diff --git a/README.md b/README.md index aa8aead..2f4d748 100644 --- a/README.md +++ b/README.md @@ -202,10 +202,20 @@ module.exports = { ## TypeScript +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: + +| Node.js Version | TypeScript Config | +| --------------- | --------------------------------------- | +| v16 | `@vercel/style-guide/typescript/node16` | +| v18 | `@vercel/style-guide/typescript/node18` | +| v20 | `@vercel/style-guide/typescript/node20` | + To use the shared TypeScript config, set the following in `tsconfig.json`. ```json { - "extends": "@vercel/style-guide/typescript" + "extends": "@vercel/style-guide/typescript/node16" } ``` + +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. diff --git a/package.json b/package.json index 190d342..61f37c7 100644 --- a/package.json +++ b/package.json @@ -11,11 +11,19 @@ "url": "https://github.com/vercel/style-guide.git" }, "license": "MPL-2.0", + "exports": { + "./eslint/*": "./eslint/*.js", + "./prettier": "./prettier/index.js", + "./typescript": "./typescript/tsconfig.base.json", + "./typescript/node16": "./typescript/tsconfig.node16.json", + "./typescript/node18": "./typescript/tsconfig.node18.json", + "./typescript/node20": "./typescript/tsconfig.node20.json" + }, "main": "index.js", "files": [ "eslint", "prettier", - "typescript.json" + "typescript" ], "scripts": { "eslint-check": "eslint --max-warnings=0 .", diff --git a/typescript.json b/typescript/tsconfig.base.json similarity index 78% rename from typescript.json rename to typescript/tsconfig.base.json index b03044b..010d876 100644 --- a/typescript.json +++ b/typescript/tsconfig.base.json @@ -1,5 +1,7 @@ { "$schema": "https://json.schemastore.org/tsconfig", + "display": "Vercel Base", + "docs": "https://github.com/vercel/style-guide", "compilerOptions": { "esModuleInterop": true, "forceConsistentCasingInFileNames": true, diff --git a/typescript/tsconfig.node16.json b/typescript/tsconfig.node16.json new file mode 100644 index 0000000..2f9b223 --- /dev/null +++ b/typescript/tsconfig.node16.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./tsconfig.base.json", + "display": "Vercel Node 16", + "docs": "https://github.com/vercel/style-guide", + "compilerOptions": { + "lib": ["es2021"], + "module": "node16", + "target": "es2021", + "moduleResolution": "node16" + } +} diff --git a/typescript/tsconfig.node18.json b/typescript/tsconfig.node18.json new file mode 100644 index 0000000..dccb40c --- /dev/null +++ b/typescript/tsconfig.node18.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./tsconfig.base.json", + "display": "Vercel Node 18", + "docs": "https://github.com/vercel/style-guide", + "compilerOptions": { + "lib": ["es2023"], + "module": "node16", + "target": "es2023", + "moduleResolution": "node16" + } +} diff --git a/typescript/tsconfig.node20.json b/typescript/tsconfig.node20.json new file mode 100644 index 0000000..034a243 --- /dev/null +++ b/typescript/tsconfig.node20.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./tsconfig.base.json", + "display": "Vercel Node 20", + "docs": "https://github.com/vercel/style-guide", + "compilerOptions": { + "lib": ["es2023"], + "module": "node16", + "target": "es2023", + "moduleResolution": "node16" + } +}