Skip to content

Commit

Permalink
Move @ember/polyfill types to stable
Browse files Browse the repository at this point in the history
The updated types and tests now match those of `Object.assign`

toward #19946
  • Loading branch information
theroncross committed Jan 19, 2023
1 parent cb14f61 commit dd50deb
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 41 deletions.
6 changes: 3 additions & 3 deletions packages/@ember/polyfills/lib/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { deprecate } from '@ember/debug';
export function assign<T, U>(target: T, source: U): T & U;
export function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
export function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
export function assign(target: object, ...sources: object[]): object;
export function assign(target: object, ...sources: any[]): any;
/**
Copy properties from a source object to a target object. Source arguments remain unchanged.
Expand All @@ -29,7 +29,7 @@ export function assign(target: object, ...sources: object[]): object;
@public
@static
*/
export function assign(target: object, ...rest: object[]): object {
export function assign(target: object, ...sources: any[]): any {
deprecate(
'Use of `assign` has been deprecated. Please use `Object.assign` or the spread operator instead.',
false,
Expand All @@ -45,5 +45,5 @@ export function assign(target: object, ...rest: object[]): object {
}
);

return Object.assign(target, ...rest);
return Object.assign(target, ...sources);
}
8 changes: 4 additions & 4 deletions type-tests/@ember/polyfills-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { expectTypeOf } from 'expect-type';
/* assign */
assign({}, { a: 'b' });
expectTypeOf(assign({}, { a: 'b' }).a).toBeString();
expectTypeOf(assign({ a: 6 }, { a: 'b' }).a).toBeString();
expectTypeOf(assign({ a: 6 }, { a: 'b' }).a).toEqualTypeOf<string & number>();
expectTypeOf(assign({ a: 6 }, {}).a).toBeNumber();
// @ts-expect-error
assign({ b: 6 }, {}).a;
expectTypeOf(assign({}, { b: 6 }, {}).b).toBeNumber();
expectTypeOf(assign({ a: 'hello' }, { b: 6 }, {}).a).toBeString();
expectTypeOf(assign({ a: 'hello' }, { b: 6 }, { a: true }).a).toBeBoolean();
// @ts-expect-error
assign({ a: 'hello' }, { b: 6 }, { a: true }).a;
// @ts-expect-error
assign({ a: 'hello' }, '', { a: true }).a;
expectTypeOf(
assign({ d: ['gobias industries'] }, { a: 'hello' }, { b: 6 }, { a: true }).d
assign({ d: ['gobias industries'] }, { a: 'hello' }, { b: 6 }).d
).toEqualTypeOf<string[]>();
// @ts-expect-error
assign({}, { a: 0 }, { b: 1 }, { c: 2 }, { d: 3 }).a;

// matches Object.assign
Expand Down
23 changes: 0 additions & 23 deletions types/preview/@ember/polyfills/index.d.ts

This file was deleted.

6 changes: 0 additions & 6 deletions types/preview/@ember/polyfills/types.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ import './@ember/object/observers';
import './@ember/object/promise-proxy-mixin';
import './@ember/object/proxy';

import './@ember/polyfills';
import './@ember/polyfills/types';

import './@ember/routing';
import './@ember/routing/-private/router-dsl';
import './@ember/routing/auto-location';
Expand Down
2 changes: 0 additions & 2 deletions types/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ const PREVIEW_MODULES = [
'@ember/object/observers.d.ts',
'@ember/object/promise-proxy-mixin.d.ts',
'@ember/object/proxy.d.ts',
'@ember/polyfills/index.d.ts',
'@ember/polyfills/lib/assign.d.ts',
'@ember/renderer/index.d.ts',
'@ember/routing/-internals.d.ts',
'@ember/routing/auto-location.d.ts',
Expand Down

0 comments on commit dd50deb

Please sign in to comment.