mirror of https://github.com/sveltejs/svelte
fix: allow ts casts in bindings (#10181)
fixes #10179 --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/10233/head
parent
2861ad66e0
commit
0071e0252a
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: allow ts casts in bindings
|
@ -1,5 +1,6 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '1 2'
|
||||
html: '1 2 <div></div> <input type="number"> <input type="number">',
|
||||
ssrHtml: '1 2 <div></div> <input type="number" value="1"> <input type="number" value="2">'
|
||||
});
|
||||
|
@ -1,6 +1,14 @@
|
||||
<script lang="ts">
|
||||
let count = $state(1) as number;
|
||||
let double = $derived(count as number * 2) as number;
|
||||
|
||||
let element = null;
|
||||
let with_state = $state({ foo: 1 });
|
||||
let without_state = { foo: 2 };
|
||||
</script>
|
||||
|
||||
{count as number} {double as number}
|
||||
|
||||
<div bind:this={element as HTMLElement}></div>
|
||||
<input type="number" bind:value={(with_state as { foo: number }).foo} />
|
||||
<input type="number" bind:value={(without_state as { foo: number }).foo as number} />
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '1 2'
|
||||
html: '1 2 <input type="number">'
|
||||
});
|
||||
|
@ -1,6 +1,9 @@
|
||||
<script lang="ts">
|
||||
let count = $state(1)!;
|
||||
let double = $derived(count! * 2)!;
|
||||
let binding = $state(null);
|
||||
</script>
|
||||
|
||||
{count!} {double!}
|
||||
|
||||
<input type="number" bind:value={binding!} />
|
||||
|
Loading…
Reference in new issue