[@types/ember] add ember__template (#38571)

* [@types/ember] add ember__template

* [@types/ember] move -private/handlebars into @ember/template

* [@types/ember] fix SafeString namespacing

Co-Authored-By: Mike North <michael.l.north@gmail.com>
This commit is contained in:
Scott Kidder 2019-10-03 17:22:21 -04:00 committed by Ryan Cavanaugh
parent 45780f09bd
commit 4131598ed6
19 changed files with 83 additions and 21 deletions

View File

@ -36,6 +36,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -36,6 +36,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -36,6 +36,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -36,6 +36,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -36,6 +36,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -36,6 +36,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -36,6 +36,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -28,6 +28,7 @@
/// <reference types="ember__application" />
/// <reference types="ember__test" />
/// <reference types="ember__service" />
/// <reference types="ember__template" />
import {
Objectify, Fix, UnwrapComputedPropertySetters,
@ -48,7 +49,7 @@ import { TemplateFactory } from 'htmlbars-inline-precompile';
import { Registry as ServiceRegistry } from '@ember/service';
import { Registry as ControllerRegistry } from '@ember/controller';
import * as EmberStringNs from '@ember/string';
import * as EmberStringHandlebarsNs from '@ember/string/-private/handlebars';
import * as EmberTemplateHandlebarsNs from '@ember/template/-private/handlebars';
// tslint:disable-next-line:no-duplicate-imports
import * as EmberServiceNs from '@ember/service';
import * as EmberPolyfillsNs from '@ember/polyfills';
@ -426,7 +427,7 @@ export namespace Ember {
function K(): any;
function createFrame(objec: any): any;
function Exception(message: string): void;
class SafeString extends EmberStringHandlebarsNs.SafeString {}
class SafeString extends EmberTemplateHandlebarsNs.SafeString {}
function parse(string: string): any;
function print(ast: any): void;
const logger: typeof Logger;

View File

@ -1,5 +1,5 @@
import Ember from 'ember';
import { SafeString } from '@ember/string/-private/handlebars';
import { SafeString } from '@ember/template/-private/handlebars';
const { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } = Ember.String;

View File

@ -37,6 +37,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@ -1,5 +1,4 @@
import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w, isHTMLSafe } from '@ember/string';
import { SafeString } from '@ember/string/-private/handlebars';
import { dasherize, camelize, capitalize, classify, decamelize, loc, underscore, w } from '@ember/string';
dasherize(); // $ExpectError
dasherize('blue man group'); // $ExpectType string
@ -32,15 +31,3 @@ capitalize('', ''); // $ExpectError
loc(); // $ExpectError
loc("_Hello World"); // $ExpectType string
loc("_Hello %@ %@", ["John", "Smith"]); // $ExpectType string
const handlebarsSafeString: SafeString = htmlSafe('lorem ipsum...');
htmlSafe('lorem ipsum...'); // $ExpectType SafeString
const regularString: string = htmlSafe('lorem ipsum...'); // $ExpectError
function isSafeTest(a: string | SafeString) {
if (isHTMLSafe(a)) {
a = a.toString();
}
camelize(a);
}

View File

@ -4,15 +4,13 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { SafeString } from "./-private/handlebars";
export { htmlSafe, isHTMLSafe } from '@ember/template';
export function camelize(str: string): string;
export function capitalize(str: string): string;
export function classify(str: string): string;
export function dasherize(str: string): string;
export function decamelize(str: string): string;
export function htmlSafe(str: string): SafeString;
export function isHTMLSafe(str: any): str is SafeString;
export function loc(template: string, args?: string[]): string;
export function underscore(str: string): string;
export function w(str: string): string[];

View File

@ -15,6 +15,8 @@
"../"
],
"paths": {
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"]
},
@ -23,7 +25,6 @@
"forceConsistentCasingInFileNames": true
},
"files": [
"-private/handlebars.d.ts",
"index.d.ts",
"ember__string-tests.ts"
]

View File

@ -0,0 +1,14 @@
import { SafeString } from '@ember/template/-private/handlebars';
import { htmlSafe, isHTMLSafe } from '@ember/template';
const handlebarsSafeString: SafeString = htmlSafe('lorem ipsum...');
htmlSafe('lorem ipsum...'); // $ExpectType SafeString
const regularString: string = htmlSafe('lorem ipsum...'); // $ExpectError
function isSafeTest(a: string | SafeString) {
if (isHTMLSafe(a)) {
a = a.toString();
}
a.toLowerCase();
}

9
types/ember__template/index.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
// Type definitions for non-npm package @ember/template 3.0
// Project: https://emberjs.com/api/ember/3.12/modules/@ember%2Ftemplate
// Definitions by: Mike North <https://github.com/mike-north>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { SafeString } from './-private/handlebars';
export function htmlSafe(str: string): SafeString;
export function isHTMLSafe(str: any): str is SafeString;

View File

@ -0,0 +1,30 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"-private/handlebars.d.ts",
"index.d.ts",
"ember__template-tests.ts"
]
}

View File

@ -0,0 +1,4 @@
{
"extends": "dtslint/dt.json",
"rules": {}
}

View File

@ -39,6 +39,8 @@
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/template": ["ember__template"],
"@ember/template/*": ["ember__template/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],