This repository is the source code for the legacy version of nuxt-ts.
The latest nuxt-ts is owned by Nuxt core team after v2.4.0.
Shared module for using TypeScript in Nuxt 2. Enable your Nuxt project to use TypeScript easier and quicker 🍲
- Write
<script lang='ts'>- 🔮 Then you can use
~likeimport OneComponent from "~/components/one-component.vue"
- 🔮 Then you can use
- Use TypeScript
.tsfiles
- Install this module
nuxt-tsto your Nuxt project
$ npm i nuxt-ts@legacy- Install
typescript,ts-loadertoo
$ npm i typescript ts-loader
- Add
nuxt-tstomodulessection onnuxt.config.js
{
modules: [
'nuxt-ts',
]
}with options
{
modules: [
['nuxt-ts', {
forkTsChecker: { workers: 2, memoryLimit: 4096 },
tsconfig: path.join(__dirname, 'tsconfig.custom.json')
}]
]
}This may make your main build of Nuxt faster. Install fork-ts-checker-webpack-plugin. nuxt-ts uses automatically if that's installed.
$ npm i fork-ts-checker-webpack-pluginnuxt-ts provides default of tsconfig automatically. So you don't need to have tsconfig.json basically. In some cases, you may want to use your own, have your tsconfig.json as you like in project root. nuxt-ts picks that automatically as default.
If you see unintentioanl error like:
TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["node_modules/nuxt-ts/../../**/*.ts","node_modules/nuxt-ts/../../**/*.vue"]' and 'exclude' paths were '["node_modules/nuxt-ts/../../node_modules"]'.
Your project doesn't have any *.ts nor *.vue file. To avoid this, have both *.ts and *.vue one for each at least.
However, VSCode requires tsconfig.json on the root of your project currently. If you prefer to use the config which nuxt-ts provides, just make tsconfig.json with:
{
"extends": "./node_modules/nuxt-ts/tsconfig.nuxt-ts.json"
}tsconfig: string- The path for the custom
tsconfigfile
- The path for the custom
forkTsChecker: { workers: number, memoryLimit: number }- Settings for ForkTsCheckerPlugin
This vue-cli template gives a simple ready-made Nuxt2 + TS3 by using nuxt-ts: https://github.com/hmsk/nuxt-typescript-template
- Support tsx?
- CI with actual samples
Copyright (c) Kengo Hamasaki / hmsk k.hamasaki@gmail.com