[ember] refactor @ember/polyfills types into their own package (#28797)

* [ember] refactor @ember/polyfills into its own module
fixes https://github.com/typed-ember/ember-cli-typescript/issues/273

* [ember] delay activation of some tests until after future improvements to Ember.assign/merge
This commit is contained in:
Mike North
2018-09-14 09:56:14 -07:00
committed by Ryan Cavanaugh
parent 92abd0cd3d
commit 0c694b22fb
4 changed files with 67 additions and 0 deletions
@@ -0,0 +1,25 @@
import { assign, merge } from '@ember/polyfills';
(() => { /* assign */
assign({}, { a: 'b'});
assign({}, { a: 'b'}).a; // $ExpectType string
assign({ a: 6 }, { a: 'b'}).a; // $ExpectType string
assign({ a: 6 }, {}).a; // $ExpectType number
assign({ b: 6 }, {}).a; // $ExpectError
// TODO enable after https://github.com/typed-ember/ember-cli-typescript/issues/291
// assign({}, { b: 6 }, {}).b; // $ExpectType number
assign({ a: 'hello' }, { b: 6 }, {}).a; // $ExpectType string
// TODO enable after https://github.com/typed-ember/ember-cli-typescript/issues/291
// assign({ a: 'hello' }, { b: 6 }, { a: true }).a; // $ExpectType boolean
// TODO enable after https://github.com/typed-ember/ember-cli-typescript/issues/291
// assign({ a: 'hello' }, '', { a: true }).a; // $ExpectError
assign({ d: ['gobias industries'] }, { a: 'hello' }, { b: 6 }, { a: true }).d; // $ExpectType string[]
})();
(() => { /* merge */
merge({}, { a: 'b'});
merge({}, { a: 'b'}).a; // $ExpectType string
merge({ a: 6 }, { a: 'b'}).a; // $ExpectType string
merge({ a: 6 }, {}).a; // $ExpectType number
merge({ b: 6 }, {}).a; // $ExpectError
})();
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for @ember/polyfills 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 assign: typeof Ember.assign;
export const merge: typeof Ember.merge;
+28
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/polyfills": ["ember__polyfills"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ember__polyfills-tests.ts"
]
}
+4
View File
@@ -0,0 +1,4 @@
{
"extends": "dtslint/dt.json",
"rules": {}
}