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

feat: improve Typescript support for exactOptionalPropertyTypes #30005

Open
3 tasks done
aeharding opened this issue Nov 7, 2024 · 0 comments
Open
3 tasks done

feat: improve Typescript support for exactOptionalPropertyTypes #30005

aeharding opened this issue Nov 7, 2024 · 0 comments
Labels

Comments

@aeharding
Copy link
Contributor

Prerequisites

Describe the Feature Request

exactOptionalPropertyTypes makes TypeScript truly enforce the definition provided matches the actual javascript value.

It's a recently added feature (v4.4) that is increasing in use.

However, many of Ionic's types are incompatible with exactOptionalPropertyTypes. This is because they define types as this:

  "shape"?: 'round';

and not this:

  "shape"?: 'round' | undefined;

It is worth noting that core React types follow the latter convention. Example:

image

Describe the Use Case

See above.

Describe Preferred Solution

Unless there is a specific reason, all Ionic attributes with ? also list undefined as an explicit accepted value.

Describe Alternatives

Not using exactOptionalPropertyTypes will opt the user out of many benefits, but it is a workaround for now.

Related Code

No response

Additional Information

This could also be considered a bug for certain attributes, since certain types, like className defined here don't actually conform with the React className attribute:

image
@ionitron-bot ionitron-bot bot added the triage label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant