Skip to content
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

Types not compatible with TypeScript exactOptionalPropertyTypes option #143

Open
kainino0x opened this issue Nov 1, 2023 · 0 comments
Open

Comments

@kainino0x
Copy link
Collaborator

In TypeScript, by default, if you have an optional field like:
{ x?: number }
then it allows any of:
{ x: 5 }, { x: undefined }, {}

There is an option called exactOptionalPropertyTypes, which makes { x: undefined } invalid, allowing only:
{ x: 5 }, {}

However { x: undefined } is allowed by the rules of WebIDL, so all of our optional fields need to be written like:
{ x?: undefined | number }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant