[ember] remove dependency on handlebars types

This commit is contained in:
Mike North
2019-03-01 11:42:23 -08:00
parent d1a0a77ca6
commit abfbff801f
17 changed files with 29 additions and 9 deletions

View File

@@ -35,6 +35,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -35,6 +35,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -35,6 +35,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -35,6 +35,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -35,6 +35,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -35,6 +35,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -35,6 +35,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -38,15 +38,17 @@ import {
ComputedPropertyCallback,
ObserverMethod
} from '@ember/object/-private/types';
import * as HandlebarsNamespace from 'handlebars';
// Capitalization is intentional: this makes it much easier to re-export RSVP on
// the Ember namespace.
import Rsvp from 'rsvp';
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';
// tslint:disable-next-line:no-duplicate-imports
import * as EmberServiceNs from '@ember/service';
import * as EmberPolyfillsNs from '@ember/polyfills';
@@ -424,11 +426,12 @@ export namespace Ember {
function K(): any;
function createFrame(objec: any): any;
function Exception(message: string): void;
const SafeString: typeof HandlebarsNamespace.SafeString;
class SafeString extends EmberStringHandlebarsNs.SafeString {}
function parse(string: string): any;
function print(ast: any): void;
const logger: typeof Logger;
function log(level: string, str: string): void;
function registerHelper(name: string, helper: any): void;
}
namespace String {
const camelize: typeof EmberStringNs.camelize;

View File

@@ -92,10 +92,10 @@ App.userController = Ember.Object.create({
}),
});
Handlebars.registerHelper(
Ember.Handlebars.registerHelper(
'highlight',
(property: string, options: any) =>
new Handlebars.SafeString('<span class="highlight">' + 'some value' + '</span>')
new Ember.Handlebars.SafeString('<span class="highlight">' + 'some value' + '</span>')
);
const coolView = App.CoolView.create();

View File

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

View File

@@ -36,6 +36,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -0,0 +1,5 @@
export class SafeString {
constructor(str: string);
toString(): string;
toHTML(): string;
}

View File

@@ -1,5 +1,5 @@
import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w, isHTMLSafe } from '@ember/string';
import { SafeString } from 'handlebars';
import { SafeString } from '@ember/string/-private/handlebars';
dasherize(); // $ExpectError
dasherize('blue man group'); // $ExpectType string
@@ -37,7 +37,7 @@ const handlebarsSafeString: SafeString = htmlSafe('lorem ipsum...');
htmlSafe('lorem ipsum...'); // $ExpectType SafeString
const regularString: string = htmlSafe('lorem ipsum...'); // $ExpectError
function isSafeTest(a: string|Handlebars.SafeString) {
function isSafeTest(a: string | SafeString) {
if (isHTMLSafe(a)) {
a = a.toString();
}

View File

@@ -4,7 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { SafeString } from 'handlebars';
import { SafeString } from "./-private/handlebars";
export function camelize(str: string): string;
export function capitalize(str: string): string;

View File

@@ -15,13 +15,15 @@
"../"
],
"paths": {
"@ember/string": ["ember__string"]
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"-private/handlebars.d.ts",
"index.d.ts",
"ember__string-tests.ts"
]

View File

@@ -38,6 +38,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],

View File

@@ -36,6 +36,7 @@
"@ember/runloop/*": ["ember__runloop/*"],
"@ember/service": ["ember__service"],
"@ember/string": ["ember__string"],
"@ember/string/*": ["ember__string/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/utils": ["ember__utils"],