vue-dts-generator
v0.1.6
Published
forked from [vue-dts-gen](https://badgen.net/npm/v/vue-dts-gen)
Downloads
11
Readme
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