-
-
Notifications
You must be signed in to change notification settings - Fork 221
Closed
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.bugSomething isn't workingSomething isn't working
Description
Describe the bug
In the snippet below, I can't use $ to access the contents of store. I'm not sure if this is a Svelte or a TypeScript problem, I suspect Svelte:
<script>
import type { Writable } from "svelte/store";
export let store: Writable<string[]> | null = null;
if (store) {
$store.length
}
</script>TypeScript tells me that "Property 'length' does not exist on type 'never'.", even though the type of $store should be string[] inside the if block.
Expected Behavior
TypeScript infers the type of $store as string[] inside the if block.
Actual Behavior
TypeScript infers the type of $store as null inside the if block.
Reproduction
Copying the script above should be enough
Logs
No response
System Info
System:
OS: Windows 10 10.0.19045
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 16.32 GB / 31.91 GB
Binaries:
Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
npm: 8.4.1 - ~\node_modules\.bin\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (111.0.1661.44)
npmPackages:
rollup: ^2.3.4 => 2.79.1
svelte: ^3.0.0 => 3.55.1Severity
annoyance
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