[ember] refactor @ember/string types into their own package (#28791)

* [@types/ember__string] refactor types out of @types/ember, add additional tests

* [@ember/string] enable all TSLint rules
This commit is contained in:
Mike North
2018-09-14 10:23:36 -07:00
committed by Ryan Cavanaugh
parent c43bcd9fd7
commit 614492e26b
4 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } from '@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
loc("_Hello %@ %@", ["John", "Smith"]); // $ExpectType string

18
types/ember__string/index.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
// Type definitions for @ember/string 3.0
// Project: http://emberjs.com/
// Definitions by: Mike North <https://github.com/mike-north>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import Ember from 'ember';
export const camelize: typeof Ember.String.camelize;
export const capitalize: typeof Ember.String.capitalize;
export const classify: typeof Ember.String.classify;
export const dasherize: typeof Ember.String.dasherize;
export const decamelize: typeof Ember.String.decamelize;
export const htmlSafe: typeof Ember.String.htmlSafe;
export const isHTMLSafe: typeof Ember.String.isHTMLSafe;
export const loc: typeof Ember.String.loc;
export const underscore: typeof Ember.String.underscore;
export const w: typeof Ember.String.w;

View File

@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"@ember/string": ["ember__string"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ember__string-tests.ts"
]
}

View File

@@ -0,0 +1,4 @@
{
"extends": "dtslint/dt.json",
"rules": {}
}