diff --git a/types/ember-data/tsconfig.json b/types/ember-data/tsconfig.json index f64d309abe..9faf0479cf 100644 --- a/types/ember-data/tsconfig.json +++ b/types/ember-data/tsconfig.json @@ -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"], diff --git a/types/ember-feature-flags/tsconfig.json b/types/ember-feature-flags/tsconfig.json index dc3260af3a..236a684014 100644 --- a/types/ember-feature-flags/tsconfig.json +++ b/types/ember-feature-flags/tsconfig.json @@ -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"], diff --git a/types/ember-mocha/tsconfig.json b/types/ember-mocha/tsconfig.json index c6c6a09f65..3f78b53e47 100644 --- a/types/ember-mocha/tsconfig.json +++ b/types/ember-mocha/tsconfig.json @@ -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"], diff --git a/types/ember-modal-dialog/tsconfig.json b/types/ember-modal-dialog/tsconfig.json index 8fc7a37808..a08d5cb221 100644 --- a/types/ember-modal-dialog/tsconfig.json +++ b/types/ember-modal-dialog/tsconfig.json @@ -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"], diff --git a/types/ember-qunit/tsconfig.json b/types/ember-qunit/tsconfig.json index 92a555a59f..3a720840b5 100644 --- a/types/ember-qunit/tsconfig.json +++ b/types/ember-qunit/tsconfig.json @@ -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"], diff --git a/types/ember-resolver/tsconfig.json b/types/ember-resolver/tsconfig.json index 7263220f71..721a5f0162 100644 --- a/types/ember-resolver/tsconfig.json +++ b/types/ember-resolver/tsconfig.json @@ -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"], diff --git a/types/ember-test-helpers/tsconfig.json b/types/ember-test-helpers/tsconfig.json index ca139535f3..a24f024234 100644 --- a/types/ember-test-helpers/tsconfig.json +++ b/types/ember-test-helpers/tsconfig.json @@ -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"], diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index d048007d8f..f138e66b28 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -28,6 +28,7 @@ /// /// /// +/// 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; diff --git a/types/ember/test/string.ts b/types/ember/test/string.ts index d812a52dd5..ec79b98db3 100644 --- a/types/ember/test/string.ts +++ b/types/ember/test/string.ts @@ -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; diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index 6e494f5a03..5c6f90beb5 100755 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -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"], diff --git a/types/ember__string/ember__string-tests.ts b/types/ember__string/ember__string-tests.ts index c6474cd266..4cbc3ca7ed 100644 --- a/types/ember__string/ember__string-tests.ts +++ b/types/ember__string/ember__string-tests.ts @@ -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); -} diff --git a/types/ember__string/index.d.ts b/types/ember__string/index.d.ts index 2a65c9b5df..bf69021081 100644 --- a/types/ember__string/index.d.ts +++ b/types/ember__string/index.d.ts @@ -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[]; diff --git a/types/ember__string/tsconfig.json b/types/ember__string/tsconfig.json index a5a7ecc944..f94f90f698 100644 --- a/types/ember__string/tsconfig.json +++ b/types/ember__string/tsconfig.json @@ -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" ] diff --git a/types/ember__string/-private/handlebars.d.ts b/types/ember__template/-private/handlebars.d.ts similarity index 100% rename from types/ember__string/-private/handlebars.d.ts rename to types/ember__template/-private/handlebars.d.ts diff --git a/types/ember__template/ember__template-tests.ts b/types/ember__template/ember__template-tests.ts new file mode 100644 index 0000000000..0dda85bf33 --- /dev/null +++ b/types/ember__template/ember__template-tests.ts @@ -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(); +} diff --git a/types/ember__template/index.d.ts b/types/ember__template/index.d.ts new file mode 100644 index 0000000000..04e7145f48 --- /dev/null +++ b/types/ember__template/index.d.ts @@ -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 +// 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; diff --git a/types/ember__template/tsconfig.json b/types/ember__template/tsconfig.json new file mode 100644 index 0000000000..482c869d26 --- /dev/null +++ b/types/ember__template/tsconfig.json @@ -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" + ] +} diff --git a/types/ember__template/tslint.json b/types/ember__template/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/ember__template/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +} diff --git a/types/ember__test-helpers/tsconfig.json b/types/ember__test-helpers/tsconfig.json index 35638865d8..5aa3b74a0e 100644 --- a/types/ember__test-helpers/tsconfig.json +++ b/types/ember__test-helpers/tsconfig.json @@ -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"],