You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 35a0a51
Browse filesBrowse the repository at this point in the historyBrowse files
fix(codegen-ts): annotate cross-entity FK .references() with Any*Column
The Drizzle schema generator only emitted the explicit `(): Any{Pg,SQLite}Column`
return-type annotation on the .references() callback for SELF-referential FKs
(targetEntityName === currentEntityName). Cross-MODULE circular references — table
A → B while B → A — also form an import cycle that makes TypeScript infer the table
const as `any` (TS7022 "implicitly has type 'any' … referenced in its own
initializer") under `strict`, but those went through the un-annotated branch.
Emit the annotation unconditionally on .references() callbacks: it is the
Drizzle-documented fix for circular inference and is a harmless explicit supertype
for acyclic FKs.
- drizzle-schema.ts: hoist the Any*Column symbol and annotate both the self-ref and
cross-entity branches.
- Regenerated postgres/sqlite/package golden snapshots (cross-entity FKs now carry
the annotation) + updated the field-extends-attr inline assertion.
- Added a cross-module circular-FK regression test (Author <-> Book) asserting both
directions emit `(): AnyPgColumn => ...`.
Surfaced by a downstream consumer whose generated schema has mutually-referential
tables (e.g. active_npcs <-> npc_groups): `tsc --strict` failed with TS7022 on the
0.12 output. 819 tests pass.
0 commit comments