We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 object", "spread typed object"
Tested with TS:
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAbgLhgbxlAptJ0BOBLMAcxgF8YBeFAKBjUyiQHIATRgGipIG4qqB6PjAgALEAFcANsxgAjdDACGYGAFEcOEDiqhIsAqHXpgDFDDzNsUfEVIVqtAHRO4HWuaasO3XgKGiA7hAwACoAyjDo6pra4NAwBjhGJqjuQlYExGSUyDR0WDAs7LmphV5cQA
const v: { test: string } = { test: 'd', }; // should be an Error const incorrect: { id: string } = { ...v, id: 'd', }; // shows TS error const correct: { id: string } = { test: 'd', id: 'd', };
It allows to spread anything inside the variable const incorrect. You can even spread ...[], inside incorrect variable and it won't throw an error.
const incorrect
...[],
incorrect
If variable v is typed, incorrect case must throw an error.
v
No response
The text was updated successfully, but these errors were encountered:
Another duplicate of #39998. Type checking is working, just excess property checks not.
Sorry, something went wrong.
@MartinJohns thanks for adding a duplicate. I didn't find that one myself. I wonder if that issue covers also this case:
// should be an Error const incorrect: { id: string } = { ...[], id: 'd', };
#52060 / #9726.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
π Search Terms
"spread object", "spread typed object"
π Version & Regression Information
Tested with TS:
β― Playground Link
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAbgLhgbxlAptJ0BOBLMAcxgF8YBeFAKBjUyiQHIATRgGipIG4qqB6PjAgALEAFcANsxgAjdDACGYGAFEcOEDiqhIsAqHXpgDFDDzNsUfEVIVqtAHRO4HWuaasO3XgKGiA7hAwACoAyjDo6pra4NAwBjhGJqjuQlYExGSUyDR0WDAs7LmphV5cQA
π» Code
π Actual behavior
It allows to spread anything inside the variable
const incorrect
. You can even spread...[],
insideincorrect
variable and it won't throw an error.π Expected behavior
If variable
v
is typed,incorrect
case must throw an error.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: