Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recommended configuration for Node.js running TS natively #293

Merged
merged 9 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/recommended/tsconfig.json"
```

### Bun <kbd><a href="./bases/bun.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -69,6 +70,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/bun/tsconfig.json"
```

### Create React App <kbd><a href="./bases/create-react-app.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -83,6 +85,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/create-react-app/tsconfig.json"
```

### Cypress <kbd><a href="./bases/cypress.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -97,6 +100,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/cypress/tsconfig.json"
```

### Deno <kbd><a href="./bases/deno.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -111,6 +115,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/deno/tsconfig.json"
```

### Docusaurus v2 <kbd><a href="./bases/docusaurus.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -126,7 +131,10 @@ Add to your `tsconfig.json`:
"extends": "@tsconfig/docusaurus/tsconfig.json"
```



> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.

### Ember <kbd><a href="./bases/ember.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -142,7 +150,10 @@ Add to your `tsconfig.json`:
"extends": "@tsconfig/ember/tsconfig.json"
```



> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.

### Next.js <kbd><a href="./bases/next.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -157,6 +168,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/next/tsconfig.json"
```

### Node LTS (22) <kbd><a href="./bases/node-lts.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -171,6 +183,27 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node-lts/tsconfig.json"
```

### Node with TypeScript (TS >=5.8 ONLY) <kbd><a href="./bases/node-ts.json">tsconfig.json</a></kbd>

Install:

```sh
npm install --save-dev @tsconfig/node-ts
yarn add --dev @tsconfig/node-ts
```


> This base require TypeScript 5.8+ (See [announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option))

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`:

```json
{
"extends": ["@tsconfig/node22/tsconfig.json", "@tsconfig/node-ts/tsconfig.json"]
}
```

### Node 10 <kbd><a href="./bases/node10.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -185,6 +218,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node10/tsconfig.json"
```

### Node 12 <kbd><a href="./bases/node12.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -199,6 +233,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node12/tsconfig.json"
```

### Node 14 <kbd><a href="./bases/node14.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -213,6 +248,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node14/tsconfig.json"
```

### Node 16 <kbd><a href="./bases/node16.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -227,6 +263,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node16/tsconfig.json"
```

### Node 17 <kbd><a href="./bases/node17.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -241,6 +278,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node17/tsconfig.json"
```

### Node 18 <kbd><a href="./bases/node18.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -255,6 +293,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node18/tsconfig.json"
```

### Node 19 <kbd><a href="./bases/node19.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -269,6 +308,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node19/tsconfig.json"
```

### Node 20 <kbd><a href="./bases/node20.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -283,6 +323,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node20/tsconfig.json"
```

### Node 21 <kbd><a href="./bases/node21.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -297,6 +338,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node21/tsconfig.json"
```

### Node 22 <kbd><a href="./bases/node22.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -311,6 +353,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node22/tsconfig.json"
```

### Node 23 <kbd><a href="./bases/node23.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -325,6 +368,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/node23/tsconfig.json"
```

### Nuxt <kbd><a href="./bases/nuxt.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -340,7 +384,10 @@ Add to your `tsconfig.json`:
"extends": "@tsconfig/nuxt/tsconfig.json"
```



> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.

### QJSEngine <kbd><a href="./bases/qjsengine.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -355,6 +402,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/qjsengine/tsconfig.json"
```

### React Native <kbd><a href="./bases/react-native.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -369,6 +417,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/react-native/tsconfig.json"
```

### Remix <kbd><a href="./bases/remix.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -384,7 +433,10 @@ Add to your `tsconfig.json`:
"extends": "@tsconfig/remix/tsconfig.json"
```



> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution.

### Strictest <kbd><a href="./bases/strictest.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -399,6 +451,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/strictest/tsconfig.json"
```

### Svelte <kbd><a href="./bases/svelte.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -414,7 +467,10 @@ Add to your `tsconfig.json`:
"extends": "@tsconfig/svelte/tsconfig.json"
```



> **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.

### Taro <kbd><a href="./bases/taro.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -429,6 +485,7 @@ Add to your `tsconfig.json`:
```json
"extends": "@tsconfig/taro/tsconfig.json"
```

### Vite React <kbd><a href="./bases/vite-react.json">tsconfig.json</a></kbd>

Install:
Expand All @@ -444,6 +501,7 @@ Add to your `tsconfig.json`:
"extends": "@tsconfig/vite-react/tsconfig.json"
```


<!-- /AUTO -->

### What about combined configs?
Expand Down
10 changes: 10 additions & 0 deletions bases/node-ts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node with TypeScript (TS >=5.8 ONLY)",
"docs": "https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option",
"_version": "23.6.0",
"compilerOptions": {
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true
}
}
9 changes: 9 additions & 0 deletions readme-extras/node-ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
> This base require TypeScript 5.8+ (See [announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option))

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`:

```json
{
"extends": ["@tsconfig/node22/tsconfig.json", "@tsconfig/node-ts/tsconfig.json"]
}
```
22 changes: 16 additions & 6 deletions scripts/update-markdown-readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,29 @@ npm install --save-dev @tsconfig/${name}
yarn add --dev @tsconfig/${name}
\`\`\`

Add to your \`tsconfig.json\`:
`

const hasReadmeExtra = await Deno.stat(`./readme-extras/${name}.md`).then(() => true).catch(() => false)
const readmeExtra = hasReadmeExtra ? (await Deno.readTextFile(`./readme-extras/${name}.md`)).trim() : ""

const defaultInstructions = `Add to your \`tsconfig.json\`:

\`\`\`json
"extends": "@tsconfig/${name}/tsconfig.json"
\`\`\`

`

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

if (readmeExtra)
center += `\n${readmeExtra}\n`
} catch (error) {}
center += `\n${readmeExtra}\n\n`

} else {
center += defaultInstructions
}
};

const startMarker ="<!-- AUTO -->"
Expand Down