mirror of https://github.com/sveltejs/svelte
feat: support type annotations in `{@const ...}` tag (#9609)
* support type for const tag * use expression directly * lint * format * format * revert * legacy mode * format * revert and update .prettierignorepull/9667/head
parent
075c268f42
commit
da1aa7c4a8
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': minor
|
||||
---
|
||||
|
||||
feat: support type definition in {@const}
|
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<p>10 * 10 = 100</p><p>20 * 20 = 400</p>'
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script lang="ts">
|
||||
const boxes = [ { width: 10, height: 10 }, { width: 20, height: 20 } ];
|
||||
</script>
|
||||
|
||||
{#each boxes as box}
|
||||
{@const area: number = box.width * box.height}
|
||||
<p>{box.width} * {box.height} = {area}</p>
|
||||
{/each}
|
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<p>{}</p>'
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
<script lang="ts">
|
||||
</script>
|
||||
|
||||
{@const name: string = "{}"}
|
||||
<p>{name}</p>
|
Loading…
Reference in new issue