-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Update an error message to match TypeScript’s behaviour which allows spreading non objects in objects #58046
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
Conversation
…spreading non objects in objects
|
@microsoft-github-policy-service agree |
| return { ...arg } | ||
| ~~~~~~ | ||
| !!! error TS2698: Spread types may only be created from object types. | ||
| !!! error TS2698: Spread appears unintentional because this value is not possibly an object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need better logic here - T is constrained to string[] which is an object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I'm not familiar with the codebase, where should I look at to fix these tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geryogam This is likely going to be quite difficult, and unfortunately I can't allocate time to help new contributors with a "You can send a PR if you want to"-tier issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, since you think it's going to be quite difficult and you're the development lead for the TypeScript team at Microsoft, I don't think I'll even try to go any further, as I don't have much time to devote to open source contributions at the moment. Thanks for the information.
| return { ...arg } | ||
| ~~~~~~ | ||
| !!! error TS2698: Spread types may only be created from object types. | ||
| !!! error TS2698: Spread appears unintentional because this value is not possibly an object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect logic here; T is not constrained to only primitives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
|
To help with PR housekeeping, I'm going to close this PR since it's pretty old now. |
Update this error message
to this one
Fixes #57957