diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 5b059a0ee4..5a2a654cbc 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -34,6 +34,7 @@ declare module 'ember' { import { Registry as ServiceRegistry } from '@ember/service'; import { Registry as ControllerRegistry } from '@ember/controller'; import ModuleComputed from '@ember/object/computed'; + import * as EmberPolyfills from '@ember/polyfills'; // Get an alias to the global Array type to use in inner scope below. type GlobalArray = T[]; @@ -3138,11 +3139,7 @@ declare module 'ember' { * A value is present if it not `isBlank`. */ function isPresent(obj?: any): boolean; - /** - * Merge the contents of two objects together into the first object. - * @deprecated Use Object.assign - */ - function merge(original: T, updates: U): Mix; + const merge: typeof EmberPolyfills.merge; /** * Makes a method available via an additional name. */ @@ -3289,14 +3286,12 @@ declare module 'ember' { function typeOf(value: T): KeysOfType; function typeOf(): 'undefined'; function typeOf(item: any): string; + // TODO: replace with an es6 reexport when declare module 'ember' is removed /** * Copy properties from a source object to a target object. * @deprecated Use Object.assign */ - function assign(target: T, source: U): Mix; - function assign(target: T, source1: U, source2: V): Mix3; - function assign(target: T, source1: U, source2: V, source3: W): Mix4; - + const assign: typeof EmberPolyfills.assign; /** * Polyfill for Object.create * @deprecated Use Object.create @@ -3790,15 +3785,6 @@ declare module '@ember/object/proxy' { export default class ObjectProxy extends Ember.ObjectProxy { } } -declare module '@ember/polyfills' { - import Ember from 'ember'; - export const assign: typeof Ember.assign; - export const create: typeof Ember.create; - export const hasPropertyAccessors: typeof Ember.platform.hasPropertyAccessors; - export const keys: typeof Ember.keys; - export const merge: typeof Ember.merge; -} - declare module '@ember/routing/auto-location' { import Ember from 'ember'; export default class AutoLocation extends Ember.AutoLocation { } diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index a267c26dd5..ed3a4345ff 100755 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,6 +14,9 @@ "typeRoots": [ "../" ], + "paths": { + "@ember/polyfills": ["ember__polyfills"] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/ember__polyfills/index.d.ts b/types/ember__polyfills/index.d.ts index 2a3c9b4a93..1bca6dbba4 100644 --- a/types/ember__polyfills/index.d.ts +++ b/types/ember__polyfills/index.d.ts @@ -4,7 +4,18 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import Ember from 'ember'; +import { Mix, Mix3, Mix4 } from './types'; -export const assign: typeof Ember.assign; -export const merge: typeof Ember.merge; +/** + * Copy properties from a source object to a target object. + * @deprecated Use Object.assign + */ +export function assign(target: T, source: U): Mix; +export function assign(target: T, source1: U, source2: V): Mix3; +export function assign(target: T, source1: U, source2: V, source3: W): Mix4; + +/** + * Merge the contents of two objects together into the first object. + * @deprecated Use Object.assign + */ +export function merge(original: T, updates: U): Mix; diff --git a/types/ember__polyfills/tsconfig.json b/types/ember__polyfills/tsconfig.json index a2a6bd371b..ab08b95d99 100644 --- a/types/ember__polyfills/tsconfig.json +++ b/types/ember__polyfills/tsconfig.json @@ -15,7 +15,8 @@ "../" ], "paths": { - "@ember/polyfills": ["ember__polyfills"] + "@ember/polyfills": ["ember__polyfills"], + "@ember/polyfills/*": ["ember__polyfills/*"] }, "types": [], "noEmit": true, @@ -23,6 +24,7 @@ }, "files": [ "index.d.ts", + "types.d.ts", "ember__polyfills-tests.ts" ] } diff --git a/types/ember__polyfills/types.d.ts b/types/ember__polyfills/types.d.ts new file mode 100644 index 0000000000..d1c8cf2306 --- /dev/null +++ b/types/ember__polyfills/types.d.ts @@ -0,0 +1,4 @@ +export type Mix = B & Pick>; +export type Mix3 = Mix, C>; +export type Mix4 = Mix3, C, D>; +export default Mix;