返回 slidev
code-twoslash.md
根目录 / skills / slidev / references / code-twoslash.md
1 ---
2 name: twoslash
3 description: Show TypeScript type information inline or on hover in code blocks
4 ---
5
6 # TwoSlash Integration
7
8 Show TypeScript type information inline or on hover.
9
10 ## Usage
11
12 ````md
13 ```ts twoslash
14 import { ref } from 'vue'
15
16 const count = ref(0)
17 // ^?
18 ```
19 ````
20
21 ## Features
22
23 - Type information on hover
24 - Inline type annotations with `^?`
25 - Errors and warnings display
26 - Full TypeScript compiler integration
27
28 ## Annotations
29
30 ```ts twoslash
31 const count = ref(0)
32 // ^?
33 // Shows: const count: Ref<number>
34 ```
35
36 ## Use Case
37
38 Perfect for TypeScript/JavaScript teaching materials where showing types helps understanding.
39
40 ## Resources
41
42 - TwoSlash docs: https://twoslash.netlify.app/
43
43 lines MARKDOWN