-
-
Notifications
You must be signed in to change notification settings - Fork 437
Optional properties not working in 0.40.5
when using exactOptionalProperties
#1798
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
Comments
Actually this is expected behavior, You can reproduce this problem with equivalent regular ts code: const Comp = defineComponent({
props: {
placeholder: {
type: String,
required: false,
}
}
});
const textarea: JSX.IntrinsicElements['textarea'] = {
placeholder: (new Comp()).placeholder,
}; |
TL;DR: This might actually be a problem with @vue/runtime-dom Yes, it's optional and should hence be undefined in the template. In my first post I attempted to set my optional If you look at a comparative React example on the Typescript playground, there's no error. Seems like they have amended the types of the placeholder prop on So I guess the problem isn't Volars handling of this, but rather the types from |
BTW: |
I'm using
"exactOptionalProperties": true
in my tsconfig, and have been struggling with optional prop types.After upgrading to
0.40.5
I simply can't get the following code to work, no matter the combination I choose for the type of theplaceholder
prop. I've tried the following combinations:placeholder?: string | undefined
(worked in<=0.40.4
)placeholder?: string
(the proper type if you ask me)placeholder: string | undefined
type Props = TextareaHTMLAttributes;
The error message given for the above code is:
The text was updated successfully, but these errors were encountered: