Skip to content

Types not compatible with TypeScript exactOptionalPropertyTypes option #143

@kainino0x

Description

@kainino0x

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 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions