From 8cac84ddf953a88f32c295abedaed8429d936603 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei Da" Date: Mon, 11 Mar 2024 17:50:04 +0800 Subject: [PATCH 1/7] bump ts to 5.4.2 --- package.json | 2 +- .../features/DiagnosticsProvider.ts | 15 ++++-- .../src/plugins/typescript/module-loader.ts | 2 +- .../fixtures/style-directive/expectedv2.json | 4 +- .../component-handler/expectedv2.json | 4 +- .../fixtures/element-handler/expectedv2.json | 12 ++--- packages/svelte-vscode/package.json | 2 +- packages/svelte2tsx/package.json | 2 +- packages/typescript-plugin/package.json | 2 +- pnpm-lock.yaml | 48 +++++++++---------- 10 files changed, 49 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index abeb14d72..a9c94dfc7 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "lint": "prettier --check ." }, "dependencies": { - "typescript": "^5.3.2" + "typescript": "^5.4.2" }, "devDependencies": { "cross-env": "^7.0.2", diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts index c5f9c6aa4..77570cd3b 100644 --- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts @@ -543,11 +543,16 @@ function expectedTransitionThirdArgument( return false; } - const callExpression = findNodeAtSpan( - node, - { start: node.getStart(), length: node.getWidth() }, - ts.isCallExpression - ); + // in TypeScript 5.4 the error is on the function name + // in earlier versions it's on the whole call expression + const callExpression = ts.isCallExpression(node.parent) + ? node.parent + : findNodeAtSpan( + node, + { start: node.getStart(), length: node.getWidth() }, + ts.isCallExpression + ); + const signature = callExpression && lang.getProgram()?.getTypeChecker().getResolvedSignature(callExpression); diff --git a/packages/language-server/src/plugins/typescript/module-loader.ts b/packages/language-server/src/plugins/typescript/module-loader.ts index 4eefdc700..305b61abd 100644 --- a/packages/language-server/src/plugins/typescript/module-loader.ts +++ b/packages/language-server/src/plugins/typescript/module-loader.ts @@ -102,7 +102,7 @@ class ImpliedNodeFormatResolver { let mode = undefined; if (sourceFile) { this.cacheImpliedNodeFormat(sourceFile, compilerOptions); - mode = ts.getModeForResolutionAtIndex(sourceFile, importIdxInFile); + mode = ts.getModeForResolutionAtIndex(sourceFile, importIdxInFile, compilerOptions); } return mode; } diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json index cc0a854be..7463797a3 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json @@ -6,7 +6,7 @@ }, "severity": 1, "source": "ts", - "message": "Argument of type 'boolean' is not assignable to parameter of type 'String | Number | null | undefined'.", + "message": "Argument of type 'true' is not assignable to parameter of type 'String | Number | null | undefined'.", "code": 2345, "tags": [] }, @@ -17,7 +17,7 @@ }, "severity": 1, "source": "ts", - "message": "Argument of type 'boolean' is not assignable to parameter of type 'String | Number | null | undefined'.", + "message": "Argument of type 'true' is not assignable to parameter of type 'String | Number | null | undefined'.", "code": 2345, "tags": [] } 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 7d567c1c2..56478c66d 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": 15586, "character": 10 }, - "end": { "line": 15586, "character": 20 } + "start": { "line": 15692, "character": 10 }, + "end": { "line": 15692, "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 f736e622c..86a02a272 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": 15586, "character": 10 }, - "end": { "line": 15586, "character": 20 } + "start": { "line": 15692, "character": 10 }, + "end": { "line": 15692, "character": 20 } }, "uri": "/typescript/lib/lib.dom.d.ts" } @@ -21,8 +21,8 @@ "value": "EventTarget", "location": { "range": { - "start": { "line": 8192, "character": 10 }, - "end": { "line": 8192, "character": 21 } + "start": { "line": 8237, "character": 10 }, + "end": { "line": 8237, "character": 21 } }, "uri": "/typescript/lib/lib.dom.d.ts" } @@ -32,8 +32,8 @@ "value": "HTMLButtonElement", "location": { "range": { - "start": { "line": 9684, "character": 10 }, - "end": { "line": 9684, "character": 27 } + "start": { "line": 9732, "character": 10 }, + "end": { "line": 9732, "character": 27 } }, "uri": "/typescript/lib/lib.dom.d.ts" } diff --git a/packages/svelte-vscode/package.json b/packages/svelte-vscode/package.json index 4306e6b65..3ca420f03 100644 --- a/packages/svelte-vscode/package.json +++ b/packages/svelte-vscode/package.json @@ -719,7 +719,7 @@ "@types/vscode": "^1.67", "js-yaml": "^3.14.0", "tslib": "^2.4.0", - "typescript": "^5.3.2", + "typescript": "^5.4.2", "vscode-tmgrammar-test": "^0.0.11" }, "dependencies": { diff --git a/packages/svelte2tsx/package.json b/packages/svelte2tsx/package.json index 4c226dc9f..81ee05c7d 100644 --- a/packages/svelte2tsx/package.json +++ b/packages/svelte2tsx/package.json @@ -40,7 +40,7 @@ "svelte": "~3.57.0", "tiny-glob": "^0.2.6", "tslib": "^2.4.0", - "typescript": "^5.3.2" + "typescript": "^5.4.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 e47708ffa..2ba655e3b 100644 --- a/packages/typescript-plugin/package.json +++ b/packages/typescript-plugin/package.json @@ -19,7 +19,7 @@ "license": "MIT", "devDependencies": { "@types/node": "^16.0.0", - "typescript": "^5.3.2" + "typescript": "^5.4.2" }, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.14", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 612bda377..cbe162631 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: typescript: - specifier: ^5.3.2 - version: 5.3.2 + specifier: ^5.4.2 + version: 5.4.2 devDependencies: cross-env: specifier: ^7.0.2 @@ -20,7 +20,7 @@ importers: version: 3.2.5 ts-node: specifier: ^10.0.0 - version: 10.9.1(@types/node@16.18.32)(typescript@5.3.2) + version: 10.9.1(@types/node@16.18.32)(typescript@5.4.2) packages/language-server: dependencies: @@ -53,13 +53,13 @@ importers: version: 3.57.0 svelte-preprocess: specifier: ^5.1.3 - version: 5.1.3(svelte@3.57.0)(typescript@5.3.2) + version: 5.1.3(svelte@3.57.0)(typescript@5.4.2) svelte2tsx: specifier: workspace:~ version: link:../svelte2tsx typescript: specifier: ^5.3.2 - version: 5.3.2 + version: 5.4.2 typescript-auto-import-cache: specifier: ^0.3.2 version: 0.3.2 @@ -111,7 +111,7 @@ importers: version: 11.1.2 ts-node: specifier: ^10.0.0 - version: 10.9.1(@types/node@16.18.32)(typescript@5.3.2) + version: 10.9.1(@types/node@16.18.32)(typescript@5.4.2) packages/svelte-check: dependencies: @@ -138,10 +138,10 @@ importers: version: 3.57.0 svelte-preprocess: specifier: ^5.1.3 - version: 5.1.3(svelte@3.57.0)(typescript@5.3.2) + version: 5.1.3(svelte@3.57.0)(typescript@5.4.2) typescript: specifier: ^5.0.3 - version: 5.3.2 + version: 5.4.2 devDependencies: '@rollup/plugin-commonjs': specifier: ^24.0.0 @@ -157,7 +157,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.3.2) + version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.4.2) '@types/sade': specifier: ^1.7.2 version: 1.7.4 @@ -223,8 +223,8 @@ importers: specifier: ^2.4.0 version: 2.5.2 typescript: - specifier: ^5.3.2 - version: 5.3.2 + specifier: ^5.4.2 + version: 5.4.2 vscode-tmgrammar-test: specifier: ^0.0.11 version: 0.0.11 @@ -255,7 +255,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.3.2) + version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.4.2) '@types/estree': specifier: ^0.0.42 version: 0.0.42 @@ -305,8 +305,8 @@ importers: specifier: ^2.4.0 version: 2.5.2 typescript: - specifier: ^5.3.2 - version: 5.3.2 + specifier: ^5.4.2 + version: 5.4.2 packages/typescript-plugin: dependencies: @@ -321,8 +321,8 @@ importers: specifier: ^16.0.0 version: 16.18.32 typescript: - specifier: ^5.3.2 - version: 5.3.2 + specifier: ^5.4.2 + version: 5.4.2 packages: @@ -458,7 +458,7 @@ packages: rollup: 3.7.5 dev: true - /@rollup/plugin-typescript@10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.3.2): + /@rollup/plugin-typescript@10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.4.2): resolution: {integrity: sha512-wBykxRLlX7EzL8BmUqMqk5zpx2onnmRMSw/l9M1sVfkJvdwfxogZQVNUM9gVMJbjRLDR5H6U0OMOrlDGmIV45A==} engines: {node: '>=14.0.0'} peerDependencies: @@ -475,7 +475,7 @@ packages: resolve: 1.22.2 rollup: 3.7.5 tslib: 2.5.2 - typescript: 5.3.2 + typescript: 5.4.2 dev: true /@rollup/pluginutils@5.0.2(rollup@3.7.5): @@ -1832,7 +1832,7 @@ packages: engines: {node: '>= 0.4'} dev: true - /svelte-preprocess@5.1.3(svelte@3.57.0)(typescript@5.3.2): + /svelte-preprocess@5.1.3(svelte@3.57.0)(typescript@5.4.2): resolution: {integrity: sha512-xxAkmxGHT+J/GourS5mVJeOXZzne1FR5ljeOUAMXUkfEhkLEllRreXpbl3dIYJlcJRfL1LO1uIAPpBpBfiqGPw==} engines: {node: '>= 16.0.0', pnpm: ^8.0.0} requiresBuild: true @@ -1876,7 +1876,7 @@ packages: sorcery: 0.11.0 strip-indent: 3.0.0 svelte: 3.57.0 - typescript: 5.3.2 + typescript: 5.4.2 dev: false /svelte@3.57.0: @@ -1896,7 +1896,7 @@ packages: dependencies: is-number: 7.0.0 - /ts-node@10.9.1(@types/node@16.18.32)(typescript@5.3.2): + /ts-node@10.9.1(@types/node@16.18.32)(typescript@5.4.2): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -1922,7 +1922,7 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.3.2 + typescript: 5.4.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true @@ -1941,8 +1941,8 @@ packages: semver: 7.5.1 dev: false - /typescript@5.3.2: - resolution: {integrity: sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==} + /typescript@5.4.2: + resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} engines: {node: '>=14.17'} hasBin: true From b4d7fa20fba324f56e47ec7b1daf66e564d78ce6 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei Da" Date: Thu, 14 Mar 2024 09:02:10 +0800 Subject: [PATCH 2/7] assign to bound variable for ts 5.4 to widen to control flow --- .../fixtures/bind-union/Component.svelte | 5 +++ .../fixtures/bind-union/expectedv2.json | 1 + .../fixtures/bind-union/input.svelte | 18 ++++++++ .../src/htmlxtojsx_v2/nodes/Binding.ts | 5 +++ .../samples/binding-bare/expectedv2.js | 4 +- .../htmlx2jsx/samples/binding/expectedv2.js | 6 +-- .../samples/directive-quoted/expectedv2.js | 2 +- .../samples/editing-binding/expectedv2.js | 4 +- .../samples/component-props/mappings.jsx | 38 ++++++++--------- .../samples/element-attributes/mappings.jsx | 42 +++++++++---------- .../samples/large-sample-1/mappings.jsx | 24 +++++------ .../binding-assignment-$store/expectedv2.ts | 4 +- 12 files changed, 91 insertions(+), 62 deletions(-) create mode 100644 packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/Component.svelte create mode 100644 packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json create mode 100644 packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/input.svelte diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/Component.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/Component.svelte new file mode 100644 index 000000000..bef74c544 --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/Component.svelte @@ -0,0 +1,5 @@ + + + diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/input.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/input.svelte new file mode 100644 index 000000000..43ae46b8b --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/input.svelte @@ -0,0 +1,18 @@ + + + + +{#if checked === true} + checked +{/if} + +{#if value === 'bar'} + bar +{/if} + + \ No newline at end of file diff --git a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts index 31a01ea39..e0474e357 100644 --- a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts +++ b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts @@ -94,6 +94,11 @@ export function handleBinding( return; } + const expressionStr = str.original.substring(attr.expression.start, getEnd(attr.expression)); + element.appendToStartEnd([ + surroundWithIgnoreComments(`() => ${expressionStr} = __sveltets_2_any(null);`) + ]); + // other bindings which are transformed to normal attributes/props const isShorthand = attr.expression.start === attr.start + 'bind:'.length; const name: TransformationArray = diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/binding-bare/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/binding-bare/expectedv2.js index bfef43414..0b1b0af3e 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/binding-bare/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/binding-bare/expectedv2.js @@ -1,2 +1,2 @@ - { svelteHTML.createElement("input", { "type":`text`,"bind:value":value,});} - { svelteHTML.createElement("input", { "type":`checkbox`,"bind:checked":checked,});} \ No newline at end of file + { svelteHTML.createElement("input", { "type":`text`,"bind:value":value,});/*Ωignore_startΩ*/() => value = __sveltets_2_any(null);/*Ωignore_endΩ*/} + { svelteHTML.createElement("input", { "type":`checkbox`,"bind:checked":checked,});/*Ωignore_startΩ*/() => checked = __sveltets_2_any(null);/*Ωignore_endΩ*/} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/binding/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/binding/expectedv2.js index 41ce94abb..e386fcd48 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/binding/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/binding/expectedv2.js @@ -1,3 +1,3 @@ - { svelteHTML.createElement("input", { "type":`text`,"bind:value":test,});} - { svelteHTML.createElement("input", { "type":`text`,"bind:value":test,});} - { svelteHTML.createElement("input", { "type":`text`,"bind:value":test,});} \ No newline at end of file + { svelteHTML.createElement("input", { "type":`text`,"bind:value":test,});/*Ωignore_startΩ*/() => test = __sveltets_2_any(null);/*Ωignore_endΩ*/} + { svelteHTML.createElement("input", { "type":`text`,"bind:value":test,});/*Ωignore_startΩ*/() => test = __sveltets_2_any(null);/*Ωignore_endΩ*/} + { svelteHTML.createElement("input", { "type":`text`,"bind:value":test,});/*Ωignore_startΩ*/() => test = __sveltets_2_any(null);/*Ωignore_endΩ*/} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js index 57df4fdb0..869a203b9 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js @@ -4,4 +4,4 @@ { svelteHTML.createElement("img", { });__sveltets_2_ensureTransition(fade(svelteHTML.mapElementTag('img'),(params)));} { svelteHTML.createElement("img", { });classthing;} { svelteHTML.createElement("img", { });__sveltets_2_ensureAnimation(thing(svelteHTML.mapElementTag('img'),__sveltets_2_AnimationMove,(params)));} - { svelteHTML.createElement("img", { "bind:thing":binding,});} \ No newline at end of file + { svelteHTML.createElement("img", { "bind:thing":binding,});/*Ωignore_startΩ*/() => binding = __sveltets_2_any(null);/*Ωignore_endΩ*/} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-binding/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-binding/expectedv2.js index d568573db..84c329d67 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-binding/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-binding/expectedv2.js @@ -1,3 +1,3 @@ { svelteHTML.createElement("input", { });obj.;} - { svelteHTML.createElement("input", { "bind:value":obj.,});} - { const $$_tupnI0C = __sveltets_2_ensureComponent(Input); new $$_tupnI0C({ target: __sveltets_2_any(), props: { value:obj.,}});} \ No newline at end of file + { svelteHTML.createElement("input", { "bind:value":obj.,});/*Ωignore_startΩ*/() => obj = __sveltets_2_any(null);/*Ωignore_endΩ*/} + { const $$_tupnI0C = __sveltets_2_ensureComponent(Input); new $$_tupnI0C({ target: __sveltets_2_any(), props: { value:obj.,}});/*Ωignore_startΩ*/() => obj = __sveltets_2_any(null);/*Ωignore_endΩ*/} \ No newline at end of file diff --git a/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx index 0c0b579df..86889cddc 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx @@ -54,25 +54,25 @@ async•()•=>•{••{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureCom {/** ------------------------------------------------------------------------------------------------------------------------------------------------------ */} - { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { foo:bar,}});} {/** -•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});}↲ [generated] line 11 -•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{ [generated] subset -< Component -↲ [original] line 13 + { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { foo:bar,}});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}{/** +•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 11 +•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{ [generated] subset +< Component +•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 11 + •• foo:bar,}});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/} [generated] subset + b{ foo=bar} + #= Order-breaking mappings + b foo={bar} +╚bind:foo={bar}↲ [original] line 12 + +•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 11 + • ↲ [generated] subset + / ↲ +/ ↲ +/>↲ [original] line 13 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** diff --git a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx index 2946a8661..7ef16bb3f 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx @@ -99,46 +99,46 @@ async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});} {/** ------------------------------------------------------------------------------------------------------------------------------------------------------ */} - { svelteHTML.createElement("element", { "bind:foo":foo,});} {/** -•{•svelteHTML.createElement("element",•{••"bind:foo":foo,});}↲ [generated] line 13 -•{•svelteHTML.createElement("element",•{ "bind:foo": [generated] subset + { svelteHTML.createElement("element", { "bind:foo":foo,});/*Ωignore_startΩ*/() => foo = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/** +•{•svelteHTML.createElement("element",•{••"bind:foo":foo,});/*Ωignore_startΩ*/()•=>•foo•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 13 +•{•svelteHTML.createElement("element",•{ "bind:foo": [generated] subset < element ↲ •foo•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 13 + • foo,});/*Ωignore_startΩ*/()•=>•foo•=•__sveltets_2_any(null);/*Ωignore_endΩ*/} [generated] subset • foo• • foo• -••••bind:foo•↲ [original] line 20 +••••bind:foo•↲ [original] line 20 -•{•svelteHTML.createElement("element",•{••"bind:foo":foo,});}↲ [generated] line 13 - • ↲ [generated] subset - / ↲ +•{•svelteHTML.createElement("element",•{••"bind:foo":foo,});/*Ωignore_startΩ*/()•=>•foo•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 13 + • ↲ [generated] subset + / ↲ / ↲ -/>↲ [original] line 21 +/>↲ [original] line 21 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** ------------------------------------------------------------------------------------------------------------------------------------------------------ */} - { svelteHTML.createElement("element", { "bind:foo":bar,});}}; {/** -•{•svelteHTML.createElement("element",•{••"bind:foo":bar,});}};↲ [generated] line 15 -•{•svelteHTML.createElement("element",•{ "bind:foo": [generated] subset + { svelteHTML.createElement("element", { "bind:foo":bar,});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}}; {/** +•{•svelteHTML.createElement("element",•{••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 15 +•{•svelteHTML.createElement("element",•{ "bind:foo": [generated] subset < element ↲ •bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 15 + • bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] subset • bar} • bar} -••••bind:foo={bar}↲ [original] line 24 +••••bind:foo={bar}↲ [original] line 24 -•{•svelteHTML.createElement("element",•{••"bind:foo":bar,});}};↲ [generated] line 15 - • [generated] subset +•{•svelteHTML.createElement("element",•{••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 15 + • [generated] subset / / -/> [original] line 25 +/> [original] line 25 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} return { props: /** @type {Record} */ ({}), slots: {}, events: {} }} diff --git a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx index 13d0d2485..dd6cc6ee5 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx @@ -328,12 +328,12 @@ s ↲ {/** ------------------------------------------------------------------------------------------------------------------------------------------------------ */} - { svelteHTML.createElement("svelte:window", { "bind:innerWidth":width,});} {/** -••{•svelteHTML.createElement("svelte:window",•{•"bind:innerWidth":width,});}↲ [generated] line 133 -<> ib width} ↲ - #=============================================# Order-breaking mappings -< bi width} >↲ -↲ [original] line 269 + { svelteHTML.createElement("svelte:window", { "bind:innerWidth":width,});/*Ωignore_startΩ*/() => width = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/** +••{•svelteHTML.createElement("svelte:window",•{•"bind:innerWidth":width,});/*Ωignore_startΩ*/()•=>•width•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 133 +<> ib width} ↲ + #=============================================# Order-breaking mappings +< bi width} >↲ +↲ [original] line 269 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** @@ -640,12 +640,12 @@ s ↲ { mobile}↲ ╚{#if•mobile}↲ [original] line 316 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} - { const $$_elggoTneercS1C = __sveltets_2_ensureComponent(ScreenToggle); new $$_elggoTneercS1C({ target: __sveltets_2_any(), props: { offset,"labels":['tutorial', 'input', 'output'],}});}{/** - ╚╚••{•const•$$_elggoTneercS1C•=•__sveltets_2_ensureComponent(ScreenToggle);•new•$$_elggoTneercS1C({•target:•__sveltets_2_any(),•props:•{••offset,"labels":['tutorial',•'input',•'output'],}});}↲ [generated] line 170 - ╚╚<> ScreenToggle i{offset•l abels= ['tutorial',•'input',•'output']} ↲ - #========================================================= # Order-breaking mappings - ╚╚↲ - ╚╚↲ [original] line 317 + { const $$_elggoTneercS1C = __sveltets_2_ensureComponent(ScreenToggle); new $$_elggoTneercS1C({ target: __sveltets_2_any(), props: { offset,"labels":['tutorial', 'input', 'output'],}});/*Ωignore_startΩ*/() => offset = __sveltets_2_any(null);/*Ωignore_endΩ*/}{/** + ╚╚••{•const•$$_elggoTneercS1C•=•__sveltets_2_ensureComponent(ScreenToggle);•new•$$_elggoTneercS1C({•target:•__sveltets_2_any(),•props:•{••offset,"labels":['tutorial',•'input',•'output'],}});/*Ωignore_startΩ*/()•=>•offset•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 170 + ╚╚<> ScreenToggle i{offset•l abels= ['tutorial',•'input',•'output']} ↲ + #========================================================= # Order-breaking mappings + ╚╚↲ + ╚╚↲ [original] line 317 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** ╚}↲ [generated] line 171 diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/binding-assignment-$store/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/binding-assignment-$store/expectedv2.ts index 9bce5e2b7..2b1baf659 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/binding-assignment-$store/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/binding-assignment-$store/expectedv2.ts @@ -4,8 +4,8 @@ async () => { { const $$_div0 = svelteHTML.createElement("div", { });$compile_o { const $$_div0 = svelteHTML.createElement("div", { });$compile_options.foo= $$_div0.offsetHeight;} { const $$_div0 = svelteHTML.createElement("div", { });$compile_options = $$_div0;} { const $$_div0 = svelteHTML.createElement("div", { });$compile_options.foo = $$_div0;} - { svelteHTML.createElement("div", { "bind:noAssignment":$compile_options,});} - { svelteHTML.createElement("div", { "bind:noAssignment":$compile_options.foo,});}}; + { svelteHTML.createElement("div", { "bind:noAssignment":$compile_options,});/*Ωignore_startΩ*/() => $compile_options = __sveltets_2_any(null);/*Ωignore_endΩ*/} + { svelteHTML.createElement("div", { "bind:noAssignment":$compile_options.foo,});/*Ωignore_startΩ*/() => $compile_options.foo = __sveltets_2_any(null);/*Ωignore_endΩ*/}}; return { props: /** @type {Record} */ ({}), slots: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event(render()))) { From 4076d6136f278b47852907fbde45c086ba0623a5 Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Sat, 16 Mar 2024 09:31:12 +0800 Subject: [PATCH 3/7] format --- .../features/diagnostics/fixtures/bind-union/expectedv2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json index 0637a088a..fe51488c7 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bind-union/expectedv2.json @@ -1 +1 @@ -[] \ No newline at end of file +[] From 35510ed4a0cdc33cdc51512088cfb1b33f4ec64d Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Sat, 16 Mar 2024 12:44:21 +0800 Subject: [PATCH 4/7] oops this doesn't work in 5.3 --- .../typescript/features/DiagnosticsProvider.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts index 77570cd3b..64223ac35 100644 --- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts @@ -545,13 +545,14 @@ function expectedTransitionThirdArgument( // in TypeScript 5.4 the error is on the function name // in earlier versions it's on the whole call expression - const callExpression = ts.isCallExpression(node.parent) - ? node.parent - : findNodeAtSpan( - node, - { start: node.getStart(), length: node.getWidth() }, - ts.isCallExpression - ); + const callExpression = + ts.isIdentifier(node) && ts.isCallExpression(node.parent) + ? node.parent + : findNodeAtSpan( + node, + { start: node.getStart(), length: node.getWidth() }, + ts.isCallExpression + ); const signature = callExpression && lang.getProgram()?.getTypeChecker().getResolvedSignature(callExpression); From 2095372b10bbadb20a4c64cee46451ea7ed7db79 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei Da" Date: Mon, 18 Mar 2024 12:57:32 +0800 Subject: [PATCH 5/7] revert bumping but keeps compatibility fixes --- package.json | 2 +- packages/language-server/package.json | 2 +- .../src/plugins/typescript/module-loader.ts | 1 + .../fixtures/style-directive/expectedv2.json | 4 +- .../component-handler/expectedv2.json | 4 +- .../fixtures/element-handler/expectedv2.json | 12 ++--- packages/svelte-vscode/package.json | 2 +- packages/svelte2tsx/package.json | 2 +- packages/typescript-plugin/package.json | 2 +- pnpm-lock.yaml | 48 +++++++++---------- 10 files changed, 40 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index a9c94dfc7..abeb14d72 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "lint": "prettier --check ." }, "dependencies": { - "typescript": "^5.4.2" + "typescript": "^5.3.2" }, "devDependencies": { "cross-env": "^7.0.2", diff --git a/packages/language-server/package.json b/packages/language-server/package.json index 45de36a36..8908da6e5 100644 --- a/packages/language-server/package.json +++ b/packages/language-server/package.json @@ -57,7 +57,7 @@ "svelte": "^3.57.0", "svelte-preprocess": "^5.1.3", "svelte2tsx": "workspace:~", - "typescript": "^5.3.2", + "typescript": "~5.3.2", "typescript-auto-import-cache": "^0.3.2", "vscode-css-languageservice": "~6.2.10", "vscode-html-languageservice": "~5.1.1", diff --git a/packages/language-server/src/plugins/typescript/module-loader.ts b/packages/language-server/src/plugins/typescript/module-loader.ts index 305b61abd..b681978bf 100644 --- a/packages/language-server/src/plugins/typescript/module-loader.ts +++ b/packages/language-server/src/plugins/typescript/module-loader.ts @@ -102,6 +102,7 @@ class ImpliedNodeFormatResolver { let mode = undefined; if (sourceFile) { this.cacheImpliedNodeFormat(sourceFile, compilerOptions); + // @ts-expect-error remove when bumping to TS 5.4 mode = ts.getModeForResolutionAtIndex(sourceFile, importIdxInFile, compilerOptions); } return mode; diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json index 7463797a3..cc0a854be 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/style-directive/expectedv2.json @@ -6,7 +6,7 @@ }, "severity": 1, "source": "ts", - "message": "Argument of type 'true' is not assignable to parameter of type 'String | Number | null | undefined'.", + "message": "Argument of type 'boolean' is not assignable to parameter of type 'String | Number | null | undefined'.", "code": 2345, "tags": [] }, @@ -17,7 +17,7 @@ }, "severity": 1, "source": "ts", - "message": "Argument of type 'true' is not assignable to parameter of type 'String | Number | null | undefined'.", + "message": "Argument of type 'boolean' is not assignable to parameter of type 'String | Number | null | undefined'.", "code": 2345, "tags": [] } 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 56478c66d..7d567c1c2 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": 15692, "character": 10 }, - "end": { "line": 15692, "character": 20 } + "start": { "line": 15586, "character": 10 }, + "end": { "line": 15586, "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 86a02a272..f736e622c 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": 15692, "character": 10 }, - "end": { "line": 15692, "character": 20 } + "start": { "line": 15586, "character": 10 }, + "end": { "line": 15586, "character": 20 } }, "uri": "/typescript/lib/lib.dom.d.ts" } @@ -21,8 +21,8 @@ "value": "EventTarget", "location": { "range": { - "start": { "line": 8237, "character": 10 }, - "end": { "line": 8237, "character": 21 } + "start": { "line": 8192, "character": 10 }, + "end": { "line": 8192, "character": 21 } }, "uri": "/typescript/lib/lib.dom.d.ts" } @@ -32,8 +32,8 @@ "value": "HTMLButtonElement", "location": { "range": { - "start": { "line": 9732, "character": 10 }, - "end": { "line": 9732, "character": 27 } + "start": { "line": 9684, "character": 10 }, + "end": { "line": 9684, "character": 27 } }, "uri": "/typescript/lib/lib.dom.d.ts" } diff --git a/packages/svelte-vscode/package.json b/packages/svelte-vscode/package.json index 3ca420f03..250a8063a 100644 --- a/packages/svelte-vscode/package.json +++ b/packages/svelte-vscode/package.json @@ -719,7 +719,7 @@ "@types/vscode": "^1.67", "js-yaml": "^3.14.0", "tslib": "^2.4.0", - "typescript": "^5.4.2", + "typescript": "~5.3.2", "vscode-tmgrammar-test": "^0.0.11" }, "dependencies": { diff --git a/packages/svelte2tsx/package.json b/packages/svelte2tsx/package.json index 81ee05c7d..4c226dc9f 100644 --- a/packages/svelte2tsx/package.json +++ b/packages/svelte2tsx/package.json @@ -40,7 +40,7 @@ "svelte": "~3.57.0", "tiny-glob": "^0.2.6", "tslib": "^2.4.0", - "typescript": "^5.4.2" + "typescript": "^5.3.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 2ba655e3b..e47708ffa 100644 --- a/packages/typescript-plugin/package.json +++ b/packages/typescript-plugin/package.json @@ -19,7 +19,7 @@ "license": "MIT", "devDependencies": { "@types/node": "^16.0.0", - "typescript": "^5.4.2" + "typescript": "^5.3.2" }, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.14", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cbe162631..578ebef6e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: typescript: - specifier: ^5.4.2 - version: 5.4.2 + specifier: ^5.3.2 + version: 5.3.2 devDependencies: cross-env: specifier: ^7.0.2 @@ -20,7 +20,7 @@ importers: version: 3.2.5 ts-node: specifier: ^10.0.0 - version: 10.9.1(@types/node@16.18.32)(typescript@5.4.2) + version: 10.9.1(@types/node@16.18.32)(typescript@5.3.2) packages/language-server: dependencies: @@ -53,13 +53,13 @@ importers: version: 3.57.0 svelte-preprocess: specifier: ^5.1.3 - version: 5.1.3(svelte@3.57.0)(typescript@5.4.2) + version: 5.1.3(svelte@3.57.0)(typescript@5.3.2) svelte2tsx: specifier: workspace:~ version: link:../svelte2tsx typescript: specifier: ^5.3.2 - version: 5.4.2 + version: 5.3.2 typescript-auto-import-cache: specifier: ^0.3.2 version: 0.3.2 @@ -111,7 +111,7 @@ importers: version: 11.1.2 ts-node: specifier: ^10.0.0 - version: 10.9.1(@types/node@16.18.32)(typescript@5.4.2) + version: 10.9.1(@types/node@16.18.32)(typescript@5.3.2) packages/svelte-check: dependencies: @@ -138,10 +138,10 @@ importers: version: 3.57.0 svelte-preprocess: specifier: ^5.1.3 - version: 5.1.3(svelte@3.57.0)(typescript@5.4.2) + version: 5.1.3(svelte@3.57.0)(typescript@5.3.2) typescript: specifier: ^5.0.3 - version: 5.4.2 + version: 5.3.2 devDependencies: '@rollup/plugin-commonjs': specifier: ^24.0.0 @@ -157,7 +157,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.4.2) + version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.3.2) '@types/sade': specifier: ^1.7.2 version: 1.7.4 @@ -223,8 +223,8 @@ importers: specifier: ^2.4.0 version: 2.5.2 typescript: - specifier: ^5.4.2 - version: 5.4.2 + specifier: ~5.3.2 + version: 5.3.2 vscode-tmgrammar-test: specifier: ^0.0.11 version: 0.0.11 @@ -255,7 +255,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.4.2) + version: 10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.3.2) '@types/estree': specifier: ^0.0.42 version: 0.0.42 @@ -305,8 +305,8 @@ importers: specifier: ^2.4.0 version: 2.5.2 typescript: - specifier: ^5.4.2 - version: 5.4.2 + specifier: ^5.3.2 + version: 5.3.2 packages/typescript-plugin: dependencies: @@ -321,8 +321,8 @@ importers: specifier: ^16.0.0 version: 16.18.32 typescript: - specifier: ^5.4.2 - version: 5.4.2 + specifier: ^5.3.2 + version: 5.3.2 packages: @@ -458,7 +458,7 @@ packages: rollup: 3.7.5 dev: true - /@rollup/plugin-typescript@10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.4.2): + /@rollup/plugin-typescript@10.0.1(rollup@3.7.5)(tslib@2.5.2)(typescript@5.3.2): resolution: {integrity: sha512-wBykxRLlX7EzL8BmUqMqk5zpx2onnmRMSw/l9M1sVfkJvdwfxogZQVNUM9gVMJbjRLDR5H6U0OMOrlDGmIV45A==} engines: {node: '>=14.0.0'} peerDependencies: @@ -475,7 +475,7 @@ packages: resolve: 1.22.2 rollup: 3.7.5 tslib: 2.5.2 - typescript: 5.4.2 + typescript: 5.3.2 dev: true /@rollup/pluginutils@5.0.2(rollup@3.7.5): @@ -1832,7 +1832,7 @@ packages: engines: {node: '>= 0.4'} dev: true - /svelte-preprocess@5.1.3(svelte@3.57.0)(typescript@5.4.2): + /svelte-preprocess@5.1.3(svelte@3.57.0)(typescript@5.3.2): resolution: {integrity: sha512-xxAkmxGHT+J/GourS5mVJeOXZzne1FR5ljeOUAMXUkfEhkLEllRreXpbl3dIYJlcJRfL1LO1uIAPpBpBfiqGPw==} engines: {node: '>= 16.0.0', pnpm: ^8.0.0} requiresBuild: true @@ -1876,7 +1876,7 @@ packages: sorcery: 0.11.0 strip-indent: 3.0.0 svelte: 3.57.0 - typescript: 5.4.2 + typescript: 5.3.2 dev: false /svelte@3.57.0: @@ -1896,7 +1896,7 @@ packages: dependencies: is-number: 7.0.0 - /ts-node@10.9.1(@types/node@16.18.32)(typescript@5.4.2): + /ts-node@10.9.1(@types/node@16.18.32)(typescript@5.3.2): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -1922,7 +1922,7 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.4.2 + typescript: 5.3.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true @@ -1941,8 +1941,8 @@ packages: semver: 7.5.1 dev: false - /typescript@5.4.2: - resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} + /typescript@5.3.2: + resolution: {integrity: sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==} engines: {node: '>=14.17'} hasBin: true From 87ae79260e5bbcaa91a58b0ea465d9476b17bbec Mon Sep 17 00:00:00 2001 From: "Lyu, Wei Da" Date: Mon, 18 Mar 2024 12:58:59 +0800 Subject: [PATCH 6/7] lock --- pnpm-lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 578ebef6e..9734f0359 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -58,7 +58,7 @@ importers: specifier: workspace:~ version: link:../svelte2tsx typescript: - specifier: ^5.3.2 + specifier: ~5.3.2 version: 5.3.2 typescript-auto-import-cache: specifier: ^0.3.2 From bbc69e1938689f7ba7fcbb4b94594b6f6ad5dbdb Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:43:24 +0100 Subject: [PATCH 7/7] Update packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts --- packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts index e0474e357..b4c6add56 100644 --- a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts +++ b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts @@ -94,6 +94,7 @@ export function handleBinding( return; } + // add reassignment to force TS to widen the type of the declaration (in case it's never reassigned anywhere else) const expressionStr = str.original.substring(attr.expression.start, getEnd(attr.expression)); element.appendToStartEnd([ surroundWithIgnoreComments(`() => ${expressionStr} = __sveltets_2_any(null);`)