Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit 3991e02

Browse files
Ethan-Arrowoodmrmckeb
andauthoredNov 22, 2023
feat(typescript): add multiple tsconfigs (#60)
Co-authored-by: Brody McKee <mrmckeb@users.noreply.github.com>
1 parent 75286d0 commit 3991e02

6 files changed

+58
-2
lines changed
 

‎README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,20 @@ module.exports = {
202202

203203
## TypeScript
204204

205+
This style guide provides multiple TypeScript configs. These configs correlate to the LTS Node.js versions, providing the appropriate `lib`, `module`, `target`, and `moduleResolution` settings for each version. The following configs are available:
206+
207+
| Node.js Version | TypeScript Config |
208+
| --------------- | --------------------------------------- |
209+
| v16 | `@vercel/style-guide/typescript/node16` |
210+
| v18 | `@vercel/style-guide/typescript/node18` |
211+
| v20 | `@vercel/style-guide/typescript/node20` |
212+
205213
To use the shared TypeScript config, set the following in `tsconfig.json`.
206214

207215
```json
208216
{
209-
"extends": "@vercel/style-guide/typescript"
217+
"extends": "@vercel/style-guide/typescript/node16"
210218
}
211219
```
220+
221+
The base TypeScript config is also available as [`@vercel/style-guide/typescript`](./typescript/tsconfig.base.json) which only specifies a set of general rules. You should inherit from this file when setting custom `lib`, `module`, `target`, and `moduleResolution` settings.

‎package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@
1111
"url": "https://github.com/vercel/style-guide.git"
1212
},
1313
"license": "MPL-2.0",
14+
"exports": {
15+
"./eslint/*": "./eslint/*.js",
16+
"./prettier": "./prettier/index.js",
17+
"./typescript": "./typescript/tsconfig.base.json",
18+
"./typescript/node16": "./typescript/tsconfig.node16.json",
19+
"./typescript/node18": "./typescript/tsconfig.node18.json",
20+
"./typescript/node20": "./typescript/tsconfig.node20.json"
21+
},
1422
"main": "index.js",
1523
"files": [
1624
"eslint",
1725
"prettier",
18-
"typescript.json"
26+
"typescript"
1927
],
2028
"scripts": {
2129
"eslint-check": "eslint --max-warnings=0 .",

‎typescript.json ‎typescript/tsconfig.base.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
3+
"display": "Vercel Base",
4+
"docs": "https://github.com/vercel/style-guide",
35
"compilerOptions": {
46
"esModuleInterop": true,
57
"forceConsistentCasingInFileNames": true,

‎typescript/tsconfig.node16.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "./tsconfig.base.json",
4+
"display": "Vercel Node 16",
5+
"docs": "https://github.com/vercel/style-guide",
6+
"compilerOptions": {
7+
"lib": ["es2021"],
8+
"module": "node16",
9+
"target": "es2021",
10+
"moduleResolution": "node16"
11+
}
12+
}

‎typescript/tsconfig.node18.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "./tsconfig.base.json",
4+
"display": "Vercel Node 18",
5+
"docs": "https://github.com/vercel/style-guide",
6+
"compilerOptions": {
7+
"lib": ["es2023"],
8+
"module": "node16",
9+
"target": "es2023",
10+
"moduleResolution": "node16"
11+
}
12+
}

‎typescript/tsconfig.node20.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "./tsconfig.base.json",
4+
"display": "Vercel Node 20",
5+
"docs": "https://github.com/vercel/style-guide",
6+
"compilerOptions": {
7+
"lib": ["es2023"],
8+
"module": "node16",
9+
"target": "es2023",
10+
"moduleResolution": "node16"
11+
}
12+
}

0 commit comments

Comments
 (0)
This repository has been archived.