This is a plugin to implement this.It will compiler code defineComponent((props:Props)=>(()=>JSX)))
to defineComponent({props,setup})
.You can use it like:
import { defineComponent, ref } from "vue";
type Foo<T extends string>=Record<T,number>
interface Props<T> extends Foo<'c'>{
a?:string,
b:T
}
const Comp=defineComponent(<T extends string|number>(props:Props<T>,ctx:{})=>{
return ()=><div>{ props.b }</div>
})
//vite
yarn install vue-ts-props-plugin-vite
//vite
import { defineConfig } from "vite";
import { VueTSPropsPlugin } from "vue-ts-props-plugin-vite";
export default defineConfig({
plugins:[VueTSPropsPlugin()]
})
How to get a better development experience?
How to define emit or slots?
How to support expose type?