We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
spread operator object wrong type
This is the behavior in every version I tried up to 5.0.0-dev.20221103
Playground
An object type can be assigned with any other object type via spread operator without any errors
const foo: {} = { ...{ foo: 'bar' }, ...['including arrays'], };
for arrays it works as expected
// type number[] is not assignable to type [] const arr: [] = [ ...[1,2,3,4,5,6,7] ]; // no error, ok const arr2: [1] = [ ...[1] as [1] ];
in the following code t property is infered correctly, but no error
t
const f = (arg: {[key: string]: {foo: 'bar'}}) => {} f({ t: { foo: 'bar', ...{bar: 'baz'}, // no error, wrong // bar: 'baz', // error, ok } })
Spread operator ignores object type
Spread operator must respect object type
The text was updated successfully, but these errors were encountered:
Duplicate of #39998.
Sorry, something went wrong.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Bug Report
π Search Terms
spread operator object wrong type
π Version & Regression Information
This is the behavior in every version I tried up to 5.0.0-dev.20221103
β― Playground Link
Playground
π» Code
An object type can be assigned with any other object type via spread operator without any errors
for arrays it works as expected
in the following code
t
property is infered correctly, but no errorπ Actual behavior
Spread operator ignores object type
π Expected behavior
Spread operator must respect object type
The text was updated successfully, but these errors were encountered: