Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

provegard/ts-typecheck-vue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ts-typecheck-vue

What is it?

ts-typecheck-vue is a piece of code that type checks TypeScript code with Vue support, i.e. it can type check regular TypeScript code as well as code inside a <script lang="ts"> block in a Vue Single File Component (SFC). Vue SFC files are files with a .vue extension.

Why does it exist?

Let's assume we have project that uses Parcel to build TypeScript code as well as Vue SFC files. Parcel performs no type checking when compiling TypeScript files, so we have to have a separate build step that invokes the TypeScript compiler (tsc) with --noEmit.

To be able to to import a Vue component from an SFC file, we use the following shim (see for example here):

declare module "*.vue" {
  import Vue from "vue"
  export default Vue
}

This makes it possible to elsewhere do:

import MyComponent from "./some/component.vue"

We also include .vue files in our tsconfig.json:

{
   "compilerOptions": {
     ...
   },
   "include": [
     ...,
     "./**/*.vue"
   ]
}

Now the problem is - how do we type check TypeScript code inside the SFC files?

There are some existing options:

In contrast, ts-typecheck-vue only depends on TypeScript itself.

How to use

CLI

Library

About

Type-checking TypeScript code with Vue support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published