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
Typescript props type inference is incorrect #15
Comments
The PR from @ChuChencheng works great! There are still issues with the import { createComponent } from 'vue'
createComponent({
props: {
foo: {
type: String,
required: true,
},
bar: {
type: String,
},
} as const,
setup(props) {
props.foo // "string" as expected
props.bar // should be -> "string | undefined" but it actually "string"
}
}) |
Trying it out as well, found some problems with props inference too. props: {
// complexObject: {
// type: (Object as unknown) as PropType<ComplexObject>,
// required: true,
// }, <= inferred as {type: ComplexObject, required true}, should be inferred as ComplexObject
complexObject: (Object as unknown) as PropType<ComplexObject>, // <= inferred as ComplexObject, but there is no required, should be inferred as optional
} as const, In general, this section doesn't seem to be enforced in the actual implementation. PS: remember to import PS2:
If anyone is wondering, this isn't already working (as expected I guess) |
The type of msg should be string, but is inferred to be of type StringConstructor
The text was updated successfully, but these errors were encountered: