[@ember/string] Use type predicate as "isHTMLSafe" result

This commit is contained in:
Ruslan Hrabovyi
2019-01-29 00:52:25 +02:00
parent 6a792386c1
commit 28628363db
2 changed files with 11 additions and 3 deletions
+9 -1
View File
@@ -1,4 +1,4 @@
import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } from '@ember/string';
import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w, isHTMLSafe } from '@ember/string';
import { SafeString } from 'handlebars';
dasherize(); // $ExpectError
@@ -36,3 +36,11 @@ 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|Handlebars.SafeString) {
if (isHTMLSafe(a)) {
a = a.toString();
}
camelize(a);
}
+2 -2
View File
@@ -11,8 +11,8 @@ 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): Handlebars.SafeString;
export function isHTMLSafe(str: string): boolean;
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[];