Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Stable types for @ember/polyfill #20325

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:sigh: This is probably the “right” thing to do here, since it’s what TS itself has, but I hate it.

/**
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