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

[Feature]: Enable TypeScript exactOptionalPropertyTypes #1404

Closed
1 of 2 tasks
iamandrewluca opened this issue Oct 30, 2024 · 5 comments
Closed
1 of 2 tasks

[Feature]: Enable TypeScript exactOptionalPropertyTypes #1404

iamandrewluca opened this issue Oct 30, 2024 · 5 comments

Comments

@iamandrewluca
Copy link

iamandrewluca commented Oct 30, 2024

Describe the feature

It would be great to have the TypeScript exactOptionalPropertyTypes option enabled.

https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes

https://youtu.be/krj9KCxJ5OY

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.
@zernonia
Copy link
Member

Hi @iamandrewluca ! Would love to hear what do you expect for this request ya?

@iamandrewluca
Copy link
Author

iamandrewluca commented Oct 30, 2024

Hi, @zernonia. I will add more details to the task later today.

The YT Video I linked explains why library authors would be better off having this enabled.
In general, the change would be that any prop marked as optional via ? should also have undefined in type explicit.

@iamandrewluca
Copy link
Author

iamandrewluca commented Oct 30, 2024

@iamandrewluca
Copy link
Author

iamandrewluca commented Oct 30, 2024

@zernonia after reading the issues above decided to close for now, as it seems more of a problem in the upstream (vue/vue-tsc/volar) libraries

@iamandrewluca
Copy link
Author

iamandrewluca commented Feb 5, 2025

Hey, @zernonia I created a PR in Vue, to add undefined to optional properties. That will only allow for native elements to pass undefined when exactOptionalPropertyTypes is enabled.

In the case of libraries, they also need to mark all their optional props with explicit undefined if they want the library to work with exactOptionalPropertyTypes enabled.

We can probably reopen this issue. I intend to create PRs to implement this.

vuejs/core#12771

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

2 participants