vite-plugin-tsx-auto-props
this is a vite plugin for auto props in tsx
Last updated 2 years ago by aibayanyu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vite-plugin-tsx-auto-props 
SYNC missed versions from official npm registry.

vite-plugin-tsx-auto-props

Vue does not provide a way to automatically specify props for functional components written in TSX. This plugin solves this problem.

Install

pnpm add vite-plugin-tsx-auto-props -D

Usage

// vite.config.ts
import { defineConfig } from 'vite'
import { tsxAutoProps } from 'vite-plugin-tsx-auto-props'
import vueJsx from '@vitejs/plugin-vue-jsx'

export default defineConfig({
    plugins: [
        tsxAutoProps(),
        vueJsx(),
    ],
})

Example

Single File

export interface Props {
    foo: string
    bar: number
}

export const Single = defineComponent<Props>(() => {
    return () => {
        return <div></div>
    }
})

Multiple Files

// typing.ts
export interface Props {
    foo: string
    bar: number
}

// component.tsx
export const Single = defineComponent<Props>(() => {
    return () => {
        return <div></div>
    }
})

Support Demos

import { defineComponent } from 'vue'
import type { Props } from './typing'

export interface Props1 {
  foo1: string
  bar1: number
}

export type Props2 = Props & Props1
export type Props3 = Pick<Props2, 'foo1' | 'foo'>

export const Single = defineComponent<Props>(() => {
  return () => {
    return <div></div>
  }
})

export const Single2 = defineComponent((_props: Props2) => {
  return () => {
    return <div></div>
  }
})

export const Single3 = defineComponent({
  setup(_props: Props3) {
    return () => {
      return <div></div>
    }
  },
})

Acknowledgements

License

MIT. Made with ❤️ by aibayanyu20

Current Tags

  • 0.0.5-beta.1                                ...           beta (2 years ago)
  • 0.0.8                                ...           latest (2 years ago)

16 Versions

  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.5-beta.1                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.4-beta.0                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.3-beta.4                                ...           2 years ago
  • 0.0.3-beta.2                                ...           2 years ago
  • 0.0.3-beta.1                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
  • 0.0.1-beta.3                                ...           2 years ago
  • 0.0.1-beta.2                                ...           2 years ago
  • 0.0.1-beta.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 7
Last Month 16
Dependencies (6)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org | Home |