-
-
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.bugSomething isn't workingSomething isn't working
Description
Based on this issue and this comment rxjs observables with await blocks are supported. sveltejs/svelte#2571 (comment)
And indeed this code snippet does the job and works (Except errors and the unresolved state but that a different issue), but it also produces a TypeScript error, and one more if strict settings (noImplicitAny to be precise) are enabled.
tsconfig.json
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true, // set to `false` to avoid ts(7006)
}
}app.svelte
<script lang="ts">
import { interval, Subject } from 'rxjs';
import { onMount } from 'svelte';
const s$ = new Subject<number>();
onMount(() => {
interval(500).subscribe((i) => s$.next(i));
});
</script>
{#await $s$}
Loading...
{:then value} <!-- Property 'then' does not exist on type 'number'.ts(2339) -->
<!-- Parameter 'value' implicitly has an 'any' type.ts(7006) -->
<!-- Both of these errors appear on the {:then block, but when hovering over
the `value` word in the `then` block it correctly shows the type as `number`,
while if I hover over the one below, it says `any` -->
Value: {value}
{:catch e} <!-- Parameter 'e' implicitly has an 'any' type.ts(7006) -->
Error: {e}
{/await}any in a catch should always be allowed as you can't even specify types of errors in regular catch blocks either. TS knows this, of course, and the interesting part is when using Promises in the template, e in the
:catch block still has an any type but that does not produce an error, only with Observables.
Metadata
Metadata
Assignees
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.bugSomething isn't workingSomething isn't working