From 354b7dfe521538800296a9ee883401337da389a5 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sat, 9 Nov 2024 15:36:37 +0800 Subject: [PATCH 01/10] docs: update the examples to use Node.js 22 as it's the active LTS --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d94ee10..b6f6515 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,13 @@ Add one of the available configurations to your `tsconfig.json`: First install the base tsconfig and types for the Node.js version you are targeting, for example: ```sh -npm add -D @tsconfig/node18 @types/node@18 +npm add -D @tsconfig/node22 @types/node@22 ``` If you are not using any bundlers, the Node.js code doesn't rely on any Vue/Vite-specific features, then these would be enough, you may not need to extend the Vue TSConfig: ```json -"extends": "@tsconfig/node18/tsconfig.json", +"extends": "@tsconfig/node22/tsconfig.json", "compilerOptions": { "types": ["node"] } @@ -49,7 +49,7 @@ Otherwise, if you are trying to use Vue components in Node.js environments (e.g. ```json "extends": [ - "@tsconfig/node18/tsconfig.json", + "@tsconfig/node22/tsconfig.json", "@vue/tsconfig/tsconfig.json" ], "compilerOptions": { @@ -57,7 +57,7 @@ Otherwise, if you are trying to use Vue components in Node.js environments (e.g. } ``` -Make sure to place `@vue/tsconfig/tsconfig.json` *after* `@tsconfig/node18/tsconfig.json` so that it takes precedence. +Make sure to place `@vue/tsconfig/tsconfig.json` *after* `@tsconfig/node22/tsconfig.json` so that it takes precedence. ## Emitting Declaration Files From 16c3736aaa49570c08072a24213a46ce9c3c0a62 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sat, 9 Nov 2024 15:56:58 +0800 Subject: [PATCH 02/10] chore: remove the FIXME comment on `outDir` field Starting in TypeScript 5.6, `.tsbuildinfo` file is always written in a `--build` invocation[^1]. So the entire community need to embrace the new behavior and explicitly set `tsbuildInfoFile` if they want to avoid polluting the project root. So I think it's no longer our responsibility to find a workaround for the users. Closes #27 [^1]: https://devblogs.microsoft.com/typescript/announcing-typescript-5-6-beta/#tsbuildinfo-is-always-written --- README.md | 2 +- tsconfig.json | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index b6f6515..2b2199a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ TSConfigs for Vue projects to extend. Requires TypeScript >= 5.0. For TypeScript v4.5 to v4.9, please use [v0.1.x](https://www.npmjs.com/package/@vue/tsconfig/v/0.1.3). -[See below for the changes in v0.3.x.](#migrating-from-typescript--50) +[See below for the breaking changes in v0.3.x.](#migrating-from-typescript--50) ## Installation diff --git a/tsconfig.json b/tsconfig.json index 2c937f4..b7f7ebc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,16 +3,6 @@ // Most non-library projects don't need to emit declarations. // So we add this option by default to make the config more friendly to most users. "noEmit": true, - // When type-checking with solution-style tsconfigs, though with `noEmit: true`, there won't - // be any `.d.ts` files emitted, but tsc still writes a `.tsbuildinfo` file to the `outDir` - // for each project. If we don't explicitly set the `outDir`, it will be in the same folder - // as the `tsconfig.json` file, which would look messy. - // Setting it to `./dist/` isn't ideal either, because it would pollute the `dist` folder. - // So we set it to a hidden folder in `node_modules` to avoid polluting the project root. - // FIXME: - // This caused a regression: https://github.com/vuejs/tsconfig/issues/27 - // Need to find a better solution. - // "outDir": "./node_modules/.cache/vue-tsbuildinfo", // As long as you are using a build tool, we recommend you to author and ship in ES modules. // Even if you are targeting Node.js, because From 480cd96cfeea29125c72d7e31fc18b3cbf11b93f Mon Sep 17 00:00:00 2001 From: yionr Date: Sat, 9 Nov 2024 16:14:54 +0800 Subject: [PATCH 03/10] fix: typo (#28) --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index b7f7ebc..1688966 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -44,7 +44,7 @@ // at least `ES2020` for dynamic `import()`s and `import.meta` to work correctly. // - If you are not using Vite, feel free to overwrite the `target` field. "target": "ESNext", - // For spec compilance. + // For spec compliance. // `true` by default if the `target` is `ES2020` or higher. // Explicitly set it to `true` here in case some users want to overwrite the `target`. "useDefineForClassFields": true, From 27fa57b67cf10a821aa37d7dd4c6177160284610 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 10 Nov 2024 14:14:25 +0800 Subject: [PATCH 04/10] feat: enable allowImportingTsExtensions We've enabled `noEmit` for a while and the constraint on solution-style tsconfigs were no longer a problem long ago. So let's enable it. --- tsconfig.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 1688966..fe2b4f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,11 +15,7 @@ // So here we enable some resolution features that are only available in bundlers. "moduleResolution": "bundler", "resolveJsonModule": true, - // `allowImportingTsExtensions` can only be used when `noEmit` or `emitDeclarationOnly` is set. - // But `noEmit` may cause problems with solution-style tsconfigs: - // - // And `emitDeclarationOnly` is not always wanted. - // Considering it's not likely to be commonly used in Vue codebases, we don't enable it here. + "allowImportingTsExtensions": true, // Required in Vue projects "jsx": "preserve", From 6355fabfda32f321995e99adb3656b6c104d9348 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 10 Nov 2024 15:33:02 +0800 Subject: [PATCH 05/10] feat: set `moduleDetection` to `force` It's considered a good practice as illustrated in: https://www.totaltypescript.com/cannot-redeclare-block-scoped-variable#solution-3-your-module-isnt-a-module --- tsconfig.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tsconfig.json b/tsconfig.json index fe2b4f6..56402e7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,10 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "allowImportingTsExtensions": true, + // Even files without `import` or `export` are treated as modules. + // It helps to avoid mysterious errors such as `Cannot redeclare block-scoped variable 'name`. + // https://www.totaltypescript.com/cannot-redeclare-block-scoped-variable#solution-3-your-module-isnt-a-module + "moduleDetection": "force", // Required in Vue projects "jsx": "preserve", From e1ef30943dd5a31edc609650fa39c293214504f8 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 10 Nov 2024 15:35:48 +0800 Subject: [PATCH 06/10] chore: rename `bundler` to `Bundler` for consistency While the configuration options are not case-sensitive, it is good to keep the casing consistent. The JSON schema at https://json.schemastore.org/tsconfig uses `Bundler`, so we should use the same casing. --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 56402e7..6584fa9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ // We expect users to use bundlers. // So here we enable some resolution features that are only available in bundlers. - "moduleResolution": "bundler", + "moduleResolution": "Bundler", "resolveJsonModule": true, "allowImportingTsExtensions": true, // Even files without `import` or `export` are treated as modules. From 590d74c064641bb6bdbe9efedf19446cb8d8a5d9 Mon Sep 17 00:00:00 2001 From: sgpinkus Date: Sun, 10 Nov 2024 18:04:35 +1000 Subject: [PATCH 07/10] fix: add peer dep to typescript v5.x in package.json. (#20) --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 066ff62..97f71d5 100644 --- a/package.json +++ b/package.json @@ -22,5 +22,8 @@ "homepage": "https://github.com/vuejs/tsconfig#readme", "publishConfig": { "access": "public" + }, + "peerDependencies": { + "typescript": "5.x" } } From ad9bd77c05ed7dadc0abff3f4a8ec164021f38d0 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 10 Nov 2024 16:07:07 +0800 Subject: [PATCH 08/10] fix: require vue 3.3 as peer dependency Because `jsxImportSource: "vue"` is only available in Vue 3.3 and above: I also made both `vue` and `typescript` optional peer dependencies, in case the configuration is not used to *run* or *type-check* a vue project, but only to *transpile* some source code. Closes #17, as we never intended to support Vue 2.x in the first place, even it works in some earlier versions, the configuration might not be optimal for Vue 2.x projects. --- README.md | 1 + package.json | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b2199a..60068b5 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ TSConfigs for Vue projects to extend. Requires TypeScript >= 5.0. For TypeScript v4.5 to v4.9, please use [v0.1.x](https://www.npmjs.com/package/@vue/tsconfig/v/0.1.3). +Requires Vue.js >= 3.3. [See below for the breaking changes in v0.3.x.](#migrating-from-typescript--50) diff --git a/package.json b/package.json index 97f71d5..77bc230 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,15 @@ "access": "public" }, "peerDependencies": { - "typescript": "5.x" + "typescript": "5.x", + "vue": "^3.3.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "vue": { + "optional": true + } } } From 1b9a7637a2913e3db247e99fd2b6cef22a5e30d8 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 10 Nov 2024 23:43:52 +0800 Subject: [PATCH 09/10] workflow: add release automation with provenance --- .github/MAINTENANCE.md | 10 ++++++++++ .github/workflows/publish.yml | 24 ++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/MAINTENANCE.md create mode 100644 .github/workflows/publish.yml diff --git a/.github/MAINTENANCE.md b/.github/MAINTENANCE.md new file mode 100644 index 0000000..6c0c2c0 --- /dev/null +++ b/.github/MAINTENANCE.md @@ -0,0 +1,10 @@ +This document explains how to perform the project's maintenance tasks. + +### Creating a new release + +Anyone with write access to the repository can request a new release. To do so, follow these steps: + +1. Run `npm version ` locally to bump the version number and create a new commit / tag. +2. Push the commit and tag to the repository by running `git push --follow-tags`. +3. The release will be automatically published to npm by GitHub Actions once approved by an administrator. +4. Go to and create a new release with the tag that was just created. Describe the notable changes in the release notes. diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..a7b7170 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Release + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + release: + # Use Publish environment for deployment protection + environment: Publish + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + registry-url: 'https://registry.npmjs.org' + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 77bc230..e9dc642 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ }, "homepage": "https://github.com/vuejs/tsconfig#readme", "publishConfig": { - "access": "public" + "access": "public", + "provenance": true }, "peerDependencies": { "typescript": "5.x", From ab39083e7081fbce4ff3ed9318efc26ae36e908f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 10 Nov 2024 23:45:32 +0800 Subject: [PATCH 10/10] 0.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9dc642..af8c439 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vue/tsconfig", - "version": "0.5.1", + "version": "0.6.0", "description": "A base TSConfig for working with Vue.js", "main": "tsconfig.json", "scripts": { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy