From c54abf134690737b620ed67265dd817211041fd3 Mon Sep 17 00:00:00 2001 From: Richard Russell <2265225+rars@users.noreply.github.com> Date: Mon, 15 Jun 2026 20:32:29 +0100 Subject: [PATCH] feat(diff-match-patch-ts): target es2022 and use TypeScript 6 --- package-lock.json | 8 ++++---- package.json | 26 ++++++++++++++------------ src/diff-match-patch.class.ts | 12 ++++++------ tsconfig.json | 11 ++++++----- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index b02ad6f..bc8e5c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "standard-version": "^9.3.2", "ts-loader": "^9.4.2", "ts-node": "^10.9.1", - "typescript": "~5.9.0", + "typescript": "~6.0.3", "typescript-eslint": "^8.7.0" } }, @@ -12903,9 +12903,9 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index e130bc3..fc8b516 100644 --- a/package.json +++ b/package.json @@ -3,19 +3,21 @@ "version": "1.0.0", "description": "Port of diff-match-patch to TypeScript.", "exports": { - "import": { - "types": "./index.d.ts", - "default": "./diff-match-patch-ts.mjs" - }, - "require": { - "types": "./index.d.ts", - "default": "./diff-match-patch-ts.cjs" + ".": { + "import": { + "types": "./index.d.ts", + "default": "./diff-match-patch-ts.mjs" + }, + "require": { + "types": "./index.d.ts", + "default": "./diff-match-patch-ts.cjs" + } } }, - "main": "diff-match-patch-ts.cjs", - "module": "diff-match-patch-ts.mjs", - "browser": "diff-match-patch-ts.umd.js", - "types": "index.d.ts", + "main": "./diff-match-patch-ts.cjs", + "module": "./diff-match-patch-ts.mjs", + "browser": "./diff-match-patch-ts.umd.js", + "types": "./index.d.ts", "scripts": { "build": "rimraf dist && rollup -c rollup.config.mjs && copyfiles package.json README.md LICENSE.md dist", "test": "jest", @@ -67,7 +69,7 @@ "standard-version": "^9.3.2", "ts-loader": "^9.4.2", "ts-node": "^10.9.1", - "typescript": "~5.9.0", + "typescript": "~6.0.3", "typescript-eslint": "^8.7.0" }, "config": { diff --git a/src/diff-match-patch.class.ts b/src/diff-match-patch.class.ts index abffb76..844aaa0 100644 --- a/src/diff-match-patch.class.ts +++ b/src/diff-match-patch.class.ts @@ -781,9 +781,9 @@ export class DiffMatchPatch { line = decodeURI(text[textPointer].substring(1)); } catch (_ex) { // Malformed URI sequence. - // TODO: remove this lint suppression once _ex is added as cause after updating target to es2022 - // eslint-disable-next-line preserve-caught-error - throw new Error('Illegal escape in patch_fromText: ' + line); + throw new Error('Illegal escape in patch_fromText: ' + line, { + cause: _ex, + }); } if (sign === '-') { // Deletion. @@ -1884,9 +1884,9 @@ export class DiffMatchPatch { diffs[diffsLength++] = [DiffOp.Insert, decodeURI(param)]; } catch (_ex) { // Malformed URI sequence. - // TODO: remove this lint rule suppression once cause is added and target is es2022. - // eslint-disable-next-line preserve-caught-error - throw new Error('Illegal escape in diff_fromDelta: ' + param); + throw new Error('Illegal escape in diff_fromDelta: ' + param, { + cause: _ex, + }); } break; } diff --git a/tsconfig.json b/tsconfig.json index b76d10c..245b40a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,14 @@ { "compilerOptions": { - "target": "es6", + "rootDir": "./src", + "target": "es2022", "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "strict": true, "declaration": true, + "declarationMap": true, "outDir": "./dist", - "lib": ["es6"] + "lib": ["ES2022"] }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "include": ["src/**/*"] }