mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(check): tsconfig "references", "extends", "files", "include" and "exclude" (#29843)
- Each workspace directory is probed for a `tsconfig.json`. - These and any that are included by their `references` are put into a list ordered by priority. - A tsconfig has lower priority than its `references`. - An earlier listed entry in `references` has higher priority than a later one. - A probed tsconfig in an inner directory has higher priority than an outer one. Their `references` would be interspersed between them. - Each tsconfig has a filter based on its `files`, `include` and `exclude` fields. If it doesn't have `files` or `include`, it will match any path in its containing directory not exempted by `exclude`. - For type-checking, each root path will be allocated compiler options based on the first tsconfig it whose filter it matches from this list. - Only if it doesn't match any tsconfig, it will fall back to using the nearest `deno.json`. If it's a workspace member and the root `deno.json` has `compilerOptions`, these will be merged using the same logic from `extends`. Inheritance between configs strictly occurs via `extends` in a `tsconfig.json`, and between workspace member and root `deno.json`s' `compilerOptions`. There is no implicit inheritance between `tsconfig.json` and `deno.json`. The default compiler options currently applied against tsconfigs are Deno's normal defaults, with the exception of `lib`. The default value for `lib` is `["deno.window", "deno.unstable", "dom"]` for files in the scope of a tsconfig with `lib` unspecified. This behaviour is depended on by, for example, the template project created by `create-vite -> svelte`. I expect we'll add more such exceptions over time with other fields.
This commit is contained in:
parent
9913311860
commit
7a9ab843bd
95 changed files with 1512 additions and 514 deletions
5
tests/specs/check/tsconfig_extends_array/__test__.jsonc
Normal file
5
tests/specs/check/tsconfig_extends_array/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "check --quiet",
|
||||
"output": "main.out",
|
||||
"exitCode": 1
|
||||
}
|
1
tests/specs/check/tsconfig_extends_array/deno.json
Normal file
1
tests/specs/check/tsconfig_extends_array/deno.json
Normal file
|
@ -0,0 +1 @@
|
|||
{}
|
2
tests/specs/check/tsconfig_extends_array/main.deno.ts
Normal file
2
tests/specs/check/tsconfig_extends_array/main.deno.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
Deno.readTextFileSync("hello.txt");
|
||||
document.body.innerHTML = "<div>Hello</div>";
|
2
tests/specs/check/tsconfig_extends_array/main.dom.ts
Normal file
2
tests/specs/check/tsconfig_extends_array/main.dom.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
Deno.readTextFileSync("hello.txt");
|
||||
document.body.innerHTML = "<div>Hello</div>";
|
11
tests/specs/check/tsconfig_extends_array/main.out
Normal file
11
tests/specs/check/tsconfig_extends_array/main.out
Normal file
|
@ -0,0 +1,11 @@
|
|||
TS2584 [ERROR]: Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
|
||||
document.body.innerHTML = "<div>Hello</div>";
|
||||
~~~~~~~~
|
||||
at file:///[WILDLINE]main.deno.ts:2:1
|
||||
|
||||
TS2304 [ERROR]: Cannot find name 'Deno'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'deno.ns' or add a triple-slash directive to the top of your entrypoint (main file): /// <reference lib="deno.ns" />
|
||||
Deno.readTextFileSync("hello.txt");
|
||||
~~~~
|
||||
at file:///[WILDLINE]main.dom.ts:1:1
|
||||
|
||||
error: Type checking failed.
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"files": ["main.dom.ts"],
|
||||
"compilerOptions": {
|
||||
"lib": []
|
||||
}
|
||||
}
|
3
tests/specs/check/tsconfig_extends_array/tsconfig.json
Normal file
3
tests/specs/check/tsconfig_extends_array/tsconfig.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": ["./tsconfig.dom_files.json", "./tsconfig.dom.json"]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue