From 3f2da5db0a58f0fd6b25c78ff1418a77c6795493 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei-Da" <36730922+jasonlyu123@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:09:39 +0800 Subject: [PATCH] feat: TypeScript 5.7 support (#2585) * feat: typescript 5.7 support * bumps to stable * update svelte 5 snapshot --- package.json | 2 +- packages/language-server/package.json | 2 +- .../typescript/features/CompletionProvider.ts | 6 ++- .../input.svelte | 6 +-- .../each-anytype/input.svelte | 5 ++ .../component-invalid/expected_svelte_5.json | 2 +- .../component-invalid/expectedv2.json | 2 +- .../fixtures/const-tag-if/expectedv2.json | 16 +++---- .../fixtures/const-tag-if/input.svelte | 8 +++- .../fixtures/unInitialized/expectedv2.json | 18 +++++++- .../fixtures/unInitialized/input.svelte | 15 +++++- .../component-handler/expectedv2.json | 4 +- .../fixtures/element-handler/expectedv2.json | 12 ++--- packages/svelte-check/package.json | 2 +- packages/svelte-vscode/package.json | 2 +- packages/svelte2tsx/package.json | 2 +- packages/typescript-plugin/package.json | 2 +- pnpm-lock.yaml | 46 +++++++++---------- 18 files changed, 97 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 78483ce60..b74048576 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "lint": "prettier --check ." }, "dependencies": { - "typescript": "~5.6.3" + "typescript": "^5.7.2" }, "devDependencies": { "cross-env": "^7.0.2", diff --git a/packages/language-server/package.json b/packages/language-server/package.json index 3021cb374..616962025 100644 --- a/packages/language-server/package.json +++ b/packages/language-server/package.json @@ -62,7 +62,7 @@ "prettier-plugin-svelte": "^3.3.0", "svelte": "^4.2.19", "svelte2tsx": "workspace:~", - "typescript": "~5.6.3", + "typescript": "^5.7.2", "typescript-auto-import-cache": "^0.3.5", "vscode-css-languageservice": "~6.3.0", "vscode-html-languageservice": "~5.3.0", diff --git a/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts b/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts index 2d6eee0eb..3bdbf4b1c 100644 --- a/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts @@ -807,7 +807,11 @@ export class CompletionsProviderImpl implements CompletionsProvider - - - \ No newline at end of file + + + diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/checkjs-nostrict/each-anytype/input.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/checkjs-nostrict/each-anytype/input.svelte index ff088e6d2..26b3e1b84 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/checkjs-nostrict/each-anytype/input.svelte +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/checkjs-nostrict/each-anytype/input.svelte @@ -1,5 +1,10 @@ {#each anyType as anyEntry} diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected_svelte_5.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected_svelte_5.json index aaa50c91c..df76add1c 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected_svelte_5.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected_svelte_5.json @@ -17,7 +17,7 @@ }, "severity": 1, "source": "ts", - "message": "Type 'boolean' is not assignable to type 'never'.", + "message": "Type 'true' is not assignable to type 'never'.", "code": 2322, "tags": [] }, diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json index e07ee0dc1..dcb9a3737 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json @@ -17,7 +17,7 @@ }, "severity": 1, "source": "ts", - "message": "Type 'boolean' is not assignable to type 'never'.", + "message": "Type 'true' is not assignable to type 'never'.", "code": 2322, "tags": [] }, diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/expectedv2.json index 8018999c4..ce8069af7 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/expectedv2.json @@ -1,8 +1,8 @@ [ { "range": { - "start": { "line": 21, "character": 19 }, - "end": { "line": 21, "character": 26 } + "start": { "line": 25, "character": 19 }, + "end": { "line": 25, "character": 26 } }, "severity": 1, "source": "ts", @@ -12,8 +12,8 @@ }, { "range": { - "start": { "line": 21, "character": 40 }, - "end": { "line": 21, "character": 47 } + "start": { "line": 25, "character": 40 }, + "end": { "line": 25, "character": 47 } }, "severity": 1, "source": "ts", @@ -23,8 +23,8 @@ }, { "range": { - "start": { "line": 23, "character": 11 }, - "end": { "line": 23, "character": 20 } + "start": { "line": 27, "character": 11 }, + "end": { "line": 27, "character": 20 } }, "severity": 1, "source": "ts", @@ -34,8 +34,8 @@ }, { "range": { - "start": { "line": 25, "character": 11 }, - "end": { "line": 25, "character": 18 } + "start": { "line": 29, "character": 11 }, + "end": { "line": 29, "character": 18 } }, "severity": 1, "source": "ts", diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/input.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/input.svelte index 0682ac5c0..04cc35743 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/input.svelte +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/const-tag-if/input.svelte @@ -1,5 +1,9 @@ @@ -9,7 +13,7 @@
{valueStr.substring(0)}{valueStr2.substring(0)}
- + {:else if typeof value === 'number'} {value.toFixed()} {/if} @@ -24,4 +28,4 @@ {value.substring(0)} {:else} {value.toFixed()} -{/if} \ No newline at end of file +{/if} diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/expectedv2.json index ad3362b5f..97a8fe2c6 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/expectedv2.json @@ -1,6 +1,22 @@ [ { - "range": { "start": { "line": 3, "character": 4 }, "end": { "line": 3, "character": 6 } }, + "range": { "start": { "line": 5, "character": 4 }, "end": { "line": 5, "character": 6 } }, + "severity": 1, + "source": "ts", + "message": "Variable 'hi' is used before being assigned.", + "code": 2454, + "tags": [] + }, + { + "range": { "start": { "line": 7, "character": 4 }, "end": { "line": 7, "character": 7 } }, + "severity": 1, + "source": "ts", + "message": "Variable 'hi3' is used before being assigned.", + "code": 2454, + "tags": [] + }, + { + "range": { "start": { "line": 16, "character": 1 }, "end": { "line": 16, "character": 3 } }, "severity": 1, "source": "ts", "message": "Variable 'hi' is used before being assigned.", diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/input.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/input.svelte index 7c09c1f04..f566c0e34 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/input.svelte +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/unInitialized/input.svelte @@ -1,6 +1,19 @@ -{hi} \ No newline at end of file +{hi} +{hi2} +{hi3} diff --git a/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/component-handler/expectedv2.json b/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/component-handler/expectedv2.json index bedfb19dd..614c9f646 100644 --- a/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/component-handler/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/component-handler/expectedv2.json @@ -12,8 +12,8 @@ "value": "MouseEvent", "location": { "range": { - "start": { "line": 15340, "character": 10 }, - "end": { "line": 15340, "character": 20 } + "start": { "line": 16152, "character": 10 }, + "end": { "line": 16152, "character": 20 } }, "uri": "/typescript/lib/lib.dom.d.ts" } diff --git a/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/element-handler/expectedv2.json b/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/element-handler/expectedv2.json index 22ffb1aa7..eccc501c8 100644 --- a/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/element-handler/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/inlayHints/fixtures/element-handler/expectedv2.json @@ -6,8 +6,8 @@ "value": "MouseEvent", "location": { "range": { - "start": { "line": 15340, "character": 10 }, - "end": { "line": 15340, "character": 20 } + "start": { "line": 16152, "character": 10 }, + "end": { "line": 16152, "character": 20 } }, "uri": "/typescript/lib/lib.dom.d.ts" } @@ -21,8 +21,8 @@ "value": "EventTarget", "location": { "range": { - "start": { "line": 8284, "character": 10 }, - "end": { "line": 8284, "character": 21 } + "start": { "line": 8694, "character": 10 }, + "end": { "line": 8694, "character": 21 } }, "uri": "/typescript/lib/lib.dom.d.ts" } @@ -32,8 +32,8 @@ "value": "HTMLButtonElement", "location": { "range": { - "start": { "line": 9721, "character": 10 }, - "end": { "line": 9721, "character": 27 } + "start": { "line": 10145, "character": 10 }, + "end": { "line": 10145, "character": 27 } }, "uri": "/typescript/lib/lib.dom.d.ts" } diff --git a/packages/svelte-check/package.json b/packages/svelte-check/package.json index df5d66db3..3d6c82829 100644 --- a/packages/svelte-check/package.json +++ b/packages/svelte-check/package.json @@ -54,7 +54,7 @@ "rollup-plugin-copy": "^3.4.0", "svelte": "^4.2.19", "svelte-language-server": "workspace:*", - "typescript": "~5.6.3", + "typescript": "^5.7.2", "vscode-languageserver": "8.0.2", "vscode-languageserver-protocol": "3.17.2", "vscode-languageserver-types": "3.17.2", diff --git a/packages/svelte-vscode/package.json b/packages/svelte-vscode/package.json index 30ab2dd03..a357e9637 100644 --- a/packages/svelte-vscode/package.json +++ b/packages/svelte-vscode/package.json @@ -732,7 +732,7 @@ "@types/vscode": "^1.67", "js-yaml": "^3.14.0", "tslib": "^2.4.0", - "typescript": "~5.6.3", + "typescript": "^5.7.2", "vscode-tmgrammar-test": "^0.0.11" }, "dependencies": { diff --git a/packages/svelte2tsx/package.json b/packages/svelte2tsx/package.json index c608983da..4797af3bc 100644 --- a/packages/svelte2tsx/package.json +++ b/packages/svelte2tsx/package.json @@ -40,7 +40,7 @@ "svelte": "~4.2.19", "tiny-glob": "^0.2.6", "tslib": "^2.4.0", - "typescript": "~5.6.3" + "typescript": "^5.7.2" }, "peerDependencies": { "svelte": "^3.55 || ^4.0.0-next.0 || ^4.0 || ^5.0.0-next.0", diff --git a/packages/typescript-plugin/package.json b/packages/typescript-plugin/package.json index 9f41a5dfe..0cb00eb55 100644 --- a/packages/typescript-plugin/package.json +++ b/packages/typescript-plugin/package.json @@ -24,7 +24,7 @@ "license": "MIT", "devDependencies": { "@types/node": "^18.0.0", - "typescript": "~5.6.3", + "typescript": "^5.7.2", "svelte": "^4.2.19" }, "dependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e27e7797..6745c3f39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ^5.7.2 + version: 5.7.2 devDependencies: cross-env: specifier: ^7.0.2 @@ -20,7 +20,7 @@ importers: version: 3.3.3 ts-node: specifier: ^10.0.0 - version: 10.9.1(@types/node@18.19.46)(typescript@5.6.3) + version: 10.9.1(@types/node@18.19.46)(typescript@5.7.2) packages/language-server: dependencies: @@ -58,8 +58,8 @@ importers: specifier: workspace:~ version: link:../svelte2tsx typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ^5.7.2 + version: 5.7.2 typescript-auto-import-cache: specifier: ^0.3.5 version: 0.3.5 @@ -111,7 +111,7 @@ importers: version: 11.1.2 ts-node: specifier: ^10.0.0 - version: 10.9.1(@types/node@18.19.46)(typescript@5.6.3) + version: 10.9.1(@types/node@18.19.46)(typescript@5.7.2) packages/svelte-check: dependencies: @@ -145,7 +145,7 @@ importers: version: 5.0.2(rollup@3.7.5) '@rollup/plugin-typescript': specifier: ^10.0.0 - version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.6.3) + version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.7.2) '@types/sade': specifier: ^1.7.2 version: 1.7.4 @@ -168,8 +168,8 @@ importers: specifier: workspace:* version: link:../language-server typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ^5.7.2 + version: 5.7.2 vscode-languageserver: specifier: 8.0.2 version: 8.0.2 @@ -217,8 +217,8 @@ importers: specifier: ^2.4.0 version: 2.5.2 typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ^5.7.2 + version: 5.7.2 vscode-tmgrammar-test: specifier: ^0.0.11 version: 0.0.11 @@ -249,7 +249,7 @@ importers: version: 15.0.2(rollup@3.7.5) '@rollup/plugin-typescript': specifier: ^10.0.0 - version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.6.3) + version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.7.2) '@types/estree': specifier: ^0.0.42 version: 0.0.42 @@ -299,8 +299,8 @@ importers: specifier: ^2.4.0 version: 2.5.2 typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ^5.7.2 + version: 5.7.2 packages/typescript-plugin: dependencies: @@ -318,8 +318,8 @@ importers: specifier: ^4.2.19 version: 4.2.19 typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ^5.7.2 + version: 5.7.2 packages: @@ -1281,8 +1281,8 @@ packages: typescript-auto-import-cache@0.3.5: resolution: {integrity: sha512-fAIveQKsoYj55CozUiBoj4b/7WpN0i4o74wiGY5JVUEoD0XiqDk1tJqTEjgzL2/AizKQrXxyRosSebyDzBZKjw==} - typescript@5.6.3: - resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==} + typescript@5.7.2: + resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} engines: {node: '>=14.17'} hasBin: true @@ -1496,11 +1496,11 @@ snapshots: optionalDependencies: rollup: 3.7.5 - '@rollup/plugin-typescript@10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.6.3)': + '@rollup/plugin-typescript@10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.7.2)': dependencies: '@rollup/pluginutils': 5.0.2(rollup@3.7.5) resolve: 1.22.2 - typescript: 5.6.3 + typescript: 5.7.2 optionalDependencies: rollup: 3.7.5 tslib: 2.5.2 @@ -2329,7 +2329,7 @@ snapshots: dependencies: is-number: 7.0.0 - ts-node@10.9.1(@types/node@18.19.46)(typescript@5.6.3): + ts-node@10.9.1(@types/node@18.19.46)(typescript@5.7.2): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.9 @@ -2343,7 +2343,7 @@ snapshots: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.6.3 + typescript: 5.7.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 @@ -2355,7 +2355,7 @@ snapshots: dependencies: semver: 7.5.1 - typescript@5.6.3: {} + typescript@5.7.2: {} undici-types@5.26.5: {}