Type is lost when returning a property from setup that uses the name of a prop.
Version
3.2.33
Reproduction link
Steps to reproduce
test.ts
import { defineComponent, PropType } from "vue";
export enum ValidSize {
sm = "sm",
}
export type ValidSizeType = keyof typeof ValidSize;
export function sizeProp<T extends ValidSize>(defaultSize?: T) {
return {
size: {
type: String as PropType<ValidSizeType>,
default: defaultSize,
validator: (value: ValidSize) => {
if (value === null) return true;
return !!ValidSize[value];
},
},
};
}
const Comp = defineComponent({
props: {
...sizeProp(ValidSize.sm),
},
setup() {
return {
size: 1, // if you comment this, it works
};
},
});
type CompType = InstanceType<typeof Comp>; // never
What is expected?
Comp
to not be never
What is actually happening?
Comp should keep the correct type