为什么打字稿无法检测到这个 Svelte 3 商店的正确内容类型,而是告诉我它是任何类型?

Why typescript cannot detect this Svelte 3 store's correct content type telling me instead it is of any type?

使用此代码和 eslint-plugin-svelte3:

<script lang="ts">
    import { writable } from "svelte/store";

    type Player = {
        name: string;
    };

    const playersStore = writable([] as Player[]);

    $: players = $playersStore;
</script>

{players}

我收到这个 Typescript 错误:

Unsafe assignment of an any value.eslint@typescript-eslint/no-unsafe-assignment

在线:

$: players = $playersStore;

为什么?

如果我使用:

错误消失
$: players = playersStore;

但我认为这不是解决方案:是一个错误,对吗?

From the GitHub readme:

There are some limitations to these type-aware rules currently. Specifically, checks in the context of reactive assignments and store subscriptions will report false positives or false negatives, depending on the rule. In the case of reactive assignments, you can work around this by explicitly typing the reactive variable.

我的建议是 turn off the offending rule Svelte 文件,直到解决此限制。