Skip to content

mater1996/vue-dts-generator

 
 

Repository files navigation

vue-dts-generator

forked from vue-dts-gen

CHANGE

  • support import type from .vue files.
  • use tsconfig as internal configuration

Generate d.ts from .vue files.

Install

Globally:

npm i -g vue-dts-generator

Or locally:

npm i -D vue-dts-generator

Usage

ts-config.json

{
  "declaration": true,
  "declarationDir": "lib",
  "emitDeclarationOnly": true,
  "include": ["src/**/*.vue", "src/**/*.ts"]
}
vue-dts-generator
# Emits ${declarationDir}/*.d.ts

Example

Input:

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
  props: {
    /** Initial number */
    start: {
      type: Number,
      required: true,
    },
  },
})
</script>

Output:

declare const _default: import("vue").DefineComponent<{
    /** Initial number */
    start: {
        type: NumberConstructor;
        required: true;
    };
}, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
    start: number;
} & {}>, {}>;
export default _default;

Input:

<template>
  <div>hi</div>
</template>

<script lang="ts" setup>
import { defineProps } from 'vue'

defineProps<{
  /** The initial number */
  start: number
}>()
</script>

Output:

declare const _default: import("vue").DefineComponent<{
    /** The initial number */
    start: number;
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {
    start?: number | undefined;
}>, {}>;
export default _default;

License

MIT © mater1996

About

Generate `d.ts` from `.vue` files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 61.3%
  • JavaScript 37.5%
  • Shell 1.2%