From a6985bcd24faa8ec4a8de671b2013d98b0bc629f Mon Sep 17 00:00:00 2001 From: "jyc.dev" Date: Mon, 22 Jun 2026 13:03:18 +0200 Subject: [PATCH] fix: strip `?` from optional parameters in svelte lang ts (#18448) In `esrap@2.2.12` we fixed the missing `?` in ts files https://github.com/sveltejs/esrap/pull/139 It's good for `ts`, but bad for svelte compiler that was not removing it as it was a esrap issue not printing it :/ This issue came: https://github.com/sveltejs/esrap/issues/141 This PR is fixing the issue in the compiler stripping the `?` --- .changeset/strip-optional-param-marker.md | 5 +++++ packages/svelte/package.json | 2 +- .../phases/1-parse/remove_typescript_nodes.js | 6 +++++ .../_expected/client/index.svelte.js | 22 +++++++++++++++++++ .../_expected/server/index.svelte.js | 15 +++++++++++++ .../index.svelte | 14 ++++++++++++ pnpm-lock.yaml | 12 +++++----- 7 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 .changeset/strip-optional-param-marker.md create mode 100644 packages/svelte/tests/snapshot/samples/typescript-optional-parameter/_expected/client/index.svelte.js create mode 100644 packages/svelte/tests/snapshot/samples/typescript-optional-parameter/_expected/server/index.svelte.js create mode 100644 packages/svelte/tests/snapshot/samples/typescript-optional-parameter/index.svelte diff --git a/.changeset/strip-optional-param-marker.md b/.changeset/strip-optional-param-marker.md new file mode 100644 index 0000000000..a6b759747c --- /dev/null +++ b/.changeset/strip-optional-param-marker.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: strip `?` from optional parameters in ` + +{v} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e86c927efe..6331fd0789 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,8 +102,8 @@ importers: specifier: ^1.2.1 version: 1.2.1 esrap: - specifier: ^2.2.11 - version: 2.2.11(@typescript-eslint/types@8.59.4) + specifier: ^2.2.12 + version: 2.2.12(@typescript-eslint/types@8.59.4) is-reference: specifier: ^3.0.3 version: 3.0.3 @@ -1418,8 +1418,8 @@ packages: resolution: {integrity: sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==} engines: {node: '>=0.10'} - esrap@2.2.11: - resolution: {integrity: sha512-gPdx+I+BjYEinNMQaBXFjbaJVyoPMU4ZODg5mE+M4DqVG9VusAVHHjcBX+zqyITlI0DIARwDMMzZwAWj36dRoQ==} + esrap@2.2.12: + resolution: {integrity: sha512-On0QbLyaiAkVC4eXtgnXK9Kh2opit+3rcUSOc45DqJ2s/X2eXAHsGOKRSJ6IDagQEW5vPyivANfXUiqgXC67Rw==} peerDependencies: '@typescript-eslint/types': ^8.2.0 peerDependenciesMeta: @@ -2886,7 +2886,7 @@ snapshots: '@jridgewell/gen-mapping@0.3.5': dependencies: '@jridgewell/set-array': 1.2.1 - '@jridgewell/sourcemap-codec': 1.5.0 + '@jridgewell/sourcemap-codec': 1.5.5 '@jridgewell/trace-mapping': 0.3.31 '@jridgewell/remapping@2.3.4': @@ -3695,7 +3695,7 @@ snapshots: dependencies: estraverse: 5.3.0 - esrap@2.2.11(@typescript-eslint/types@8.59.4): + esrap@2.2.12(@typescript-eslint/types@8.59.4): dependencies: '@jridgewell/sourcemap-codec': 1.5.5 optionalDependencies: