Prop with validator breaks prop types for component
Version
3.0.2
Reproduction link
https://codesandbox.io/s/blissful-darwin-mi9ul
Steps to reproduce
Try to access props.type
What is expected?
No error
What is actually happening?
Property 'type' does not exist on type 'Readonly<...
Removing the validator or using as Prop<string>
fixes the error, but it should be inferred without breaking the component.
Use arrow function instead, or explicitly add an annotation to this
: validator(this: void, val: string){ ... }
Ah yeah it's https://github.com/vuejs/vue/issues/8679 again, thanks.
I would like to add that this is a design limitation in TypeScript; see this issue microsoft/TypeScript#38845. And I believe that the example under Annotating Props in the docs will have this problem as well.
Still encountered the same issue even if following doc... (vue 3.0.7, typescript 4.2.3) https://github.com/vuejs/vue-next/issues/2738#issuecomment-795080280