UNPKG

1.78 kBMarkdownView Raw
1# @vue/cli-plugin-typescript
2
3> typescript plugin for vue-cli
4
5Uses TypeScript + `ts-loader` + [fork-ts-checker-webpack-plugin](https://github.com/Realytics/fork-ts-checker-webpack-plugin) for faster off-thread type checking.
6
7## Configuration
8
9TypeScript can be configured via `tsconfig.json`.
10
11Since `3.0.0-rc.6`, `typescript` is now a peer dependency of this package, so you can use a specific version of TypeScript by updating your project's `package.json`.
12
13This plugin can be used alongside `@vue/cli-plugin-babel`. When used with Babel, this plugin will output ES2015 and delegate the rest to Babel for auto polyfill based on browser targets.
14
15## Injected Commands
16
17If opted to use [TSLint](https://palantir.github.io/tslint/) during project creation, `vue-cli-service lint` will be injected.
18
19## Caching
20
21[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/ts-loader`.
22
23## Parallelization
24
25[thread-loader](https://github.com/webpack-contrib/thread-loader) is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting `parallel: false` in `vue.config.js`.
26
27`parallel` should be set to `false` when using Typescript in combination with non-serializable loader options, such as regexes, dates and functions. These options would not be passed correctly to `ts-loader` which may lead to unexpected errors.
28
29## Installing in an Already Created Project
30
31``` sh
32vue add typescript
33```
34
35## Injected webpack-chain Rules
36
37- `config.rule('ts')`
38- `config.rule('ts').use('ts-loader')`
39- `config.rule('ts').use('babel-loader')` (when used alongside `@vue/cli-plugin-babel`)
40- `config.rule('ts').use('cache-loader')`
41- `config.plugin('fork-ts-checker')`