From 6f806be0aec8b7d0f71605ef2a8060bd510b135d Mon Sep 17 00:00:00 2001 From: Brandon Cheng Date: Sat, 27 Dec 2025 05:23:49 -0500 Subject: [PATCH] chore: enable TypeScript's `erasableSyntaxOnly` config (#10365) * chore: configure `erasableSyntaxOnly` * refactor: remove class property access modifiers in constructor ``` ../dedupe/check/src/DedupeCheckIssuesError.ts:5:16 - error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. 5 constructor (public dedupeCheckIssues: DedupeCheckIssues) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../reviewing/dependencies-hierarchy/src/getTree.ts:243:24 - error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. 243 private constructor (private readonly keypath: readonly string[]) {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` * chore: migrate from enum types ``` ../pkg-manager/plugin-commands-installation/src/import/index.ts:66:6 - error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. 66 enum YarnLockType { ~~~~~~~~~~~~ ../lockfile/detect-dep-types/src/index.ts:5:13 - error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. 5 export enum DepType { ~~~~~~~ ``` * chore: add changelog * chore: remove `ts-node` dev dependency (#10371) * chore: remove `ts-node` dev dependency * chore: remove `ts-node` usages from `package.json` scripts --- .changeset/seven-turtles-attack.md | 9 +++++ __utils__/get-release-text/package.json | 2 +- __utils__/tsconfig/tsconfig.json | 1 + config/config/package.json | 1 - dedupe/check/src/DedupeCheckIssuesError.ts | 5 ++- lockfile/detect-dep-types/src/index.ts | 12 +++--- package.json | 5 +-- .../src/import/index.ts | 12 +++--- pnpm-lock.yaml | 37 +++++++++++-------- pnpm-workspace.yaml | 1 - pnpm/package.json | 2 +- .../dependencies-hierarchy/src/getTree.ts | 6 ++- 12 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 .changeset/seven-turtles-attack.md diff --git a/.changeset/seven-turtles-attack.md b/.changeset/seven-turtles-attack.md new file mode 100644 index 0000000000..7ffc09e8a1 --- /dev/null +++ b/.changeset/seven-turtles-attack.md @@ -0,0 +1,9 @@ +--- +"@pnpm/plugin-commands-installation": patch +"@pnpm/reviewing.dependencies-hierarchy": patch +"@pnpm/lockfile.detect-dep-types": patch +"@pnpm/dedupe.check": patch +pnpm: patch +--- + +Removed TypeScript specific syntax (such as enums and visibility modifiers in constructors) to enable `erasableSyntaxOnly`. diff --git a/__utils__/get-release-text/package.json b/__utils__/get-release-text/package.json index ba4def14c6..381e3d9b5b 100644 --- a/__utils__/get-release-text/package.json +++ b/__utils__/get-release-text/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "scripts": { - "write-release-text": "node --loader ts-node/esm src/main.ts", + "write-release-text": "node src/main.ts", "lint": "eslint src/**/*.ts" }, "dependencies": { diff --git a/__utils__/tsconfig/tsconfig.json b/__utils__/tsconfig/tsconfig.json index 062b7cebf1..3d542f5dc0 100644 --- a/__utils__/tsconfig/tsconfig.json +++ b/__utils__/tsconfig/tsconfig.json @@ -3,6 +3,7 @@ "allowSyntheticDefaultImports": true, "composite": true, "declaration": true, + "erasableSyntaxOnly": true, "esModuleInterop": true, "module": "nodenext", "moduleResolution": "nodenext", diff --git a/config/config/package.json b/config/config/package.json index 6fa248985a..248ad5e611 100644 --- a/config/config/package.json +++ b/config/config/package.json @@ -27,7 +27,6 @@ "scripts": { "prepublishOnly": "pnpm run compile", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "test-with-preview": "ts-node test", "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "start": "tsc --watch", diff --git a/dedupe/check/src/DedupeCheckIssuesError.ts b/dedupe/check/src/DedupeCheckIssuesError.ts index 557f5fee8d..9b9e7bb005 100644 --- a/dedupe/check/src/DedupeCheckIssuesError.ts +++ b/dedupe/check/src/DedupeCheckIssuesError.ts @@ -2,7 +2,10 @@ import { type DedupeCheckIssues } from '@pnpm/dedupe.types' import { PnpmError } from '@pnpm/error' export class DedupeCheckIssuesError extends PnpmError { - constructor (public dedupeCheckIssues: DedupeCheckIssues) { + public dedupeCheckIssues: DedupeCheckIssues + + constructor (dedupeCheckIssues: DedupeCheckIssues) { super('DEDUPE_CHECK_ISSUES', 'Dedupe --check found changes to the lockfile') + this.dedupeCheckIssues = dedupeCheckIssues } } diff --git a/lockfile/detect-dep-types/src/index.ts b/lockfile/detect-dep-types/src/index.ts index f52af434aa..bb9bfbe3a2 100644 --- a/lockfile/detect-dep-types/src/index.ts +++ b/lockfile/detect-dep-types/src/index.ts @@ -2,11 +2,13 @@ import { type LockfileObject, type PackageSnapshots, type ResolvedDependencies } import * as dp from '@pnpm/dependency-path' import { type DepPath } from '@pnpm/types' -export enum DepType { - DevOnly, - DevAndProd, - ProdOnly -} +export const DepType = { + DevOnly: 0, + DevAndProd: 1, + ProdOnly: 2, +} as const + +export type DepType = (typeof DepType)[keyof typeof DepType] export type DepTypes = Record diff --git a/package.json b/package.json index 93f65d28c8..03c631e8a6 100644 --- a/package.json +++ b/package.json @@ -15,14 +15,14 @@ "test-pkgs-main": "pnpm remove-temp-dir && pnpm run --no-sort --workspace-concurrency=1 -r _test", "test-branch": "pnpm pretest && pnpm lint && git remote set-branches --add origin main && git fetch origin main && pnpm run test-pkgs-branch", "test-pkgs-branch": "pnpm remove-temp-dir && pnpm --workspace-concurrency=1 --filter=...[origin/main] run --no-sort _test", - "compile-only": "pnpm --config.useNodeVersion=24.6.0 exec ts-node __utils__/scripts/src/typecheck-only.ts && pnpm -F pnpm compile", + "compile-only": "pnpm --config.useNodeVersion=24.6.0 node __utils__/scripts/src/typecheck-only.ts && pnpm -F pnpm compile", "compile": "pnpm compile-only && pnpm run update-manifests", "watch": "pnpm --filter=@pnpm/fetch run compile && pnpm --filter=pnpm run compile --watch", "make-lcov": "shx mkdir -p coverage && lcov-result-merger './packages/*/coverage/lcov.info' 'coverage/lcov.info'", "update-manifests": "pnpm run meta-updater && pnpm install", "meta-updater": "pnpm --filter=@pnpm-private/updater compile && pnpm exec meta-updater", "lint:meta": "pnpm run meta-updater --test", - "copy-artifacts": "ts-node __utils__/scripts/src/copy-artifacts.ts", + "copy-artifacts": "node __utils__/scripts/src/copy-artifacts.ts", "make-release-description": "pnpm --filter=@pnpm/get-release-text run write-release-text", "release": "pnpm --filter=@pnpm/exe publish --tag=next-11 --access=public && pnpm publish --filter=!pnpm --filter=!@pnpm/exe --access=public && pnpm publish --filter=pnpm --tag=next-11 --access=public", "dev-setup": "pnpm -C=./pnpm/dev link -g" @@ -56,7 +56,6 @@ "rimraf": "catalog:", "shx": "catalog:", "ts-jest": "catalog:", - "ts-node": "catalog:", "typescript": "catalog:", "verdaccio": "catalog:" }, diff --git a/pkg-manager/plugin-commands-installation/src/import/index.ts b/pkg-manager/plugin-commands-installation/src/import/index.ts index 55acf42089..055e03dc88 100644 --- a/pkg-manager/plugin-commands-installation/src/import/index.ts +++ b/pkg-manager/plugin-commands-installation/src/import/index.ts @@ -63,14 +63,16 @@ interface YarnPackageLock { [name: string]: YarnLockPackage } -enum YarnLockType { - yarn = 'yarn', - yarn2 = 'yarn2' -} +const YarnLockType = { + yarn: 'yarn', + yarn2: 'yarn2', +} as const + +type YarnLockType = (typeof YarnLockType)[keyof typeof YarnLockType] // copy from yarn v1 interface YarnLock2Struct { - type: YarnLockType.yarn2 + type: typeof YarnLockType.yarn2 object: YarnPackageLock } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2ad4d26289..f237c83828 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -732,9 +732,6 @@ catalogs: ts-jest-resolver: specifier: 2.0.1 version: 2.0.1 - ts-node: - specifier: ^10.9.2 - version: 10.9.2 typescript: specifier: 5.9.2 version: 5.9.2 @@ -921,9 +918,6 @@ importers: ts-jest: specifier: 'catalog:' version: 29.4.1(@babel/core@7.28.3)(@jest/transform@30.0.5(@babel/types@7.28.2))(@jest/types@30.0.5)(babel-jest@30.0.5(@babel/core@7.28.3)(@babel/types@7.28.2))(jest-util@30.0.5)(jest@30.0.5(@babel/types@7.28.2)(@types/node@22.15.30)(ts-node@10.9.2(@types/node@22.15.30)(typescript@5.9.2)))(typescript@5.9.2) - ts-node: - specifier: 'catalog:' - version: 10.9.2(@types/node@22.15.30)(typescript@5.9.2) typescript: specifier: 'catalog:' version: 5.9.2 @@ -17513,6 +17507,7 @@ snapshots: '@cspotcode/source-map-support@0.8.1': dependencies: '@jridgewell/trace-mapping': 0.3.9 + optional: true '@cypress/request@3.0.9': dependencies: @@ -17937,6 +17932,7 @@ snapshots: dependencies: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 + optional: true '@manypkg/find-root@1.1.0': dependencies: @@ -19255,13 +19251,17 @@ snapshots: dependencies: defer-to-connect: 2.0.1 - '@tsconfig/node10@1.0.11': {} + '@tsconfig/node10@1.0.11': + optional: true - '@tsconfig/node12@1.0.11': {} + '@tsconfig/node12@1.0.11': + optional: true - '@tsconfig/node14@1.0.3': {} + '@tsconfig/node14@1.0.3': + optional: true - '@tsconfig/node16@1.0.4': {} + '@tsconfig/node16@1.0.4': + optional: true '@tybys/wasm-util@0.10.0': dependencies: @@ -20069,6 +20069,7 @@ snapshots: acorn-walk@8.3.4: dependencies: acorn: 8.14.1 + optional: true acorn@8.14.1: {} @@ -20186,7 +20187,8 @@ snapshots: readable-stream: 2.3.8 optional: true - arg@4.1.3: {} + arg@4.1.3: + optional: true argparse@1.0.10: dependencies: @@ -20844,7 +20846,8 @@ snapshots: optionalDependencies: typescript: 5.9.2 - create-require@1.1.1: {} + create-require@1.1.1: + optional: true cross-env@10.0.0: dependencies: @@ -21099,7 +21102,8 @@ snapshots: fastest-levenshtein: 1.0.16 lodash.deburr: 4.1.0 - diff@4.0.2: {} + diff@4.0.2: + optional: true diff@5.2.0: {} @@ -25323,6 +25327,7 @@ snapshots: typescript: 5.9.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 + optional: true ts-toolbelt@9.6.0: {} @@ -25557,7 +25562,8 @@ snapshots: uuid@9.0.1: {} - v8-compile-cache-lib@3.0.1: {} + v8-compile-cache-lib@3.0.1: + optional: true v8-compile-cache@2.4.0: {} @@ -25965,7 +25971,8 @@ snapshots: dependencies: buffer-crc32: 1.0.0 - yn@3.1.1: {} + yn@3.1.1: + optional: true yocto-queue@0.1.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 43ba4fd0fd..777fd6090a 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -302,7 +302,6 @@ catalog: tree-kill: ^1.2.2 ts-jest: 29.4.1 ts-jest-resolver: 2.0.1 - ts-node: ^10.9.2 typescript: 5.9.2 unified: ^9.2.2 uuid: ^9.0.1 diff --git a/pnpm/package.json b/pnpm/package.json index 491010f274..e0e590a335 100644 --- a/pnpm/package.json +++ b/pnpm/package.json @@ -58,7 +58,7 @@ }, "unpkg": "dist/pnpm.mjs", "scripts": { - "bundle": "pnpm --config.useNodeVersion=24.6.0 exec ts-node bundle.ts", + "bundle": "pnpm --config.useNodeVersion=24.6.0 node bundle.ts", "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "pretest:e2e": "rimraf node_modules/.bin/pnpm", diff --git a/reviewing/dependencies-hierarchy/src/getTree.ts b/reviewing/dependencies-hierarchy/src/getTree.ts index 8f35b01925..2459ba0ed8 100644 --- a/reviewing/dependencies-hierarchy/src/getTree.ts +++ b/reviewing/dependencies-hierarchy/src/getTree.ts @@ -240,7 +240,11 @@ function getTreeHelper ( * Useful for detecting cycles. */ class Keypath { - private constructor (private readonly keypath: readonly string[]) {} + private readonly keypath: readonly string[] + + private constructor (keypath: readonly string[]) { + this.keypath = keypath + } public static initialize (treeNodeId: TreeNodeId): Keypath { return new Keypath([serializeTreeNodeId(treeNodeId)])