Skip to content

Commit 7f89127

Browse files
authored
Merge pull request #293 from khaosdoctor/main
Add recommended configuration for Node.js running TS natively
2 parents 81a4280 + ac64db9 commit 7f89127

File tree

4 files changed

+93
-6
lines changed

4 files changed

+93
-6
lines changed

README.md

+58
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Add to your `tsconfig.json`:
5555
```json
5656
"extends": "@tsconfig/recommended/tsconfig.json"
5757
```
58+
5859
### Bun <kbd><a href="./bases/bun.json">tsconfig.json</a></kbd>
5960

6061
Install:
@@ -69,6 +70,7 @@ Add to your `tsconfig.json`:
6970
```json
7071
"extends": "@tsconfig/bun/tsconfig.json"
7172
```
73+
7274
### Create React App <kbd><a href="./bases/create-react-app.json">tsconfig.json</a></kbd>
7375

7476
Install:
@@ -83,6 +85,7 @@ Add to your `tsconfig.json`:
8385
```json
8486
"extends": "@tsconfig/create-react-app/tsconfig.json"
8587
```
88+
8689
### Cypress <kbd><a href="./bases/cypress.json">tsconfig.json</a></kbd>
8790

8891
Install:
@@ -97,6 +100,7 @@ Add to your `tsconfig.json`:
97100
```json
98101
"extends": "@tsconfig/cypress/tsconfig.json"
99102
```
103+
100104
### Deno <kbd><a href="./bases/deno.json">tsconfig.json</a></kbd>
101105

102106
Install:
@@ -111,6 +115,7 @@ Add to your `tsconfig.json`:
111115
```json
112116
"extends": "@tsconfig/deno/tsconfig.json"
113117
```
118+
114119
### Docusaurus v2 <kbd><a href="./bases/docusaurus.json">tsconfig.json</a></kbd>
115120

116121
Install:
@@ -126,7 +131,10 @@ Add to your `tsconfig.json`:
126131
"extends": "@tsconfig/docusaurus/tsconfig.json"
127132
```
128133

134+
135+
129136
> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.
137+
130138
### Ember <kbd><a href="./bases/ember.json">tsconfig.json</a></kbd>
131139

132140
Install:
@@ -142,7 +150,10 @@ Add to your `tsconfig.json`:
142150
"extends": "@tsconfig/ember/tsconfig.json"
143151
```
144152

153+
154+
145155
> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.
156+
146157
### Next.js <kbd><a href="./bases/next.json">tsconfig.json</a></kbd>
147158

148159
Install:
@@ -157,6 +168,7 @@ Add to your `tsconfig.json`:
157168
```json
158169
"extends": "@tsconfig/next/tsconfig.json"
159170
```
171+
160172
### Node LTS (22) <kbd><a href="./bases/node-lts.json">tsconfig.json</a></kbd>
161173

162174
Install:
@@ -171,6 +183,27 @@ Add to your `tsconfig.json`:
171183
```json
172184
"extends": "@tsconfig/node-lts/tsconfig.json"
173185
```
186+
187+
### Node with TypeScript (TS >=5.8 ONLY) <kbd><a href="./bases/node-ts.json">tsconfig.json</a></kbd>
188+
189+
Install:
190+
191+
```sh
192+
npm install --save-dev @tsconfig/node-ts
193+
yarn add --dev @tsconfig/node-ts
194+
```
195+
196+
197+
> This base require TypeScript 5.8+ (See [announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option))
198+
199+
This file is meant to be used in conjunction with other Node.js configurations, you can do so by extending multiple files in the `extends` clause of your `tsconfig.json`:
200+
201+
```json
202+
{
203+
"extends": ["@tsconfig/node22/tsconfig.json", "@tsconfig/node-ts/tsconfig.json"]
204+
}
205+
```
206+
174207
### Node 10 <kbd><a href="./bases/node10.json">tsconfig.json</a></kbd>
175208

