/vue-ts-props-plugin

Vue plugin to auto infer runtime props options from type.

Primary LanguageTypeScriptMIT LicenseMIT

vue-ts-props-plugin

What is this

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>
})

Install

//vite
yarn install vue-ts-props-plugin-vite

Usage

//vite
import { defineConfig } from "vite";
import { VueTSPropsPlugin } from "vue-ts-props-plugin-vite";
export default defineConfig({
  plugins:[VueTSPropsPlugin()]
}) 

Q & A

How to get a better development experience?

How to define emit or slots?

How to support expose type?

License