eng-1863 Relation cross-app contract#1197
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
|
||
| type SpaceRef = DbRef | { url: string; sourceApp: Enums<"Platform"> }; | ||
|
|
||
| export type LocalOrRemoteRef = | ||
| | LocalRef | ||
| | { | ||
| localId: string; | ||
| // infer space from context if absent. | ||
| space?: SpaceRef; | ||
| } | ||
| | { |
There was a problem hiding this comment.
🔍 Structurally redundant union variants in LocalOrRemoteRef
The LocalOrRemoteRef type at packages/database/src/crossAppContracts.ts:26-36 defines three union variants, but the first two are structurally indistinguishable in TypeScript. Variant 1 is LocalRef = { localId: string }, and variant 2 is { localId: string; space?: SpaceRef }. Since space is optional, every value matching variant 1 also matches variant 2 — TypeScript's structural type system cannot discriminate between them. This means runtime type-narrowing code (e.g., checking for the presence of space) will never isolate variant 1 from variant 2. If future consumers need to distinguish 'definitely local' from 'possibly remote with space inferred from context', they won't be able to do so with this type as written. This may be intentional for readability (showing that a plain LocalRef is accepted), but it's worth confirming the design intent before downstream code is built against it.
Was this helpful? React with 👍 or 👎 to provide feedback.
562c561 to
f1e49e1
Compare
4eb544e to
a4c65c3
Compare
Uh oh!
There was an error while loading. Please reload this page.