176209
Install:
@@ -185,6 +218,7 @@ Add to your `tsconfig.json`:
185218
```json
186219
"extends": "@tsconfig/node10/tsconfig.json"
187220
```
221+
188222
### Node 12 <kbd><a href="./bases/node12.json">tsconfig.json</a></kbd>
189223

190224
Install:
@@ -199,6 +233,7 @@ Add to your `tsconfig.json`:
199233
```json
200234
"extends": "@tsconfig/node12/tsconfig.json"
201235
```
236+
202237
### Node 14 <kbd><a href="./bases/node14.json">tsconfig.json</a></kbd>
203238

204239
Install:
@@ -213,6 +248,7 @@ Add to your `tsconfig.json`:
213248
```json
214249
"extends": "@tsconfig/node14/tsconfig.json"
215250
```
251+
216252
### Node 16 <kbd><a href="./bases/node16.json">tsconfig.json</a></kbd>
217253

218254
Install:
@@ -227,6 +263,7 @@ Add to your `tsconfig.json`:
227263
```json
228264
"extends": "@tsconfig/node16/tsconfig.json"
229265
```
266+
230267
### Node 17 <kbd><a href="./bases/node17.json">tsconfig.json</a></kbd>
231268

232269
Install:
@@ -241,6 +278,7 @@ Add to your `tsconfig.json`:
241278
```json
242279
"extends": "@tsconfig/node17/tsconfig.json"
243280
```
281+
244282
### Node 18 <kbd><a href="./bases/node18.json">tsconfig.json</a></kbd>
245283

246284
Install:
@@ -255,6 +293,7 @@ Add to your `tsconfig.json`:
255293
```json
256294
"extends": "@tsconfig/node18/tsconfig.json"
257295
```
296+
258297
### Node 19 <kbd><a href="./bases/node19.json">tsconfig.json</a></kbd>
259298

260299
Install:
@@ -269,6 +308,7 @@ Add to your `tsconfig.json`:
269308
```json
270309
"extends": "@tsconfig/node19/tsconfig.json"
271310
```
311+
272312
### Node 20 <kbd><a href="./bases/node20.json">tsconfig.json</a></kbd>
273313

274314
Install:
@@ -283,6 +323,7 @@ Add to your `tsconfig.json`:
283323
```json
284324
"extends": "@tsconfig/node20/tsconfig.json"
285325
```
326+
286327
### Node 21 <kbd><a href="./bases/node21.json">tsconfig.json</a></kbd>
287328

288329
Install:
@@ -297,6 +338,7 @@ Add to your `tsconfig.json`:
297338
```json
298339
"extends": "@tsconfig/node21/tsconfig.json"
299340
```
341+
300342
### Node 22 <kbd><a href="./bases/node22.json">tsconfig.json</a></kbd>
301343

302344
Install:
@@ -311,6 +353,7 @@ Add to your `tsconfig.json`:
311353
```json
312354
"extends": "@tsconfig/node22/tsconfig.json"
313355
```
356+
314357
### Node 23 <kbd><a href="./bases/node23.json">tsconfig.json</a></kbd>
315358

316359
Install:
@@ -325,6 +368,7 @@ Add to your `tsconfig.json`:
325368
```json
326369
"extends": "@tsconfig/node23/tsconfig.json"
327370
```
371+
328372
### Nuxt <kbd><a href="./bases/nuxt.json">tsconfig.json</a></kbd>
329373

330374
Install:
@@ -340,7 +384,10 @@ Add to your `tsconfig.json`:
340384
"extends": "@tsconfig/nuxt/tsconfig.json"
341385
```
342386

387+
388+
343389
> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.
390+
344391
### QJSEngine <kbd><a href="./bases/qjsengine.json">tsconfig.json</a></kbd>
345392

346393
Install:
@@ -355,6 +402,7 @@ Add to your `tsconfig.json`:
355402
```json
356403
"extends": "@tsconfig/qjsengine/tsconfig.json"
357404
```
405+
358406
### React Native <kbd><a href="./bases/react-native.json">tsconfig.json</a></kbd>
359407

360408
Install:
@@ -369,6 +417,7 @@ Add to your `tsconfig.json`:
369417
```json
370418
"extends": "@tsconfig/react-native/tsconfig.json"
371419
```
420+
372421
### Remix <kbd><a href="./bases/remix.json">tsconfig.json</a></kbd>
373422

374423
Install:
@@ -384,7 +433,10 @@ Add to your `tsconfig.json`:
384433
"extends": "@tsconfig/remix/tsconfig.json"
385434
```
386435

