Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion types/ember__string/ember__string-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { dasherize, camelize, capitalize, classify, decamelize, loc, underscore, w } from '@ember/string';
import {
dasherize,
camelize,
capitalize,
classify,
decamelize,
loc,
underscore,
w,
htmlSafe,
isHTMLSafe,
} from '@ember/string';

dasherize(); // $ExpectError
dasherize('blue man group'); // $ExpectType string
Expand Down Expand Up @@ -31,3 +42,10 @@ capitalize('', ''); // $ExpectError
loc(); // $ExpectError
loc("_Hello World"); // $ExpectType string
loc("_Hello %@ %@", ["John", "Smith"]); // $ExpectType string

htmlSafe(); // $ExpectError
htmlSafe('foo'); // $ExpectType SafeString

isHTMLSafe(); // $ExpectError
isHTMLSafe('foo'); // $ExpectType boolean
isHTMLSafe(htmlSafe('foo')); // $ExpectType boolean
7 changes: 7 additions & 0 deletions types/ember__string/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.7

import { htmlSafe as templateHtmlSafe, isHTMLSafe as templateIsHTMLSafe } from '@ember/template';

export function camelize(str: string): string;
export function capitalize(str: string): string;
export function classify(str: string): string;
Expand All @@ -15,3 +17,8 @@ export function decamelize(str: string): string;
export function loc(template: string, args?: string[]): string;
export function underscore(str: string): string;
export function w(str: string): string[];

declare module '@ember/string' {
function htmlSafe(...args: Parameters<typeof templateHtmlSafe>): ReturnType<typeof templateHtmlSafe>;
function isHTMLSafe(...args: Parameters<typeof templateIsHTMLSafe>): ReturnType<typeof templateIsHTMLSafe>;
}