Skip to content

Commit f77cbff

Browse files
authored
docs: add tsconfig.json support details to TypeScript page (#3026)
1 parent ed6a2fe commit f77cbff

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

runtime/fundamentals/typescript.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,46 @@ To specify the library files to use in a TypeScript file, you can use
264264
/// <reference lib="dom" />
265265
```
266266

267+
## Configuring TypeScript with `tsconfig.json` {#tsconfig}
268+
269+
While Deno uses `deno.json` for TypeScript configuration by default, it also
270+
supports `tsconfig.json` for compatibility with existing Node.js and TypeScript
271+
projects, making it easier to adopt Deno incrementally. Each workspace directory
272+
containing a `deno.json` or `package.json` is probed for a `tsconfig.json` — if
273+
one exists, Deno will automatically use it for type checking and the language
274+
server, no extra flags needed. Since Deno 2.1, `jsconfig.json` is also
275+
auto-detected when a `package.json` is present, which is useful for
276+
JavaScript-only projects.
277+
278+
For example, an existing Node.js project with this `tsconfig.json`:
279+
280+
```json title="tsconfig.json"
281+
{
282+
"compilerOptions": {
283+
"strict": true,
284+
"jsx": "react-jsx",
285+
"lib": ["dom", "esnext"],
286+
"paths": {
287+
"@/*": ["./src/*"]
288+
}
289+
},
290+
"include": ["src/**/*"]
291+
}
292+
```
293+
294+
will be picked up automatically when running `deno check` or using the Deno
295+
language server. If a `deno.json` with its own `compilerOptions` is added later,
296+
those take precedence.
297+
298+
:::tip
299+
300+
For Deno-first projects, prefer `compilerOptions` in `deno.json` over a separate
301+
`tsconfig.json`. See
302+
[Configuring TypeScript](/runtime/reference/ts_config_migration/) for the full
303+
list of supported fields, precedence rules, and compiler option defaults.
304+
305+
:::
306+
267307
## Augmenting global types
268308

269309
Deno supports ambient or global types in TypeScript. This is useful when

0 commit comments

Comments
 (0)