File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 3
3
Cheatsheets for experienced Vue developers getting started with TypeScript
4
4
5
5
- https://devchat.tv/views-on-vue/vov-076-typescript-tell-all-with-jack-koppa/
6
+
7
+
8
+ ## Recommended ts.config setup
9
+ note: ` strict:true ` stricter inference for data properties on ` this ` . If you do not use it, ` this ` will always be treated as ` any `
10
+ ``` json
11
+ // tsconfig.json
12
+ {
13
+ "compilerOptions" : {
14
+ "target" : " esnext" ,
15
+ "module" : " esnext" ,
16
+ "strict" : true ,
17
+ "moduleResolution" : " node"
18
+ }
19
+ }
20
+ ```
21
+
22
+ ## Usage in .vue files
23
+ add ` lang="ts" ` to the script tag to declare TS as the lang used.
24
+ ``` html
25
+ <script lang =" ts" >
26
+ ...
27
+ </script >
28
+ ```
29
+
30
+ use ` defineComponent ` to get type inference in Vue component options
31
+ ``` js
32
+ import { defineComponent } from ' vue'
33
+
34
+ const Component = defineComponent ({
35
+ // type inference enabled
36
+ })
37
+ ```
You can’t perform that action at this time.
0 commit comments