This repository was archived by the owner on Dec 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +546
-3
lines changed Expand file tree Collapse file tree 5 files changed +546
-3
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,37 @@ export default {
6262
6363Example: [ ` examples/nuxt ` ] ( ./examples/nuxt )
6464
65+ ###### TypeScript
66+
67+ To use TypeScript with Nuxt, install the [ ` @nuxtjs/typescript-module ` ] ( https://typescript.nuxtjs.org/ ) but disable the type check:
68+
69+ ``` bash
70+ npm i -D @nuxt/typescript-build vue-tsc
71+ ```
72+
73+ ``` ts
74+ // nuxt.config.js
75+ export default {
76+ buildModules: [
77+ [' @nuxt/typescript-build' , { typeCheck: false }],
78+ ' @nuxtjs/composition-api/module' ,
79+ ' vue2-script-setup-transform/nuxt' ,
80+ ],
81+ }
82+ ```
83+
84+ And then use [ ` vue-tsc ` ] ( https://github.com/johnsoncodehk/volar ) to do the type check at build time:
85+
86+ ``` jsonc
87+ // package.json
88+ {
89+ " scripts" : {
90+ " dev" : " nuxt" ,
91+ " build" : " vue-tsc --noEmit && nuxt build" ,
92+ }
93+ }
94+ ```
95+
6596<br ></details >
6697
6798<details >
Original file line number Diff line number Diff line change 11export default {
22 buildModules : [
3- '@nuxt/typescript-build' ,
3+ // we disable the type check and left it to `vue-tsc`
4+ [ '@nuxt/typescript-build' , { typeCheck : false } ] ,
5+ // @vue /composition-api support
46 '@nuxtjs/composition-api/module' ,
7+ // install the transformer
58 'vue2-script-setup-transform/nuxt' ,
69 ] ,
710}
Original file line number Diff line number Diff line change 33 "private" : true ,
44 "scripts" : {
55 "dev" : " nuxt" ,
6- "build" : " nuxt build" ,
6+ "build" : " vue-tsc --noEmit && nuxt build" ,
77 "start" : " nuxt start" ,
88 "generate" : " nuxt generate"
99 },
1616 "@nuxt/typescript-build" : " ^2.1.0" ,
1717 "@nuxtjs/composition-api" : " ^0.27.0" ,
1818 "@vue/runtime-dom" : " ^3.2.4" ,
19+ "vue-tsc" : " ^0.3.0" ,
1920 "vue2-script-setup-transform" : " workspace:*"
2021 }
2122}
Original file line number Diff line number Diff line change 99 " DOM"
1010 ],
1111 "esModuleInterop" : true ,
12+ "skipLibCheck" : true ,
1213 "allowJs" : true ,
1314 "sourceMap" : true ,
1415 "strict" : true ,
2425 },
2526 "types" : [
2627 " @types/node" ,
27- " @nuxt/types"
28+ " @nuxt/types" ,
29+ " vue2-script-setup-transform/types"
2830 ]
2931 },
3032 "exclude" : [
You can’t perform that action at this time.
0 commit comments