Skip to content

Inexact optional property types #499

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

Open
1 task done
iwoplaza opened this issue Apr 11, 2025 · 1 comment · May be fixed by #500
Open
1 task done

Inexact optional property types #499

iwoplaza opened this issue Apr 11, 2025 · 1 comment · May be fixed by #500
Labels
bug Something isn't working

Comments

@iwoplaza
Copy link

iwoplaza commented Apr 11, 2025

Environment

  • unplugin: 6.2.2
  • typescript: 5.7.2

Reproduction

https://stackblitz.com/edit/vitejs-vite-lovdzaug?file=unplugin-foo.ts

Describe the bug

Definitions like:

type StringFilter = FilterPattern | {
	include?: FilterPattern
	exclude?: FilterPattern
};

... can cause friction when using the TypeScript exactOptionalPropertyTypes compiler option, since under that configuration, undefined is not a valid value to be passed into include or exclude. Would it break anything to widen the type to the following?:

type StringFilter = FilterPattern | {
	include?: FilterPattern | undefined
	exclude?: FilterPattern | undefined
};

Additional information

  • Would you be willing to help implement a patch for this?
@iwoplaza iwoplaza added the bug Something isn't working label Apr 11, 2025
@iwoplaza iwoplaza linked a pull request Apr 11, 2025 that will close this issue
@sxzz
Copy link
Member

sxzz commented Apr 12, 2025

/cc @antfu WDYT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants