akiomik / akiomik/nosvelte

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

Open
#89 0 comments 0 reactions 0 assignees View on GitHub
bug
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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.