Accept undefined as prop when exactOptionalPropertyTypes is enabled in tsconfig #12869
Unanswered
amritk
asked this question in
Help/Questions
Replies: 2 comments 3 replies
-
Related issue, though not exactly the same #6532 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello! This is expected behavior, because this is exactly what this option is for) type Props = { hello?: string }
const foo: Props = { hello: undefined }; Without With
Since props passed to component as object, Your example is not really relevant to this issue. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Vue version
3.5.12
Link to minimal reproduction
https://github.com/amritk/vue-exact-optional-property-types
Steps to reproduce
Create a component like so
enable
exactOptionalProperties
in tsconfigWhat is expected?
You should be able to pass undefined into the prop as you can in typescript
What is actually happening?
It gives an error saying undefined is not assignable to string. However we have a default set so it will end up being a string.
System Info
Any additional comments?
Is there a way to get this to work like it does in typescript without explicitly setting the type
| undefined
Beta Was this translation helpful? Give feedback.
All reactions