$app.rxNostr is typed as always present but is undefined outside NostrApp
- Dominant language
- TypeScript
- Stars
- 29
- Forks
- 3
- Avg merge
- 3h 5m
- Merged PRs (30d)
- 11
Description
`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.
Contributor guide
No contributing guide indexed for this repository
Research direction
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.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100