types icon indicating copy to clipboard operation
types copied to clipboard

Types not compatible with TypeScript `exactOptionalPropertyTypes` option

Open kainino0x opened this issue 2 years ago • 0 comments

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 }

kainino0x avatar Nov 01 '23 19:11 kainino0x