1 | ### A base TSConfig for working with Svelte.
|
2 |
|
3 | Add the package to your `"devDependencies"`:
|
4 |
|
5 | ```sh
|
6 | npm install --save-dev @tsconfig/svelte
|
7 | yarn add --dev @tsconfig/svelte
|
8 | ```
|
9 |
|
10 | Add to your `tsconfig.json`:
|
11 |
|
12 | ```json
|
13 | "extends": "@tsconfig/svelte/tsconfig.json"
|
14 | ```
|
15 |
|
16 | ---
|
17 |
|
18 | The `tsconfig.json`:
|
19 |
|
20 | ```jsonc
|
21 | {
|
22 | "$schema": "https://json.schemastore.org/tsconfig",
|
23 | "display": "Svelte",
|
24 | "_version": "3.0.0",
|
25 |
|
26 | "compilerOptions": {
|
27 | "moduleResolution": "node",
|
28 | "target": "es2017",
|
29 | /**
|
30 | Svelte Preprocess cannot figure out whether you have a value or a type, so tell TypeScript
|
31 | to enforce using `import type` instead of `import` for Types.
|
32 | */
|
33 | "importsNotUsedAsValues": "error",
|
34 | /**
|
35 | TypeScript doesn't know about import usages in the template because it only sees the
|
36 | script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
|
37 | */
|
38 | "preserveValueImports": true,
|
39 | "isolatedModules": true,
|
40 | /**
|
41 | To have warnings/errors of the Svelte compiler at the correct position,
|
42 | enable source maps by default.
|
43 | */
|
44 | "sourceMap": true,
|
45 |
|
46 | "strict": false,
|
47 | "esModuleInterop": true,
|
48 | "skipLibCheck": true,
|
49 | "forceConsistentCasingInFileNames": true
|
50 | }
|
51 | }
|
52 |
|
53 | ```
|
54 |
|
55 | You can find the [code here](https://github.com/tsconfig/bases/blob/master/bases/svelte.json).
|