mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
[ember] @ember/string prototype extensions, additional tests and fixes (#28695)
* [ember] @ember/string prototype extensions, additional tests and fixes * [ember] @ember/string w/ prototype extensions - test fixes
This commit is contained in:
committed by
Ryan Cavanaugh
parent
59f25426d5
commit
b5a595ff4f
13
types/ember/index.d.ts
vendored
13
types/ember/index.d.ts
vendored
@@ -324,6 +324,17 @@ declare module 'ember' {
|
||||
|
||||
interface ArrayPrototypeExtensions<T> extends MutableArray<T>, Observable, Copyable {}
|
||||
|
||||
interface StringPrototypeExtensions {
|
||||
camelize(): string;
|
||||
decamelize(): string;
|
||||
classify(): string;
|
||||
capitalize(): string;
|
||||
loc(values?: string[]): string;
|
||||
dasherize(): string;
|
||||
underscore(): string;
|
||||
w(): string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a fullName return a factory manager.
|
||||
*/
|
||||
@@ -2453,7 +2464,7 @@ declare module 'ember' {
|
||||
function fmt(...args: string[]): string;
|
||||
function htmlSafe(str: string): Handlebars.SafeString;
|
||||
function isHTMLSafe(str: string): boolean;
|
||||
function loc(...args: string[]): string;
|
||||
function loc(template: string, args?: string[]): string;
|
||||
function underscore(str: string): string;
|
||||
function w(str: string): string[];
|
||||
}
|
||||
|
||||
28
types/ember/test/string-ext.ts
Normal file
28
types/ember/test/string-ext.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
declare global {
|
||||
interface String extends Ember.StringPrototypeExtensions {}
|
||||
}
|
||||
|
||||
''.dasherize('foo'); // $ExpectError
|
||||
''.dasherize(); // $ExpectType string
|
||||
|
||||
''.camelize(); // $ExpectType string
|
||||
''.camelize('blue man group'); // $ExpectError
|
||||
|
||||
''.decamelize(); // $ExpectType string
|
||||
''.decamelize('blue man group'); // $ExpectError
|
||||
|
||||
''.underscore(); // $ExpectType string
|
||||
''.underscore('blue man group'); // $ExpectError
|
||||
|
||||
''.w(); // $ExpectType string[]
|
||||
|
||||
''.classify(); // $ExpectType string
|
||||
''.classify('blue man group'); // $ExpectError
|
||||
|
||||
''.capitalize(); // $ExpectType string
|
||||
''.capitalize('blue man group'); // $ExpectError
|
||||
|
||||
''.loc(); // $ExpectType string
|
||||
''.loc("_Hello World"); // $ExpectError
|
||||
36
types/ember/test/string.ts
Normal file
36
types/ember/test/string.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
const { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } = Ember.String;
|
||||
|
||||
dasherize(); // $ExpectError
|
||||
dasherize('blue man group'); // $ExpectType string
|
||||
dasherize('', ''); // $ExpectError
|
||||
|
||||
camelize(); // $ExpectError
|
||||
camelize('blue man group'); // $ExpectType string
|
||||
camelize('', ''); // $ExpectError
|
||||
|
||||
decamelize(); // $ExpectError
|
||||
decamelize('blue man group'); // $ExpectType string
|
||||
decamelize('', ''); // $ExpectError
|
||||
|
||||
underscore(); // $ExpectError
|
||||
underscore('blue man group'); // $ExpectType string
|
||||
underscore('', ''); // $ExpectError
|
||||
|
||||
w(); // $ExpectError
|
||||
w('blue man group'); // $ExpectType string[]
|
||||
w('', ''); // $ExpectError
|
||||
|
||||
classify(); // $ExpectError
|
||||
classify('blue man group'); // $ExpectType string
|
||||
classify('', ''); // $ExpectError
|
||||
|
||||
capitalize(); // $ExpectError
|
||||
capitalize('blue man group'); // $ExpectType string
|
||||
capitalize('', ''); // $ExpectError
|
||||
|
||||
loc(); // $ExpectError
|
||||
loc("_Hello World"); // $ExpectType string
|
||||
// TODO - fix this case upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/281
|
||||
loc("_Hello %@ %@", ["John", "Smith"]); // $ExpectType string
|
||||
@@ -21,39 +21,41 @@
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/lib/assert.ts",
|
||||
"test/application.ts",
|
||||
"test/access-modifier.ts",
|
||||
"test/application-instance.ts",
|
||||
"test/engine.ts",
|
||||
"test/engine-instance.ts",
|
||||
"test/application.ts",
|
||||
"test/array-ext.ts",
|
||||
"test/array-proxy.ts",
|
||||
"test/array.ts",
|
||||
"test/component.ts",
|
||||
"test/computed.ts",
|
||||
"test/controller.ts",
|
||||
"test/create-negative.ts",
|
||||
"test/create.ts",
|
||||
"test/create.ts",
|
||||
"test/detect-instance.ts",
|
||||
"test/detect.ts",
|
||||
"test/ember-tests.ts",
|
||||
"test/engine-instance.ts",
|
||||
"test/engine.ts",
|
||||
"test/error.ts",
|
||||
"test/event.ts",
|
||||
"test/extend.ts",
|
||||
"test/create.ts",
|
||||
"test/create-negative.ts",
|
||||
"test/create.ts",
|
||||
"test/function-ext.ts",
|
||||
"test/helper.ts",
|
||||
"test/inject.ts",
|
||||
"test/mixin.ts",
|
||||
"test/object.ts",
|
||||
"test/observable.ts",
|
||||
"test/mixin.ts",
|
||||
"test/reopen.ts",
|
||||
"test/detect.ts",
|
||||
"test/detect-instance.ts",
|
||||
"test/array.ts",
|
||||
"test/array-ext.ts",
|
||||
"test/array-proxy.ts",
|
||||
"test/helper.ts",
|
||||
"test/computed.ts",
|
||||
"test/component.ts",
|
||||
"test/function-ext.ts",
|
||||
"test/inject.ts",
|
||||
"test/utils.ts",
|
||||
"test/transition.ts",
|
||||
"test/route.ts",
|
||||
"test/router.ts",
|
||||
"test/run.ts",
|
||||
"test/string.ts",
|
||||
"test/string-ext.ts",
|
||||
"test/test.ts",
|
||||
"test/controller.ts",
|
||||
"test/route.ts",
|
||||
"test/transition.ts",
|
||||
"test/utils.ts",
|
||||
"test/view-utils.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user