436+
437+
387438
> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.
439+
388440
### Strictest <kbd><a href="./bases/strictest.json">tsconfig.json</a></kbd>
389441

390442
Install:
@@ -399,6 +451,7 @@ Add to your `tsconfig.json`:
399451
```json
400452
"extends": "@tsconfig/strictest/tsconfig.json"
401453
```
454+
402455
### Svelte <kbd><a href="./bases/svelte.json">tsconfig.json</a></kbd>
403456

404457
Install:
@@ -414,7 +467,10 @@ Add to your `tsconfig.json`:
414467
"extends": "@tsconfig/svelte/tsconfig.json"
415468
```
416469

470+
471+
417472
> **NOTE**: After `@tsconfig/svelte@2.0.0`, you should add `/// <reference types="svelte" />` to a `d.ts` or a `index.ts`(entry) file to prevent typescript error.
473+
418474
### Taro <kbd><a href="./bases/taro.json">tsconfig.json</a></kbd>
419475

420476
Install:
@@ -429,6 +485,7 @@ Add to your `tsconfig.json`:
429485
```json
430486
"extends": "@tsconfig/taro/tsconfig.json"
431487
```
488+
432489
### Vite React <kbd><a href="./bases/vite-react.json">tsconfig.json</a></kbd>
433490

434491
Install:
@@ -444,6 +501,7 @@ Add to your `tsconfig.json`:
444501
"extends": "@tsconfig/vite-react/tsconfig.json"
445502
```
446503

504+
447505
<!-- /AUTO -->
448506

449507
### What about combined configs?

bases/node-ts.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"display": "Node with TypeScript (TS >=5.8 ONLY)",
4+
"docs": "https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option",
5+
"_version": "23.6.0",
6+
"compilerOptions": {
7+
"erasableSyntaxOnly": true,
8+
"verbatimModuleSyntax": true
9+
}
10+
}

readme-extras/node-ts.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
> This base require TypeScript 5.8+ (See [announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option))
2+
3+
This file is meant to be used in conjunction with other Node.js configurations, you can do so by extending multiple files in the `extends` clause of your `tsconfig.json`:
4+
5+
```json
6+
{
7+
"extends": ["@tsconfig/node22/tsconfig.json", "@tsconfig/node-ts/tsconfig.json"]
8+
}
9+
```

scripts/update-markdown-readme.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,29 @@ npm install --save-dev @tsconfig/${name}
3232
yarn add --dev @tsconfig/${name}
3333
\`\`\`
3434
35-
Add to your \`tsconfig.json\`:
35+
`
36+
37+
const hasReadmeExtra = await Deno.stat(`./readme-extras/${name}.md`).then(() => true).catch(() => false)
38+
const readmeExtra = hasReadmeExtra ? (await Deno.readTextFile(`./readme-extras/${name}.md`)).trim() : ""
39+
40+
const defaultInstructions = `Add to your \`tsconfig.json\`:
3641
3742
\`\`\`json
3843
"extends": "@tsconfig/${name}/tsconfig.json"
3944
\`\`\`
45+
4046
`
4147

42-
try {
43-
const readmeExtra = (await Deno.readTextFile(`./readme-extras/${name}.md`)).trim()
48+
if (readmeExtra) {
49+
if (!readmeExtra.includes("extends")) {
50+
center += defaultInstructions + "\n"
51+
}
4452

45-
if (readmeExtra)
46-
center += `\n${readmeExtra}\n`
47-
} catch (error) {}
53+
center += `\n${readmeExtra}\n\n`
54+
55+
} else {
56+
center += defaultInstructions
57+
}
4858
};
4959

5060
const startMarker ="<!-- AUTO -->"

0 commit comments

Comments
 (0)