-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Generic Type Constraints with null | undefined Are Stripped During Build #12716
Comments
Please provide a complete, reproducible example that can run |
In Create vue component test.vue file:
Create export index.js file:
Then in the
Then in the root add package.json:
Add tsconfig.vitest.json:
Add vite.config.mts
Once you add these files/folders, just run |
Please use the latest version of |
Vue version
3.4.21
Link to minimal reproduction
https://play.vuejs.org/#eNp9kU1PwzAMhv+KlRNIYzvAaXSTAO0AB0CAdsqltG7JSJ0oH2NS6X/HSbWxw7RTYr+vncdOL+6snW4jirkofOWUDeAxRAu6pHYhRfBSQIuETlUcrgF3Aan24INT1MIvUOw+0eWL1nxEqrFRhLUUS0mqs8YF6B02AzTOdCAFPyfFrSRJlSEfYFvqiLAA9hTr5UXqcympmI083ISDgJ3VZUCOAApFNnLdVWdq1IyVOzDojOVidvCKCfPzG41qpxtviIfsU70Ulems0uhebFDMIMUcspK0Umvz85RzwUWc7PPVF1bfJ/Ibv0s5KV4denRbBjlooXQthlFevT/z8o5Epo+a3WfEN/RGx8Q42u55u4x95Mu0j3nL/B8ffpX+x++HSqDJOWR/Xv3DmdH/ca+nN7lO0iCGP3ruuFQ=
Steps to reproduce
Then run
npm run build
.The built output only includes
<V extends string | number>
, dropping thenull | undefined
constraints.What is expected?
The generic type constraint should preserve
null | undefined
typesComponent should accept
null/undefined
values when used with appropriate type parametersWhat is actually happening?
Built output strips
null | undefined
from generic constraintsTypeScript errors occur when trying to pass null values to components, even though they're explicitly included in the constraints
System Info
Any additional comments?
This issue makes it difficult to properly type components that need to handle nullable generic types. Current workarounds involve moving type constraints to prop definitions, but this can lead to other type incompatibility issues when the component is used with more specific types.
The text was updated successfully, but these errors were encountered: