You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package added the support for Twoslash to handle Svelte files.
4
+
5
+
For example:
6
+
7
+
```svelte twoslash
8
+
<script>
9
+
import { onMount } from 'svelte'
10
+
// ^?
11
+
12
+
// Reactive state.
13
+
let count = $state(0)
14
+
15
+
// Functions that mutate state and trigger updates.
16
+
function increment() {
17
+
count++
18
+
}
19
+
20
+
// Lifecycle hooks.
21
+
onMount(() => {
22
+
console.log(`The initial count is ${count}.`)
23
+
})
24
+
</script>
25
+
26
+
<button onclick={increment}>
27
+
Count is: {count}
28
+
</button>
29
+
```
30
+
31
+
## Installation
32
+
33
+
::: code-group
34
+
35
+
```bash [npm]
36
+
npm i -D twoslash-svelte svelte2tsx
37
+
```
38
+
```bash [pnpm]
39
+
pnpm i -D twoslash-svelte svelte2tsx
40
+
```
41
+
```bash [yarn]
42
+
yarn add -D twoslash-svelte svelte2tsx
43
+
```
44
+
```bash [bun]
45
+
bun add -D twoslash-svelte svelte2tsx
46
+
```
47
+
48
+
:::
49
+
50
+
::: info Required Types
51
+
52
+
`twoslash-svelte` requires `svelte2tsx` to be installed so that required declaration files are present during compilation of the Svelte code. Without `svelte2tsx` installed you might see errors like: `Cannot find name 'svelteHTML'.`
0 commit comments