Skip to content
forked from ktsn/vuetype

Generate TypeScript declaration files for .vue files

License

Notifications You must be signed in to change notification settings

DavidVollmers/vuetype

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is an experimental fork for Vue 3! Use at your own risk...

npm i -D @dvolper/vue3type

vuetype

Generate TypeScript declaration files for .vue files

Installation

You can use vuetype command after exec one of following commands.

$ npm install --global vuetype # npm
$ yarn global add vuetype # yarn

Usage

Specify the directory that includes your .vue files as the 2nd argument of vuetype command. Note that the .vue files should have TypeScript code (in <script lang="ts"> element).

vuetype src/components

Then .vue.d.ts file corresponding .vue file will be output. So you can import each .vue component with concrete type declaration! This would useful if you would like to unit test your components in TypeScript.

For example, if there is the following component:

<template>
  <div>{{ message }}</div>
</template>

<script lang="ts">
import Vue from 'vue'
import Component from 'vue-class-component'

@Component
export default class MyComp extends Vue {
  message = 'Hello'
}
</script>

You will acquire the following declaration file:

import Vue from 'vue';
export default class MyComp extends Vue {
    message: string;
}

Watch mode

You can enable watch mode by adding --watch (shorthand -w) flag. In the watch mode, vuetype watches update of .vue files and generates declaration files when the .vue files are updated.

vuetype --watch src/components

License

MIT

About

Generate TypeScript declaration files for .vue files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 95.8%
  • JavaScript 4.2%