-
-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.feature requestNew feature or requestNew feature or request
Description
Reactive fields (If thats that fields marked with $: are) are always any And this causes problems with noImplicitAny (And with regular intellisense)
tsconfig.json
{
"compilerOptions": {
"noImplicitAny": true,
}
}app.svelte
<script lang="ts">
let value = 1;
$: foo = value ? 'foo' : 'bar'; // foo is `any` here instead of the correct `string`
</script>
{#if value}{foo}{/if}app.svelte:3:1
Error: Variable 'foo' implicitly has type 'any' in some locations where its type cannot be determined. (ts)
alue = 1;
$: foo =
app.svelte:6:13
Error: Variable 'foo' implicitly has an 'any' type. (ts)
if value}{foo}{/if}Interestingly enough, any other reference made from the reactive field have a correct type again.
So this:
app2.svelte
<script lang="ts">
let value = 1;
$: foo = value ? 'foo' : 'bar';
let bar = foo;
</script>
{#if value}{bar}{/if}Works! Svelte-check does not output any errors. (But it's not reactive)
aradalvand
Metadata
Metadata
Assignees
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.feature requestNew feature or requestNew feature or request