在 TypeScript 中输入 <svelte:component> 的 "this" 属性

Typing <svelte:component>'s "this" property in TypeScript

我正在 Svelte 中构建一种门户系统,使用商店传递组件以显示组件树的某处。

我的问题不在于实施该系统,而在于输入商店。我试着这样声明:

const modalComponent = writable<SvelteComponent>(null)

但这不起作用。当我在某处导入组件时,VS Code 向我显示了一种 typeof <componentName>__SvelteComponent_ 类型,它与 SvelteComponent 类型不兼容(实际上是 SvelteComponentDev 的别名):

Type 'typeof <component>__SvelteComponent_' is missing the following properties from type 'SvelteComponentDev': $set, $on, $destroy, $capture_state, and 2 more.

我该如何输入?我想避免使用 any.

更新:这里是 codesandbox 重现案例的内容。不幸的是,我似乎无法让它与 TypeScript 一起工作。还在分享,希望对大家有帮助

正如@dummdidumm 指示我的那样,我为 Svelte 的团队创建了一个问题 here 来解决这个问题。

同时我暂时将此标记为答案,并在问题修复并发布后立即更新。谢谢!