-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtsconfig.json
98 lines (78 loc) · 5.39 KB
/
tsconfig.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"compilerOptions": {
// Foundry is on the bleeding edge of JavaScript so always having the newest version available is nice.
// If you want to target an older version of JavaScript anyways, first consider setting Vite to transpile to that version.
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"outDir": ".typescript-build",
"allowImportingTsExtensions": true,
// Vite does interop with ESM and CommonJS modules so this option matches the runtime.
"esModuleInterop": true,
// `@pixi/utils/lib/index.d.mts` still depends on `allowSyntheticDefaultImports`.
"allowSyntheticDefaultImports": true,
// The files this tsconfig.json includes won't even have `fvtt-types`.
// See `src/tsconfig.json` for how it sets up its type.
// You can add types here if necessary. It'll only be scoped to the root files though.
"types": [],
// Strict is _highly_ recommended. It's a whole suite of options in tsc that help you catch bugs early.
// If you want to disable it for some reason, you must add "strictNullChecks": true or else foundry-vtt-types may not function correctly.
"strict": true,
// See: https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax
"verbatimModuleSyntax": true,
// This setting keeps developers with different file name case sensitivity from running into issues.
// See: https://www.typescriptlang.org/tsconfig/#forceConsistentCasingInFileNames
"forceConsistentCasingInFileNames": true,
// Vite supports importing JSON files as modules.
"resolveJsonModule": true,
// This option is makes it so that the type of `x[0]` is `T | undefined` instead of `T`.
// If you find this annoying, disable this option
"noUncheckedIndexedAccess": true,
// An import like `import "foo";` won't be type checked by default.
// This can be convenient with some bundlers but it's not necessary with Vite and it's generally safer to have this option on.
"noUncheckedSideEffectImports": true,
// It's possible for errors to be thrown like `throw 1` which obviously isn't a subclass of `Error`.
// For the greatest safety you can check if it's an instance of `Error` with `instanceof Error` but if you'd prefer not to, you can disable this rule.
"useUnknownInCatchVariables": true,
// Types like `Record<string, T>` are very unsafe.
// 1. They allow typos like `x.naem` when you really meant `x.name`.
// 2. They don't force you to handle `undefined` (notably this is fixed by `noUncheckedIndexedAccess`).
// 3. Mutation on them inherently is unsafe. For example, this is allowed but will cause a runtime error:
// ```
// let withNumber: { x: number } = { x: 1 };
// let withIndexSignature: Record<string, unknown> = withNumber;
// withIndexSignature.x = ["foo"];
//
// console.log(withNumber.x * 5); // This will throw a runtime error.
// ```
"noPropertyAccessFromIndexSignature": true,
"noImplicitOverride": true,
"allowJs": true,
// You might think that this option is useful to have on either for performance or to ignore errors.
// However due to how many types in fvtt-types are global this doesn't usually significantly help performance.
// Fortunately for performance, this template already builds practically instantly using Vite and incremental typechecking runs in the background.
//
// Still it wouldn't be harmful if it weren't for the two issues with `skipLibCheck`. Firstly the way its semantics works is that it skips _all_ `.d.ts` files.
// This means that even `.d.ts` files in your own repo aren't type checked which can be an issue for some repositories. Secondly `skipLibCheck` silences some of
// the most interesting errors; those which occur within fvtt-types files. When this happens it's a strong indication that the durability of fvtt-types isn't high
// enough to your configuration in this area and it's best to be reported.
"skipLibCheck": false
// Consider enabling this if you have JS files and want TypeScript to lint them.
// Most starting projects will probably want to simply write in TypeScript and most existing projects will probably not have JS files that pass typechecking so this is disabled.
// If you have individual files you want to be type checked add a comment at the start of the file `// @ts-check`.
// "checkJs": true,
// This option not enabled by default because it can be very annoying.
// Consider enabling this option if you want to catch bugs arising from stuff like `{ optionalProperty: undefined }`.
// This can occur in Foundry from cases like in a configuration object where it'll override the default value.
// However opting-in to allowing `{ optionalProperty: undefined }` means you must write `{ optionalProperty?: T | undefined }` instead of `{ optionalProperty?: T }` for the type.
// This can be annoying because for developers.
// "exactOptionalPropertyTypes": true,
// Consider enabling this option if you switch another bundler that doesn't know how to bundle TypeScript multiple files at a time.
// "isolatedModules": true,
},
// Exclude the src directory from the root project to avoid double type checking and causing an error due to mismatched `compilerOptions.types`.
"exclude": ["src/**"],
"references": [{ "path": "./src/module" }]
}