akiomik / akiomik/nosvelte

$app.rxNostr is typed as always present but is undefined outside NostrApp

未关闭
#89 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
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.

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start with src/lib/stores/app.ts:9 and src/lib/components/Event.svelte:18, then inspect the twelve components that read $app.rxNostr. Review the existing tests, which currently do not catch rendering outside . Done means the absent-instance type and access path are handled consistently, the failure names , and the repeated TODO acknowledgements are consolidated into one check.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
64/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。