Merge branch 'main' into svelte-custom-renderer

pull/18505/head
Paolo Ricciuti 2 weeks ago committed by GitHub
commit 7c5b06657c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: include wrapping parentheses in `{@const}` declarator `end` position

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: don't notify `searchParams` subscribers when the URL changes without affecting the search string

@ -1,5 +1,17 @@
# svelte
## 5.56.4
### Patch Changes
- fix: include wrapping parentheses in `{@const}` declarator `end` position ([#18436](https://github.com/sveltejs/svelte/pull/18436))
- fix: always unset reactivity context after restoring it ([#18453](https://github.com/sveltejs/svelte/pull/18453))
- fix: don't notify `searchParams` subscribers when the URL changes without affecting the search string ([#18425](https://github.com/sveltejs/svelte/pull/18425))
- fix: strip `?` from optional parameters in `<script lang="ts">` so generated JavaScript is valid ([#18448](https://github.com/sveltejs/svelte/pull/18448))
## 5.56.3
### Patch Changes

@ -2,7 +2,7 @@
"name": "svelte",
"description": "Cybernetically enhanced web apps",
"license": "MIT",
"version": "5.56.3",
"version": "5.56.4",
"type": "module",
"types": "./types/index.d.ts",
"engines": {
@ -188,7 +188,7 @@
"clsx": "^2.1.1",
"devalue": "^5.8.1",
"esm-env": "^1.2.1",
"esrap": "^2.2.11",
"esrap": "^2.2.12",
"is-reference": "^3.0.3",
"locate-character": "^3.0.0",
"magic-string": "^0.30.11",

@ -30,6 +30,12 @@ const visitors = {
delete n.readonly;
delete n.definite;
delete n.override;
// `optional` is reused by JS optional chaining (`a?.b`, `a?.()`), so only
// strip the TypeScript optional marker (`x?: T`, `m?(): T`, `x?: T` fields)
if (n.type !== 'MemberExpression' && n.type !== 'CallExpression') {
delete n.optional;
}
},
Decorator(node) {
e.typescript_invalid_feature(node, 'decorators (related TSC proposal is not stage 4 yet)');

@ -26,6 +26,7 @@ import {
set_reactivity_loss_tracker
} from './deriveds.js';
import { aborted } from './effects.js';
import { queue_micro_task } from '../dom/task.js';
/**
* @param {Blocker[]} blockers
@ -173,6 +174,7 @@ export async function save(promise) {
return () => {
restore();
queue_micro_task(unset_context);
return value;
};
}

@ -4,5 +4,5 @@
* The current version, as set in package.json.
* @type {string}
*/
export const VERSION = '5.56.3';
export const VERSION = '5.56.4';
export const PUBLIC_VERSION = '5';

@ -0,0 +1,44 @@
import { tick } from 'svelte';
import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
dev: true
},
async test({ assert, target, errors }) {
await tick();
const [increment, update, resolve] = target.querySelectorAll('button');
increment.click();
await tick();
resolve.click();
await tick();
update.click();
await tick();
resolve.click();
await tick();
assert.deepEqual(
errors.filter((error) => error.includes('state_unsafe_mutation')),
[]
);
assert.htmlEqual(
target.innerHTML,
`
<button>increment</button>
<button>update</button>
<button>resolve</button>
<p>count: 1</p>
<p>submits: 1</p>
<p>pending: 0</p>
<p>2</p>
`
);
}
});

@ -0,0 +1,28 @@
<script>
const queued = [];
function push(value) {
if(!value) return value;
return new Promise((resolve) => queued.push(() => resolve(value)));
}
let count = $state(0);
let submits = $state(0);
const a = $derived(push(count));
const b = $derived(push(count));
async function updateAfterPromise() {
await Promise.resolve();
submits += 1;
}
</script>
<button onclick={() => (count += 1)}>increment</button>
<button onclick={updateAfterPromise}>update</button>
<button onclick={() => queued.shift()?.()}>resolve</button>
<p>count: {count}</p>
<p>submits: {submits}</p>
<p>pending: {$effect.pending()}</p>
<p>{await a + await b}</p>

@ -0,0 +1,22 @@
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';
export default function Typescript_optional_parameter($$anchor) {
// the `?` on the optional parameter must be stripped, but optional chaining
// (`x?.length`, `o?.b`) must be preserved
function a(x) {
return x?.length;
}
const o = {};
const v = o?.b?.c;
a();
$.next();
var text = $.text();
$.template_effect(() => $.set_text(text, v));
$.append($$anchor, text);
}

@ -0,0 +1,15 @@
import * as $ from 'svelte/internal/server';
export default function Typescript_optional_parameter($$renderer) {
// the `?` on the optional parameter must be stripped, but optional chaining
// (`x?.length`, `o?.b`) must be preserved
function a(x) {
return x?.length;
}
const o = {};
const v = o?.b?.c;
a();
$$renderer.push(`<!---->${$.escape(v)}`);
}

@ -0,0 +1,14 @@
<script lang="ts">
// the `?` on the optional parameter must be stripped, but optional chaining
// (`x?.length`, `o?.b`) must be preserved
function a(x?: string) {
return x?.length;
}
const o: { b?: { c: number } } = {};
const v = o?.b?.c;
a();
</script>
{v}

@ -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:

Loading…
Cancel
Save