Repository navigation
Commit 5859d09
authored
fix: revert ObservableStatus to a strict (non-union) type (#750)
* test: type-check the test suite in CI to catch type regressions
Adds tsconfig.test.json (type-checks src + test) and runs it in the
type-check workflow. The test suite already exercises hooks the way
consumers do (reading .data off results), so a breaking change to the
public types now fails CI at compile time.
Also fixes pre-existing test-only type issues surfaced by turning the
check on: unused imports, node globals (require/global/Buffer) via the
node types, and a FunctionComponent children prop annotation.
* fix: revert ObservableStatus to a strict (non-union) type
4.2.4 shipped ObservableStatus<T> as a discriminated union (data is
T | undefined unless narrowed on status), which broke the documented
pattern of reading .data directly across every data hook. Revert the
type to the previous strict shape (data: T) so this ships as a patch.
The genuinely-optional cases stay correctly typed at the hook level
(useFirestoreDocData/DocDataOnce return T | undefined, useUser returns
User | null, useDatabaseListData returns T[] | null), which is where
the undefined belongs rather than on ObservableStatus itself.
The internal SuspenseSubject status builders keep an as-cast since the
in-flight loading value is internally T | undefined.
* docs: regenerate reference docs for ObservableStatus type change
ObservableStatus is now an interface again rather than a discriminated
union type-alias, so the generated reference docs drop the per-status
sub-interface pages and retarget links from type-aliases/ to interfaces/.
* test: strengthen the type guard with typed object-data and doc-data reads
Per review: the guard did not exercise useDatabaseObjectData, and the
existing useFirestoreDocData tests use <any> so their .data reads are
untyped. Add a useDatabaseObjectData test with a typed .data read (data
is T, so it fails to compile if ObservableStatus regresses to a union)
and a concretely-typed useFirestoreDocData read.1 parent 43dc25a commit 5859d09
35 files changed
Lines changed: 109 additions & 361 deletions
File tree
- .github/workflows
- docs/reference
- functions
- interfaces
- type-aliases
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments