$app.rxNostr is typed as always present but is undefined outside NostrApp
- 主要语言
- TypeScript
- 星标
- 29
- 派生
- 3
- 平均合并
- 3 小时 5 分钟
- 30 天内合并 PR
- 11
描述
`src/lib/stores/app.ts:9` declares the store with no initial value but a
non-optional type:
```ts
export const app = writable<{ rxNostr: RxNostr }>();
```
so `$app` is `undefined` until a `` mounts, while the type says it is
always there. All twelve components read `$app.rxNostr` and each carries the same
acknowledgement of the gap, e.g. `src/lib/components/Event.svelte:18`:
```ts
// TODO: Check if $app.rxNostr is defined
$: result = useEvent($app.rxNostr, queryKey, id, req);
```
Rendering any data component outside `` throws
`TypeError: Cannot read properties of undefined (reading 'rxNostr')`, and neither
the type system nor the tests catch it. The equivalent mistake with the query client
produces TanStack's clear "No QueryClient was found in Svelte context" message.
Determined by code reading.
## Direction
Whatever holds the instance should be typed as possibly-absent and accessed through
a helper that fails with a message naming ``, so the twelve TODOs collapse
into one check.
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。