Skip to content

Conversation

@geryogam
Copy link

@geryogam geryogam commented Apr 2, 2024

Update this error message

error TS2698: Spread types may only be created from object types.

to this one

error TS2698: Spread appears unintentional because this value is not possibly an object.

Fixes #57957

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 2, 2024
@geryogam
Copy link
Author

geryogam commented Apr 2, 2024

@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.
Copy link
Member

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

Copy link
Author

@geryogam geryogam Apr 3, 2024

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?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Member

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.

Copy link
Author

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.
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

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

I agree.

@sandersn
Copy link
Member

sandersn commented Jun 6, 2024

To help with PR housekeeping, I'm going to close this PR since it's pretty old now.

@sandersn sandersn closed this Jun 6, 2024
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

All primitives can be spread in objects according to MDN but TypeScript prevents it

4 participants