[@ember/polyfills] Move types from ember (#28923)

https://github.com/typed-ember/ember-cli-typescript/issues/299
This commit is contained in:
Mike North
2018-09-16 15:00:28 -07:00
committed by Ryan Cavanaugh
parent 5099333846
commit 9a4fd80c8c
5 changed files with 28 additions and 22 deletions

View File

@@ -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> = 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<T extends object, U extends object>(original: T, updates: U): Mix<T, U>;
const merge: typeof EmberPolyfills.merge;
/**
* Makes a method available via an additional name.
*/
@@ -3289,14 +3286,12 @@ declare module 'ember' {
function typeOf<T>(value: T): KeysOfType<TypeLookup, T>;
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<T extends object, U extends object>(target: T, source: U): Mix<T, U>;
function assign<T extends object, U extends object, V extends object>(target: T, source1: U, source2: V): Mix3<T, U, V>;
function assign<T extends object, U extends object, V extends object, W extends object>(target: T, source1: U, source2: V, source3: W): Mix4<T, U, V, W>;
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 { }

View File

@@ -14,6 +14,9 @@
"typeRoots": [
"../"
],
"paths": {
"@ember/polyfills": ["ember__polyfills"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true

View File

@@ -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<T extends object, U extends object>(target: T, source: U): Mix<T, U>;
export function assign<T extends object, U extends object, V extends object>(target: T, source1: U, source2: V): Mix3<T, U, V>;
export function assign<T extends object, U extends object, V extends object, W extends object>(target: T, source1: U, source2: V, source3: W): Mix4<T, U, V, W>;
/**
* Merge the contents of two objects together into the first object.
* @deprecated Use Object.assign
*/
export function merge<T extends object, U extends object>(original: T, updates: U): Mix<T, U>;

View File

@@ -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"
]
}

4
types/ember__polyfills/types.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
export type Mix<A, B> = B & Pick<A, Exclude<keyof A, keyof B>>;
export type Mix3<A, B, C> = Mix<Mix<A, B>, C>;
export type Mix4<A, B, C, D> = Mix3<Mix<A, B>, C, D>;
export default Mix;