docs: Don't recommend TypeScript type assertions for reactive declarations (#8824)

strictly speaking that's not the same and could hide some type errors
pull/8859/head
Not-Jayden 2 years ago committed by GitHub
parent 2a93ca9172
commit e3422e182b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -176,16 +176,14 @@ You cannot type your reactive declarations with TypeScript in the way you type a
</script>
```
You cannot add a `: TYPE` because it's invalid syntax in this position. Instead, you can use the `as` or move the definition to a `let` statement just above:
You cannot add a `: TYPE` because it's invalid syntax in this position. Instead, you can move the definition to a `let` statement just above:
```svelte
<script lang="ts">
let count = 0;
$: option1 = (count * 2) as number;
let option2: number;
$: option2 = count * 2;
let doubled: number;
$: doubled = count * 2;
</script>
```

Loading…
Cancel
Save