-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Wrong type for object assign array #35778
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
Labels
Duplicate
An existing issue was already created
Comments
See #9726 |
Maybe at least For example: interface ObjectConstructor {
assign<T, U extends (string | unknown[])>(target: T, source: U): T & Record<number, string>;
assign<T, U extends (boolean | number)>(target: T, source: U): T;
assign<T, U extends (null | undefined)>(target: T, source: U): T;
assign<T, U>(target: T, source: U): T & U;
} Then it will catch errors: const a: string[] = Object.assign({}, []); // Type 'Record<number, string>' is missing the following properties from type 'string[]': length, pop, push, concat, and 25 more.
const b: string[] = Object.assign({}, "ASD"); // Type 'Record<number, string>' is not assignable to type 'string[]'. |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.8.0-dev.20191218
Search Terms: Object assign spread array
Expected behavior:
Actual behavior:
Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: