defineProps<PropsType> generates wrong code in typescript when PropsType is exported
Vue version
3.2.47
Link to minimal reproduction
Steps to reproduce
If defineProps
is supplied with a typescript interface that is exported, the compiler seems to be unable to traverse the type heirachy (extends) and hence generate incorrectly typed props.
- If the interface itself is empty (e.g. all the fields are inherited from the base interface), it yields ts code that does not compile.
- If the interface is non-empty, the props is only typed to the interface itself, and all the fields from base interface are ignored.
For example, this will yield typescript with syntax error:
<script setup lang="ts">
interface PropsBase { type: string }
export interface Props extends PropsBase { }
const props = withDefaults(defineProps<Props>(), {});
</script>
What is expected?
SFC compiler should be able to generate typescript code with props typed correctly regardless of whether the interface is exported or not.
What is actually happening?
Once the Type
in defineProps<Type>
is exported, SFC compiler is no longer able to follow the extends
and hence produce incorrect type literal for props.
System Info
No response
Any additional comments?
No response