-
Notifications
You must be signed in to change notification settings - Fork 344
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
prop with required: true
have type undefined
#106
Comments
You may need to put |
@lbssousa Nice catch ! but isn't there an issue around the types (see Notes section) that would make it work without having casting to Also, I'm wondering why we don't have Intellisense for |
@kevinmarrec Why did it not work for me? 🤔 |
@liximomo Which installed version of TypeScript have you in the workspace of this snippet ? |
And about the original creation of this issue, is there anything we can fix instead of casting props to I mean it's working for props with |
@kevinmarrec The |
required: true
shouldn't have type undefinedrequired: true
have type undefined
In fact, we can get rid of |
Nice :) |
In case anyone else like me ends up here from a web search wondering about props with an inferred
https://github.com/vuejs/composition-api#typescript Upgrading our TypeScript fixed the intellisense and type inference. |
Description
As Vue handle
required
validation and throws an error if a component is missing a required prop, the resulting type of arequired
prop shouldn't be "possibly"undefined
.Markup
Prop with
default
value 👍Prop
required
❌requiredNumber
is expected to be of typenumber
, notnumber | undefined
Notes
I guess there's something wrong around https://github.com/vuejs/composition-api/blob/master/src/component/componentProps.ts#L20
Workaround
@lbssousa mentionned casting props to
const
and it works.But I think it shouldn't be needed and there is something to fix around types.
The text was updated successfully, but these errors were encountered: