Skip to content

Commit fe88dfa

Browse files
latest configuration recommendations
1 parent d8079af commit fe88dfa

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

src/pages/docs/resources/typescript.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,34 @@ Greenwood provides built-in support for TypeScript, either through type-strippin
1414
1515
## Setup
1616

17-
The below steps will help you get up and running with TypeScript in your Greenwood project. The general recommendation is to use type-stripping during development for faster live reload, and then run TypeScript during CI (e.g. GitHub Actions) to check and enforce all types, e.g. `tsc --project tsconfig.json`.
17+
The below steps will help you get up and running with TypeScript in your Greenwood project, and are the [same settings](https://github.com/ProjectEvergreen/greenwood/blob/master/packages/init/src/template-base-ts/tsconfig.json) you'll get running [Greenwood's **init** package with TypeScript enabled](/docs/introduction/setup/#init). The general recommendation is to use type-stripping during development for faster live reload, and then run TypeScript during CI (e.g. GitHub Actions) to check and enforce all types, e.g. `tsc --project tsconfig.json`.
1818

1919
1. You will need to use Node **>= 22.6.0** and set the `--experimental-strip-types` flag
2020
1. Install TypeScript into your project, e.g. `npm i typescript --save-dev`
21-
1. Create a _tsconfig.json_ file at the root of your project with these minimum configuration settings. We also recommend adding the [`erasableSyntaxOnly` setting](https://www.typescriptlang.org/tsconfig/#erasableSyntaxOnly)
21+
1. Create a _tsconfig.json_ file at the root of your project with the below minimum configuration settings.
22+
1. We also recommend additional configurations like [`verbatimModuleSyntax`](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) and [`erasableSyntaxOnly` setting](https://www.typescriptlang.org/tsconfig/#erasableSyntaxOnly)
2223

2324
<!-- prettier-ignore-start -->
2425

2526
<app-ctc-block variant="snippet" heading="tsconfig.json">
2627

27-
```json
28+
```json5
2829
{
29-
"compilerOptions": {
30-
"target": "es2015",
31-
"module": "preserve",
32-
"moduleResolution": "bundler",
33-
"allowImportingTsExtensions": true,
34-
"verbatimModuleSyntax": false,
35-
"noEmit": true
36-
}
30+
compilerOptions: {
31+
// minimum required configuration
32+
target: "es2020",
33+
module: "preserve",
34+
moduleResolution: "bundler",
35+
allowImportingTsExtensions: true,
36+
noEmit: true,
37+
38+
// additional recommended configuration
39+
lib: ["ES2020", "DOM", "DOM.Iterable"],
40+
verbatimModuleSyntax: true,
41+
erasableSyntaxOnly: true,
42+
},
43+
44+
exclude: ["./public/", "./greenwood/", "node_modules"],
3745
}
3846
```
3947

0 commit comments

Comments
 (0)