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 {
62
62
63
63
Example: [ ` examples/nuxt ` ] ( ./examples/nuxt )
64
64
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
+
65
96
<br ></details >
66
97
67
98
<details >
Original file line number Diff line number Diff line change 1
1
export default {
2
2
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
4
6
'@nuxtjs/composition-api/module' ,
7
+ // install the transformer
5
8
'vue2-script-setup-transform/nuxt' ,
6
9
] ,
7
10
}
Original file line number Diff line number Diff line change 3
3
"private" : true ,
4
4
"scripts" : {
5
5
"dev" : " nuxt" ,
6
- "build" : " nuxt build" ,
6
+ "build" : " vue-tsc --noEmit && nuxt build" ,
7
7
"start" : " nuxt start" ,
8
8
"generate" : " nuxt generate"
9
9
},
16
16
"@nuxt/typescript-build" : " ^2.1.0" ,
17
17
"@nuxtjs/composition-api" : " ^0.27.0" ,
18
18
"@vue/runtime-dom" : " ^3.2.4" ,
19
+ "vue-tsc" : " ^0.3.0" ,
19
20
"vue2-script-setup-transform" : " workspace:*"
20
21
}
21
22
}
Original file line number Diff line number Diff line change 9
9
" DOM"
10
10
],
11
11
"esModuleInterop" : true ,
12
+ "skipLibCheck" : true ,
12
13
"allowJs" : true ,
13
14
"sourceMap" : true ,
14
15
"strict" : true ,
24
25
},
25
26
"types" : [
26
27
" @types/node" ,
27
- " @nuxt/types"
28
+ " @nuxt/types" ,
29
+ " vue2-script-setup-transform/types"
28
30
]
29
31
},
30
32
"exclude" : [
You can’t perform that action at this time.
0 commit comments