forked from vue-dts-gen
- support import type from
.vue
files. - use tsconfig as internal configuration
Generate d.ts
from .vue
files.
Globally:
npm i -g vue-dts-generator
Or locally:
npm i -D vue-dts-generator
ts-config.json
{
"declaration": true,
"declarationDir": "lib",
"emitDeclarationOnly": true,
"include": ["src/**/*.vue", "src/**/*.ts"]
}
vue-dts-generator
# Emits ${declarationDir}/*.d.ts
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;
MIT © mater1996