Repository: tsconfig/bases Branch: main Commit: bc304579bf23 Files: 56 Total size: 55.5 KB Directory structure: gitextract_8515flm8/ ├── .gitattributes ├── .github/ │ └── workflows/ │ ├── CI.yml │ └── deploy.yml ├── .gitignore ├── .vscode/ │ ├── extensions.json │ └── settings.json ├── LICENSE.md ├── README.md ├── bases/ │ ├── bun.json │ ├── create-react-app.json │ ├── cypress.json │ ├── deno.json │ ├── docusaurus.json │ ├── ember.json │ ├── next.json │ ├── node-lts.json │ ├── node-ts.json │ ├── node10.json │ ├── node12.json │ ├── node14.json │ ├── node16.json │ ├── node17.json │ ├── node18.json │ ├── node19.json │ ├── node20.json │ ├── node21.json │ ├── node22.json │ ├── node23.json │ ├── node24.json │ ├── nuxt.json │ ├── qjsengine.json │ ├── react-native.json │ ├── recommended.json │ ├── remix.json │ ├── strictest.json │ ├── svelte.json │ ├── taro.json │ └── vite-react.json ├── readme-extras/ │ ├── docusaurus.md │ ├── ember.md │ ├── node-ts.md │ ├── nuxt.md │ ├── remix.md │ └── svelte.md ├── scripts/ │ ├── create-npm-packages.ts │ ├── deploy-changed-npm-packages.ts │ ├── generate-lts.ts │ ├── generate-recommend.ts │ └── update-markdown-readme.ts ├── template/ │ ├── LICENSE │ ├── README-combined.md │ ├── README.md │ └── package.json └── test/ ├── index.ts ├── package.json └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ # Treat all bases as bases/*.json linguist-language=JSON-with-Comments ================================================ FILE: .github/workflows/CI.yml ================================================ name: CI # For testing on: pull_request jobs: ci: runs-on: ubuntu-latest steps: - name: Checkout tree uses: actions/checkout@v3 - name: Set-up Deno uses: denoland/setup-deno@v1 with: deno-version: v1.x # Build all the packages - name: Create packages for TSConfig JSONs run: deno run --allow-read --allow-write --allow-net scripts/create-npm-packages.ts - name: Test working-directory: test/ run: | corepack enable pnpm install pnpm test - name: Update the README run: deno run --allow-read --allow-write --allow-net scripts/update-markdown-readme.ts - name: Fail if the README needs updating run: | if [[ -z $(git status -s) ]] then echo "" else echo "Please update the README via: deno run --allow-read --allow-write scripts/update-markdown-readme.ts" exit 1 fi ================================================ FILE: .github/workflows/deploy.yml ================================================ name: Daily builds of changes to the TSConfig bases dir # For testing # on: push # For production on: schedule: - cron: 0 4 * * * workflow_dispatch: permissions: id-token: write jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout tree uses: actions/checkout@v3 - name: Set-up Node.js uses: actions/setup-node@v3 with: node-version: lts/* registry-url: https://registry.npmjs.org - name: Set-up Deno uses: denoland/setup-deno@v1 with: deno-version: v1.x # Build all the packages - name: Create packages for TSConfig JSONs run: deno run --allow-read --allow-write --allow-net scripts/create-npm-packages.ts # Deploy anything which differs from the npm version of a tsconfig - name: "Deploy built packages to NPM" run: | deno run --allow-read --allow-run --allow-env --allow-net scripts/deploy-changed-npm-packages.ts env: NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} ================================================ FILE: .gitignore ================================================ *.log packages/ .idea/ node_modules ================================================ FILE: .vscode/extensions.json ================================================ { "recommendations": ["denoland.vscode-deno"] } ================================================ FILE: .vscode/settings.json ================================================ { "cSpell.words": ["Deno"], "deno.enable": true, "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }, "files.associations": { "**/bases/*.json": "jsonc" }, } ================================================ FILE: LICENSE.md ================================================ MIT License Copyright (c) Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE ================================================ FILE: README.md ================================================ ## Centralized Recommendations for TSConfig bases Hosts TSConfigs for you to extend in your apps, tuned to a particular runtime environment. Owned and improved by the community. Basically Definitely Typed for TSConfigs. We target the latest stable version of TypeScript, note that because we want to be consistent with the versioning the target runtime we can't always do semver releases. ### Table of TSConfigs | Name | Package | | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | [Recommended](#recommended-tsconfigjson) | [`@tsconfig/recommended`](https://npmjs.com/package/@tsconfig/recommended) | | [Bun](#bun-tsconfigjson) | [`@tsconfig/bun`](https://npmjs.com/package/@tsconfig/bun) | | [Create React App](#create-react-app-tsconfigjson) | [`@tsconfig/create-react-app`](https://npmjs.com/package/@tsconfig/create-react-app) | | [Cypress](#cypress-tsconfigjson) | [`@tsconfig/cypress`](https://npmjs.com/package/@tsconfig/cypress) | | [Deno](#deno-tsconfigjson) | [`@tsconfig/deno`](https://npmjs.com/package/@tsconfig/deno) | | [Docusaurus v2](#docusaurus-v2-tsconfigjson) | [`@tsconfig/docusaurus`](https://npmjs.com/package/@tsconfig/docusaurus) | | [Ember](#ember-tsconfigjson) | [`@tsconfig/ember`](https://npmjs.com/package/@tsconfig/ember) | | [Next.js](#nextjs-tsconfigjson) | [`@tsconfig/next`](https://npmjs.com/package/@tsconfig/next) | | [Node LTS](#node-lts-22-tsconfigjson) | [`@tsconfig/node-lts`](https://npmjs.com/package/@tsconfig/node-lts) | | [Node 10](#node-10-tsconfigjson) | [`@tsconfig/node10`](https://npmjs.com/package/@tsconfig/node10) | | [Node 12](#node-12-tsconfigjson) | [`@tsconfig/node12`](https://npmjs.com/package/@tsconfig/node12) | | [Node 14](#node-14-tsconfigjson) | [`@tsconfig/node14`](https://npmjs.com/package/@tsconfig/node14) | | [Node 16](#node-16-tsconfigjson) | [`@tsconfig/node16`](https://npmjs.com/package/@tsconfig/node16) | | [Node 17](#node-17-tsconfigjson) | [`@tsconfig/node17`](https://npmjs.com/package/@tsconfig/node17) | | [Node 18](#node-18-tsconfigjson) | [`@tsconfig/node18`](https://npmjs.com/package/@tsconfig/node18) | | [Node 19](#node-19-tsconfigjson) | [`@tsconfig/node19`](https://npmjs.com/package/@tsconfig/node19) | | [Node 20](#node-20-tsconfigjson) | [`@tsconfig/node20`](https://npmjs.com/package/@tsconfig/node20) | | [Node 21](#node-21-tsconfigjson) | [`@tsconfig/node21`](https://npmjs.com/package/@tsconfig/node21) | | [Node 22](#node-22-tsconfigjson) | [`@tsconfig/node22`](https://npmjs.com/package/@tsconfig/node22) | | [Node 23](#node-23-tsconfigjson) | [`@tsconfig/node23`](https://npmjs.com/package/@tsconfig/node23) | | [Node 24](#node-24-tsconfigjson) | [`@tsconfig/node24`](https://npmjs.com/package/@tsconfig/node24) | | [Node with TypeScript](#node-with-typescript-ts-58-only-tsconfigjson)| [`@tsconfig/node-ts`](https://npmjs.com/package/@tsconfig/node-ts) | | [Nuxt](#nuxt-tsconfigjson) | [`@tsconfig/nuxt`](https://npmjs.com/package/@tsconfig/nuxt) | | [QJSEngine](#qjsengine-tsconfigjson) | [`@tsconfig/qjsengine`](https://npmjs.com/package/@tsconfig/qtsengine) | | [React Native](#react-native-tsconfigjson) | [`@tsconfig/react-native`](https://npmjs.com/package/@tsconfig/react-native) | | [Remix](#remix-tsconfigjson) | [`@tsconfig/remix`](https://npmjs.com/package/@tsconfig/remix) | | [Strictest](#strictest-tsconfigjson) | [`@tsconfig/strictest`](https://npmjs.com/package/@tsconfig/strictest) | | [Svelte](#svelte-tsconfigjson) | [`@tsconfig/svelte`](https://npmjs.com/package/@tsconfig/svelte) | | [Taro](#taro-tsconfigjson) | [`@tsconfig/taro`](https://npmjs.com/package/@tsconfig/taro) | | [Vite React](#vite-react-tsconfigjson) | [`@tsconfig/vite-react`](https://npmjs.com/package/@tsconfig/vite-react) | | [Bases](#bases-tsconfigjson) | [`@tsconfig/bases`](https://npmjs.com/package/@tsconfig/bases) | ### Available TSConfigs ### Recommended tsconfig.json Install: ```sh npm install --save-dev @tsconfig/recommended yarn add --dev @tsconfig/recommended ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/recommended/tsconfig.json" ``` ### Bun tsconfig.json Install: ```sh npm install --save-dev @tsconfig/bun yarn add --dev @tsconfig/bun ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/bun/tsconfig.json" ``` ### Create React App tsconfig.json Install: ```sh npm install --save-dev @tsconfig/create-react-app yarn add --dev @tsconfig/create-react-app ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/create-react-app/tsconfig.json" ``` ### Cypress tsconfig.json Install: ```sh npm install --save-dev @tsconfig/cypress yarn add --dev @tsconfig/cypress ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/cypress/tsconfig.json" ``` ### Deno tsconfig.json Install: ```sh npm install --save-dev @tsconfig/deno yarn add --dev @tsconfig/deno ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/deno/tsconfig.json" ``` ### Docusaurus v2 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/docusaurus yarn add --dev @tsconfig/docusaurus ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/docusaurus/tsconfig.json" ``` > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ### Ember tsconfig.json Install: ```sh npm install --save-dev @tsconfig/ember yarn add --dev @tsconfig/ember ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/ember/tsconfig.json" ``` > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ### Next.js tsconfig.json Install: ```sh npm install --save-dev @tsconfig/next yarn add --dev @tsconfig/next ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/next/tsconfig.json" ``` ### Node LTS (24) tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node-lts yarn add --dev @tsconfig/node-lts ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node-lts/tsconfig.json" ``` ### Node with TypeScript (TS >=5.8 ONLY) tsconfig.json 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 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node10 yarn add --dev @tsconfig/node10 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node10/tsconfig.json" ``` ### Node 12 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node12 yarn add --dev @tsconfig/node12 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node12/tsconfig.json" ``` ### Node 14 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node14 yarn add --dev @tsconfig/node14 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node14/tsconfig.json" ``` ### Node 16 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node16 yarn add --dev @tsconfig/node16 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node16/tsconfig.json" ``` ### Node 17 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node17 yarn add --dev @tsconfig/node17 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node17/tsconfig.json" ``` ### Node 18 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node18 yarn add --dev @tsconfig/node18 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node18/tsconfig.json" ``` ### Node 19 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node19 yarn add --dev @tsconfig/node19 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node19/tsconfig.json" ``` ### Node 20 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node20 yarn add --dev @tsconfig/node20 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node20/tsconfig.json" ``` ### Node 21 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node21 yarn add --dev @tsconfig/node21 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node21/tsconfig.json" ``` ### Node 22 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node22 yarn add --dev @tsconfig/node22 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node22/tsconfig.json" ``` ### Node 23 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node23 yarn add --dev @tsconfig/node23 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node23/tsconfig.json" ``` ### Node 24 tsconfig.json Install: ```sh npm install --save-dev @tsconfig/node24 yarn add --dev @tsconfig/node24 ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/node24/tsconfig.json" ``` ### Nuxt tsconfig.json Install: ```sh npm install --save-dev @tsconfig/nuxt yarn add --dev @tsconfig/nuxt ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/nuxt/tsconfig.json" ``` > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ### QJSEngine tsconfig.json Install: ```sh npm install --save-dev @tsconfig/qjsengine yarn add --dev @tsconfig/qjsengine ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/qjsengine/tsconfig.json" ``` ### React Native tsconfig.json Install: ```sh npm install --save-dev @tsconfig/react-native yarn add --dev @tsconfig/react-native ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/react-native/tsconfig.json" ``` ### Remix tsconfig.json Install: ```sh npm install --save-dev @tsconfig/remix yarn add --dev @tsconfig/remix ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/remix/tsconfig.json" ``` > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ### Strictest tsconfig.json Install: ```sh npm install --save-dev @tsconfig/strictest yarn add --dev @tsconfig/strictest ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/strictest/tsconfig.json" ``` ### Svelte tsconfig.json Install: ```sh npm install --save-dev @tsconfig/svelte yarn add --dev @tsconfig/svelte ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/svelte/tsconfig.json" ``` > **NOTE**: After `@tsconfig/svelte@2.0.0`, you should add `/// ` to a `d.ts` or a `index.ts`(entry) file to prevent typescript error. ### Taro tsconfig.json Install: ```sh npm install --save-dev @tsconfig/taro yarn add --dev @tsconfig/taro ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/taro/tsconfig.json" ``` ### Vite React tsconfig.json Install: ```sh npm install --save-dev @tsconfig/vite-react yarn add --dev @tsconfig/vite-react ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/vite-react/tsconfig.json" ``` ### Bases tsconfig.json Install: ```sh npm install --save-dev @tsconfig/bases yarn add --dev @tsconfig/bases ``` Add to your `tsconfig.json`: ```json // "extends": "@tsconfig/bases/" "extends": "@tsconfig/bases/node-lts" ``` ### What about combined configs? Because of previous limitations in the config extension system of TypeScript, this repo used to provide combined configs from a few common bases (like Node + ESM, Node + Strictest and so on). This issue is now moot since TypeScript v5.0.0, which provides the [ability to extend from multiple configs at once](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-rc/#supporting-multiple-configuration-files-in-extends). For instance, if you want to start from a Node 18 + Strictest base config, you can install [@tsconfig/bases](#bases-tsconfigjson) (or both `@tsconfig/node18` and `@tsconfig/strictest`) package and extend those configs like so: ```jsonc // tsconfig.json { "extends": ["@tsconfig/bases/strictest", "@tsconfig/bases/node18"] // or "extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node18/tsconfig"] } ``` You can see the result of the combined configs via `tsc --showConfig`. ### What about `@tsconfig/esm`? We deprecated it in favour of setting [module/moduleResolution](https://github.com/tsconfig/bases/pull/197) to node/bundler. ### Contributing ```sh git clone https://github.com/tsconfig/bases.git tsconfig-bases cd tsconfig-bases ``` Then edit the tsconfig.json files in [`bases/`](./bases). Every morning there is a GitHub Action which deploys any changed bases. To generate the recommended TSConfig which is generated via `tsc --init`, run: ```sh deno run --allow-read --allow-run --allow-env --allow-write --allow-net scripts/generate-recommend.ts ``` ### Developing Create a set of npm packages via: ```sh deno run --allow-read --allow-write --allow-net scripts/create-npm-packages.ts ``` You can inspect them in the `packages/` folder, then they are deployed by passing in the paths to the base files via stdin: ```sh deno run --allow-read --allow-run --allow-env --allow-net scripts/deploy-changed-npm-packages.ts ``` The rest of the files in this repo are for deploying, which uses [Deno](https://deno.land) 1.0. If you add a new json file, please run `deno run --allow-read --allow-write scripts/update-markdown-readme.ts` to update the README. ================================================ FILE: bases/bun.json ================================================ { // This is based on https://bun.com/docs/typescript#suggested-compileroptions "$schema": "https://www.schemastore.org/tsconfig", "display": "Bun", "docs": "https://bun.com/docs/typescript", "compilerOptions": { // Environment setup & latest features "lib": ["ESNext"], "target": "ESNext", "module": "Preserve", "moduleDetection": "force", "jsx": "react-jsx", "allowJs": true, // Bundler mode "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "noEmit": true, // Best practices "strict": true, "skipLibCheck": true, "noFallthroughCasesInSwitch": true, "noUncheckedIndexedAccess": true, "noImplicitOverride": true, // Some stricter flags (disabled by default) "noUnusedLocals": false, "noUnusedParameters": false, "noPropertyAccessFromIndexSignature": false } } ================================================ FILE: bases/create-react-app.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Create React App", "_version": "2.0.0", "compilerOptions": { "lib": ["dom", "dom.iterable", "esnext"], "module": "esnext", "moduleResolution": "bundler", "target": "es2015", "allowJs": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "isolatedModules": true, "jsx": "react-jsx", "noEmit": true, "noFallthroughCasesInSwitch": true, "resolveJsonModule": true, "skipLibCheck": true, "strict": true } } ================================================ FILE: bases/cypress.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Cypress", "compilerOptions": { "target": "es5", "lib": ["es5", "dom"], "types": ["cypress"] } } ================================================ FILE: bases/deno.json ================================================ { // This is based on https://deno.land/manual/getting_started/typescript#custom-typescript-compiler-options // then the defaults are removed. "$schema": "https://www.schemastore.org/tsconfig", "display": "Deno", "compilerOptions": { "jsx": "react", "lib": [], "resolveJsonModule": true, "strict": true } } ================================================ FILE: bases/docusaurus.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Docusaurus v2", "docs": "https://v2.docusaurus.io/docs/typescript-support", "_version": "2.0.0", "compilerOptions": { "allowJs": true, "esModuleInterop": true, "jsx": "react", "lib": ["dom"], "module": "esnext", "moduleResolution": "bundler", "noEmit": true, "types": ["node", "@docusaurus/module-type-aliases", "@docusaurus/theme-classic"], "baseUrl": ".", "paths": { "@site/*": ["./*"] }, "skipLibCheck": true } } ================================================ FILE: bases/ember.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Ember", "docs": "https://guides.emberjs.com/release/typescript/", "_version": "3.0.0", "_deprecated": true, // This is the base config used by Ember apps and addons. When actually used // via Ember CLI (e.g. ember-cli-typescript's blueprint), it additionally has // `compilerOptions.baseUrl`, `compilerOptions.paths`, and `include` set. "compilerOptions": { "target": "es2023", "module": "esnext", "moduleResolution": "bundler", // We don't want to include types dependencies in our compiled output, so tell TypeScript // to enforce using `import type` instead of `import` for Types. "verbatimModuleSyntax": true, // Trying to check Ember apps and addons with `allowJs: true` is a recipe // for many unresolveable type errors, because with *considerable* extra // configuration it ends up including many files which are *not* valid and // cannot be: they *appear* to be resolve-able to TS, but are in fact not in // valid Node-resolveable locations and may not have TS-ready types. This // will likely improve over time "allowJs": false, // Practically, it is *nearly* impossible to have every type-checked // package in your dependency graph to have compatible types. // Good stewards of the ecosystem may opt to set this to false and try to // fix packages with failures, but for most people, the error information // is inactionable noise. "skipLibCheck": true, // --- TS for SemVer Types compatibility // Strictness settings -- you should *not* change these: Ember code is not // guaranteed to type check with these set to looser values. "strict": true, "noUncheckedIndexedAccess": true, // Interop: this is viral and will require anyone downstream of your package // to *also* set them to true. However, this represents the way that // bundlers actually work, and is future-compatible with the closest module // modes: "nodenext" in TS 4.7+ and "mixed" in 5.0+ mode. Since Ember apps // and addons never emit with `tsc`, this is safe: it makes type-checking do // the right thing, but does not result in changes to what gets emitted. We // intentionally leave `esModuleInterop` unset, so that it gets whatever TS // provides as the default for the currently-specified `module` mode. "allowSyntheticDefaultImports": true, // --- Lint-style rules // TypeScript also supplies some lint-style checks; nearly all of them are // better handled by ESLint with the `@typescript-eslint`. This one is more // like a safety check, though, so we leave it on. "noPropertyAccessFromIndexSignature": true, // --- Compilation/integration settings // Setting `noEmitOnError` here allows tools trying to respect the tsconfig // to still emit code without breaking on errors. // Errors are still reported in the CLI when running `tsc` or `glint`, // but the errors won't prevent code from being emitted. // This helps hasten development by allowing devs to prototype before coming // to a decision on what they want their types to be. "noEmitOnError": false, // We use Babel for emitting runtime code, because it's very important that // we always and only use the same transpiler for non-stable features, in // particular decorators. If you were to change this to `true`, it could // lead to accidentally generating code with `tsc` instead of Babel, and // could thereby result in broken code at runtime. "noEmit": true, // Ember makes heavy use of decorators; TS does not support them at all // without this flag. "experimentalDecorators": true, // We don't use TS for compilation, so we can disable these. // Library authors should set declaration and declarationMap to true, however "declaration": false, "declarationMap": false, "inlineSourceMap": false, "inlineSources": false, // Don't implicitly pull in declarations from `@types` packages unless we // actually import from them AND the package in question doesn't bring its // own types. // // You may wish to override this e.g. with `"types": ["ember-source/types"]` "types": [] } } ================================================ FILE: bases/next.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Next.js", "_version": "2.0.0", "compilerOptions": { "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, "plugins": [ { "name": "next" } ] }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } ================================================ FILE: bases/node-lts.json ================================================ // This file was autogenerated by a script // Equivalent to a config of: node24 { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node LTS (24)", "_version": "24.0.0", "compilerOptions": { "lib": [ "es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Iterator", "ESNext.Promise" ], "module": "nodenext", "target": "es2024", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node-ts.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node with TypeScript (TS >=5.8 ONLY)", "docs": [ "https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/#path-rewriting-for-relative-paths", "https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option" ], "_version": "23.6.0", "compilerOptions": { "rewriteRelativeImportExtensions": true, "erasableSyntaxOnly": true, "verbatimModuleSyntax": true } } ================================================ FILE: bases/node10.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 10", "compilerOptions": { "lib": ["es2018"], "module": "commonjs", "target": "es2018", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node" } } ================================================ FILE: bases/node12.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 12", "_version": "12.1.0", "compilerOptions": { "lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"], "module": "node16", "target": "es2019", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node14.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 14", "_version": "14.1.0", "compilerOptions": { "lib": ["es2020"], "module": "node16", "target": "es2020", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node16.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 16", "_version": "16.1.0", "compilerOptions": { "lib": ["es2021"], "module": "node16", "target": "es2021", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node17.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 17", "_version": "17.1.0", "compilerOptions": { "lib": ["es2022"], "module": "node16", "target": "es2022", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "useDefineForClassFields": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node18.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 18", "_version": "18.2.0", "compilerOptions": { "lib": ["es2023"], "module": "node16", "target": "es2022", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node19.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 19", "_version": "19.1.0", "compilerOptions": { "lib": ["es2023"], "module": "node16", "target": "es2022", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node20.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 20", "_version": "20.1.0", "compilerOptions": { "lib": ["es2023"], "module": "nodenext", "target": "es2022", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node21.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 21", "_version": "21.0.0", "compilerOptions": { "lib": ["es2023"], "module": "nodenext", "target": "es2022", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node22.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 22", "_version": "22.0.0", "compilerOptions": { "lib": ["es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Iterator"], "module": "nodenext", "target": "es2022", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node23.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 23", "_version": "23.0.0", "compilerOptions": { "lib": ["es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Iterator", "ESNext.Promise"], "module": "nodenext", "target": "es2024", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/node24.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 24", "_version": "24.0.0", "compilerOptions": { "lib": [ "es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Error", "ESNext.Iterator", "ESNext.Promise" ], "module": "nodenext", "target": "es2024", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "moduleResolution": "node16" } } ================================================ FILE: bases/nuxt.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Nuxt", "_version": "2.0.0", "compilerOptions": { "target": "esnext", "module": "esnext", "moduleResolution": "bundler", "lib": [ "esnext", "esnext.asynciterable", "dom" ], "esModuleInterop": true, "allowJs": true, "sourceMap": true, "strict": true, "noEmit": true, "baseUrl": ".", "paths": { "~/*": [ "./*" ], "@/*": [ "./*" ] }, "types": [ "@types/node", "@nuxt/types" ] }, "exclude": [ "node_modules", ".nuxt", "dist" ] } ================================================ FILE: bases/qjsengine.json ================================================ { // https://doc.qt.io/qt-5/qjsengine.html "$schema": "https://www.schemastore.org/tsconfig", "display": "QJSEngine", "compilerOptions": { // Technically QTJSEngine supportes ES2016, however there are issues with // arrow functions where in certain contexts "this" does not exist. // Targeting ES5 instead fixes these issues by binding this to a variable // and closing over that instead. "target": "ES5", "lib": ["ES2016"], "module": "none", "esModuleInterop": false, "strict": true } } ================================================ FILE: bases/react-native.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "React Native", "_version": "3.0.2", "compilerOptions": { "target": "esnext", "module": "commonjs", "types": ["react-native", "jest"], "lib": [ "es2019", "es2020.bigint", "es2020.date", "es2020.number", "es2020.promise", "es2020.string", "es2020.symbol.wellknown", "es2021.promise", "es2021.string", "es2021.weakref", "es2022.array", "es2022.object", "es2022.string" ], "allowJs": true, "jsx": "react-native", "noEmit": true, "isolatedModules": true, "strict": true, "moduleResolution": "node", "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "skipLibCheck": true } } ================================================ FILE: bases/recommended.json ================================================ { "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, "skipLibCheck": true }, "display": "Recommended", "$schema": "https://www.schemastore.org/tsconfig" } ================================================ FILE: bases/remix.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Remix", "_version": "2.0.0", "compilerOptions": { "lib": ["dom", "dom.iterable", "es2019"], "isolatedModules": true, "esModuleInterop": true, "jsx": "react-jsx", "module": "esnext", "moduleResolution": "bundler", "resolveJsonModule": true, "target": "es2019", "strict": true, "allowJs": true, "baseUrl": ".", "paths": { "~/*": ["./app/*"] }, // Remix takes care of building everything in `remix build`. "noEmit": true } } ================================================ FILE: bases/strictest.json ================================================ { "compilerOptions": { "strict": true, "allowUnusedLabels": false, "allowUnreachableCode": false, "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, "noImplicitOverride": true, "noImplicitReturns": true, "noPropertyAccessFromIndexSignature": true, "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noUnusedParameters": true, "isolatedModules": true, "esModuleInterop": true, "skipLibCheck": true }, "$schema": "https://www.schemastore.org/tsconfig", "display": "Strictest", "_version": "2.0.0" } ================================================ FILE: bases/svelte.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Svelte", "_version": "5.0.0", "compilerOptions": { "module": "esnext", "moduleResolution": "bundler", "target": "es2017", /** Svelte Preprocess cannot figure out whether you have a value or a type, so tell TypeScript to enforce using `import type` instead of `import` for Types. */ "verbatimModuleSyntax": true, /** To have warnings/errors of the Svelte compiler at the correct position, enable source maps by default. */ "sourceMap": true, "strict": true, "esModuleInterop": true, "skipLibCheck": true } } ================================================ FILE: bases/taro.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Taro", "compileOnSave": false, "compilerOptions": { "target": "es2017", "module": "commonjs", "moduleResolution": "node", "allowJs": true, "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "resolveJsonModule": true, "skipLibCheck": true, "strict": true, "noEmit": true, "jsx": "react-jsx" } } ================================================ FILE: bases/vite-react.json ================================================ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Vite React", "_version": "7.0.0", "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2022", "useDefineForClassFields": true, "lib": ["ES2022", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "moduleDetection": "force", "noEmit": true, "jsx": "react-jsx", /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "erasableSyntaxOnly": true, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true } } ================================================ FILE: readme-extras/docusaurus.md ================================================ > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ================================================ FILE: readme-extras/ember.md ================================================ > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ================================================ FILE: readme-extras/node-ts.md ================================================ > 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"] } ``` ================================================ FILE: readme-extras/nuxt.md ================================================ > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ================================================ FILE: readme-extras/remix.md ================================================ > **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. ================================================ FILE: readme-extras/svelte.md ================================================ > **NOTE**: After `@tsconfig/svelte@2.0.0`, you should add `/// ` to a `d.ts` or a `index.ts`(entry) file to prevent typescript error. ================================================ FILE: scripts/create-npm-packages.ts ================================================ import * as path from "https://deno.land/std/path/mod.ts"; import stripJsonComments from "https://esm.sh/strip-json-comments"; for await (const tsconfigEntry of Deno.readDir("bases")) { if (!tsconfigEntry.isFile) continue const tsconfigFilePath = path.join("bases", tsconfigEntry.name) const name = path.basename(tsconfigEntry.name).replace(".json", "") // Make the folder const packagePath = path.join("packages", name) Deno.mkdirSync(packagePath, { recursive: true }) // Copy over the template files const templateDir = "./template" for await (const templateFile of Deno.readDir(templateDir)) { if (!templateFile.isFile) continue if (templateFile.name === "README-combined.md") continue // README-combined.md is only for the combined bases const templatedFile = path.join(templateDir, templateFile.name) Deno.copyFileSync(templatedFile, path.join(packagePath, templateFile.name)) } // Copy the create a tsconfig.json from the base json const newPackageTSConfigPath = path.join(packagePath, "tsconfig.json") Deno.copyFileSync(tsconfigFilePath, newPackageTSConfigPath) const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath) const tsconfigJSON = JSON.parse(stripJsonComments(tsconfigText)) // Drop `display` field in tsconfig.json for npm package await Deno.writeTextFile(newPackageTSConfigPath, tsconfigText.replace(/\s*"display.*/,'')) // Edit the package.json const packageText = await Deno.readTextFile(path.join(packagePath, "package.json")) const packageJSON = JSON.parse(packageText) packageJSON.name = `@tsconfig/${name}` packageJSON.description = `A base TSConfig for working with ${tsconfigJSON.display}.` packageJSON.keywords = ["tsconfig", name] // Do some string replacements in the other templated files const replaceTextIn = ["README.md"] for (const filenameToEdit of replaceTextIn) { const fileToEdit = path.join(packagePath, filenameToEdit) const defaultTitle = `A base TSConfig for working with ${tsconfigJSON.display}` const title = name !== "recommended" ? defaultTitle : "The recommended base for a TSConfig" let packageText = await Deno.readTextFile(fileToEdit) packageText = packageText.replace(/\[filename\]/g, name) .replace(/\[display_title\]/g, title) .replace(/\[tsconfig\]/g, Deno.readTextFileSync(newPackageTSConfigPath)) // Inject readme-extra if any try { const readmeExtra = (await Deno.readTextFile(path.join("readme-extras", `${name}.md`))).trim() if (readmeExtra) packageText = packageText.replace(/\[readme-extra\]/g, `\n${readmeExtra}\n`) } catch (error) { // NOOP, there is no extra readme // console.log(error) } // Remove readme-extra placeholders if any packageText = packageText.replace(/\[readme-extra\]/g, '') await Deno.writeTextFile(fileToEdit, packageText) }; // Bump the last version of the number from npm, // or use the _version in tsconfig if it's higher, // or default to 1.0.0 let version = tsconfigJSON._version || "1.0.0" try { const npmResponse = await fetch(`https://registry.npmjs.org/${packageJSON.name}`) const npmPackage = await npmResponse.json() const semverMarkers = npmPackage["dist-tags"].latest.split("."); const bumpedVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${Number(semverMarkers[2]) + 1}`; if (isBumpedVersionHigher(version, bumpedVersion)) { version = bumpedVersion; } } catch (error) { // NOOP, this is for the first deploy // console.log(error) } packageJSON.version = version await Deno.writeTextFile(path.join(packagePath, "package.json"), JSON.stringify(packageJSON, null, " ")) console.log("Built:", tsconfigEntry.name); } await buildTsconfigBases() function isBumpedVersionHigher (packageJSONVersion: string, bumpedVersion: string) { const semverMarkersPackageJSON = packageJSONVersion.split('.') const semverMarkersBumped = bumpedVersion.split('.') for (let i = 0; i < 3; i++) { if (Number(semverMarkersPackageJSON[i]) > Number(semverMarkersBumped[i])) { return false } } return true } // build @tsconfig/bases catch all package async function buildTsconfigBases() { const name = "bases" // Make the folder const packagePath = path.join("packages", name) Deno.mkdirSync(packagePath, { recursive: true }) // Copy over the template files const templateDir = "./template" for await (const templateFile of Deno.readDir(templateDir)) { if (!templateFile.isFile) continue if (templateFile.name === "README.md") continue const templatedFile = path.join(templateDir, templateFile.name) Deno.copyFileSync( templatedFile, path.join( packagePath, templateFile.name === "README-combined.md" ? "README.md" : templateFile.name, ), ) } const exportsOverride = {} // Copy the tsconfig.json files from all bases for await (const tsconfigEntry of Deno.readDir("bases")) { if (!tsconfigEntry.isFile) continue // remove extension const name = tsconfigEntry.name.replace(/\.json$/, "") const finalTsconfigFile = `${name}.tsconfig.json` // add entry to package.json exports exportsOverride[`./${name}`] = `./${finalTsconfigFile}` const tsconfigFilePath = path.join("bases", tsconfigEntry.name) const newPackageTSConfigPath = path.join(packagePath, finalTsconfigFile) Deno.copyFileSync(tsconfigFilePath, newPackageTSConfigPath) const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath) // Drop `display` field in tsconfig.json for npm package await Deno.writeTextFile(newPackageTSConfigPath, tsconfigText.replace(/\s*"display.*/, "")) } const tsconfigJSON = { display: "Bases" } // Edit the package.json const packageText = await Deno.readTextFile(path.join(packagePath, "package.json")) const packageJSON = JSON.parse(packageText) packageJSON.name = `@tsconfig/${name}` packageJSON.description = `Combined tsconfig bases.` packageJSON.keywords = ["tsconfig", name, "combined"] packageJSON.exports = exportsOverride // Do some string replacements in the other templated files const replaceTextIn = ["README.md"] for (const filenameToEdit of replaceTextIn) { const fileToEdit = path.join(packagePath, filenameToEdit) const defaultTitle = `A base TSConfig for working with ${tsconfigJSON.display}` const title = name !== "recommended" ? defaultTitle : "The recommended base for a TSConfig" let packageText = await Deno.readTextFile(fileToEdit) packageText = packageText.replace(/\[filename\]/g, name).replace(/\[display_title\]/g, title) // Inject readme-extra if any try { const readmeExtra = (await Deno.readTextFile(path.join("readme-extras", `${name}.md`))).trim() if (readmeExtra) { packageText = packageText.replace(/\[readme-extra\]/g, `\n${readmeExtra}\n`) } } catch (error) { // NOOP, there is no extra readme // console.log(error) } // Remove readme-extra placeholders if any packageText = packageText.replace(/\[readme-extra\]/g, "") await Deno.writeTextFile(fileToEdit, packageText) } // Bump the last version of the number from npm, // or use the _version in tsconfig if it's higher, // or default to 1.0.0 let version = tsconfigJSON._version || "1.0.0" try { const npmResponse = await fetch(`https://registry.npmjs.org/${packageJSON.name}`) const npmPackage = await npmResponse.json() const semverMarkers = npmPackage["dist-tags"].latest.split(".") const bumpedVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${Number(semverMarkers[2]) + 1}` if (isBumpedVersionHigher(version, bumpedVersion)) { version = bumpedVersion } } catch (error) { // NOOP, this is for the first deploy // console.log(error) } packageJSON.version = version await Deno.writeTextFile( path.join(packagePath, "package.json"), JSON.stringify(packageJSON, null, " "), ) console.log("Built:", "bases") } ================================================ FILE: scripts/deploy-changed-npm-packages.ts ================================================ import * as path from "https://deno.land/std@0.164.0/path/mod.ts"; import * as bufio from "https://deno.land/std@0.164.0/io/buffer.ts"; // Loop through generated packages, deploying versions for anything which has a different tsconfig const uploaded = [] for (const dirEntry of Deno.readDirSync("packages")) { if (dirEntry.name === 'bases') continue // @tsconfig/bases package is special, it doesn't have a single tsconfig entry, it will be deployed separately const localTsconfigPath = path.join("packages", dirEntry.name, "tsconfig.json"); const newTSConfig = Deno.readTextFileSync(localTsconfigPath); let upload = false; try { const unpkgURL = `https://unpkg.com/@tsconfig/${dirEntry.name}/tsconfig.json`; const currentJSONReq = await fetch(unpkgURL); const currentJSONTxt = await currentJSONReq.text(); upload = currentJSONTxt !== newTSConfig; } catch (error) { // Not here, definitely needs to be uploaded upload = true; } if (upload) { const process = Deno.run({ cmd: ["npm", "publish", "--provenance", "--access", "public"], stdout: "piped", cwd: path.join("packages", dirEntry.name), env: { NODE_AUTH_TOKEN: Deno.env.get("NODE_AUTH_TOKEN")! }, }); for await (const line of bufio.readLines(process.stdout!)) { console.warn(line); } uploaded.push(dirEntry.name) } } if (uploaded.length) { // If there's any uploads, we need to update the combined package too const process = Deno.run({ cmd: ["npm", "publish", "--provenance", "--access", "public"], stdout: "piped", cwd: path.join("packages", "bases"), env: { NODE_AUTH_TOKEN: Deno.env.get("NODE_AUTH_TOKEN")! }, }); for await (const line of bufio.readLines(process.stdout!)) { console.warn(line); } console.log("Uploaded: ", uploaded.join(", ")) } else { console.log("No uploads") } ================================================ FILE: scripts/generate-lts.ts ================================================ // deno run --allow-read --allow-write --allow-net scripts/generate-lts.ts // import { gt } from "https://deno.land/std@0.192.0/semver/gt.ts"; import { parse } from "https://deno.land/std@0.192.0/semver/parse.ts"; interface NodeReleaseMetadata { version: string; date: string; files: string[]; npm?: string; v8: string; uv?: string; zlib?: string; openssl?: string; modules?: string; lts: string | boolean; security: boolean; } type Tsconfig = Record; const versionRegex = /v(\d+)\.(\d+)\.(\d+)/; const releasesResponse = await fetch("https://nodejs.org/download/release/index.json"); const releasesJson = (await releasesResponse.json()) as NodeReleaseMetadata[]; const lts = releasesJson .filter((r) => r.lts) .reduce( (prevValue, currValue) => (gt(parse(currValue.version), parse(prevValue.version)) ? currValue : prevValue), { version: "v0.0.0" } ); const baseMajorVersion = (lts.version.match(versionRegex) || [])[1]; const base = `node${baseMajorVersion}`; const versioned = { $schema: "https://www.schemastore.org/tsconfig", display: `Node LTS (${baseMajorVersion})`, _version: lts.version.substring(lts.version.indexOf("v") + 1) }; import * as path from "https://deno.land/std/path/mod.ts"; import stripJsonComments from "https://esm.sh/strip-json-comments"; import { deepMerge } from "https://deno.land/std/collections/deep_merge.ts"; const packageText = await Deno.readTextFile(path.join(Deno.cwd(), "bases", `${base}.json`)); const parsed = JSON.parse(stripJsonComments(packageText)) as Tsconfig; // This is to get the _version property to show up directly under the display property const parsedAndOrdered = deepMerge(versioned, parsed); parsedAndOrdered.display = versioned.display; const serializedConfig = "// This file was autogenerated by a script\n" + `// Equivalent to a config of: ${base}\n` + JSON.stringify(parsedAndOrdered, null, " ") + "\n"; const filePath = path.join(Deno.cwd(), "bases/node-lts.json"); Deno.writeTextFile(filePath, serializedConfig); ================================================ FILE: scripts/generate-recommend.ts ================================================ import stripJsonComments from "https://esm.sh/strip-json-comments"; import * as bufio from "https://deno.land/std@0.164.0/io/buffer.ts"; import * as path from "https://deno.land/std/path/mod.ts"; const tsconfigStorage = await Deno.makeTempDir({ prefix: "tsconfig" }); // Generate a tsconfig const p = await Deno.run({ cmd: ["npx", "-p", "typescript", "tsc", "--init"], stdout: "piped", cwd: tsconfigStorage }); for await (const line of bufio.readLines(p.stdout!)) { console.warn(line); } let packageText = await Deno.readTextFile(path.join(tsconfigStorage, "tsconfig.json")); // This will strip comments const parsed = JSON.parse(stripJsonComments(packageText)); // `display` field will be dropped at generating npm package, so prevent the order from being last in the JSON file parsed.display = "Recommended"; parsed["$schema"] = "https://www.schemastore.org/tsconfig"; const result = JSON.stringify(parsed, null, " "); const npmResponse = await fetch(`https://unpkg.com/@tsconfig/svelte/tsconfig.json`); const npmPackage = await npmResponse.text(); if (npmPackage !== result) { Deno.writeTextFile("bases/recommended.json", result); } ================================================ FILE: scripts/update-markdown-readme.ts ================================================ // deno run --allow-read --allow-write scripts/update-markdown-readme.ts // import * as path from "https://deno.land/std/path/mod.ts"; import stripJsonComments from "https://esm.sh/strip-json-comments"; const readme = await Deno.readTextFileSync("./README.md") let center = "" const paths = [] for await (const tsconfigEntry of Deno.readDir("bases")) { if (!tsconfigEntry.isFile) continue paths.push(tsconfigEntry.name) } const sortedPaths = paths.sort((l, r) => l.localeCompare(r)).filter(r => !r.includes("recommended")) const basePaths = ["recommended.json", ...sortedPaths] for (const base of basePaths) { if (base === "esm.json") continue const tsconfigFilePath = path.join("bases", base) const name = path.basename(base).replace(".json", "") const tsconfigText = await Deno.readTextFile(tsconfigFilePath) const tsconfigJSON = JSON.parse(stripJsonComments(tsconfigText)) center += `### ${tsconfigJSON.display} tsconfig.json\n` center += ` Install: \`\`\`sh npm install --save-dev @tsconfig/${name} yarn add --dev @tsconfig/${name} \`\`\` ` 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" \`\`\` ` if (readmeExtra) { if (!readmeExtra.includes("extends")) { center += defaultInstructions + "\n" } center += `\n${readmeExtra}\n\n` } else { center += defaultInstructions } }; const startMarker ="" const start = readme.split(startMarker)[0] const endMarker ="" const end = readme.split(endMarker)[1] const newREADME = start + startMarker + "\n" + center + "\n" + endMarker + end await Deno.writeTextFileSync("./README.md", newREADME) ================================================ FILE: template/LICENSE ================================================ MIT License Copyright (c) Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE ================================================ FILE: template/README-combined.md ================================================ ### [display_title]. Add the package to your `"devDependencies"`: ```sh npm install --save-dev @tsconfig/[filename] yarn add --dev @tsconfig/[filename] ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/[filename]/" # eg "extends": "@tsconfig/[filename]/node-lts" ``` You can find the [code here](https://github.com/tsconfig/bases/blob/master/bases/). ================================================ FILE: template/README.md ================================================ ### [display_title]. Add the package to your `"devDependencies"`: ```sh npm install --save-dev @tsconfig/[filename] yarn add --dev @tsconfig/[filename] ``` Add to your `tsconfig.json`: ```json "extends": "@tsconfig/[filename]/tsconfig.json" ``` [readme-extra] --- The `tsconfig.json`: ```jsonc [tsconfig] ``` You can find the [code here](https://github.com/tsconfig/bases/blob/master/bases/[filename].json). ================================================ FILE: template/package.json ================================================ { "name": "replaced-later", "repository": { "type": "git", "url": "https://github.com/tsconfig/bases.git", "directory": "bases" }, "license": "MIT" } ================================================ FILE: test/index.ts ================================================ console.log("Hello World") ================================================ FILE: test/package.json ================================================ { "name": "test-bases", "scripts": { "test": "tsc --noEmit" }, "packageManager": "pnpm@10.12.4", "devDependencies": { "@tsconfig/bases": "link:../packages/bases", "@types/node": "^24.2.1", "typescript": "^5.9.2" } } ================================================ FILE: test/tsconfig.json ================================================ { "extends": ["@tsconfig/bases/node-lts"] }