The error surface presented when a target guard is written on a foreign
key declared without its target type.
Never written by hand: it is the type a target takes on a bare
ForeignKey, so the compile error on the guard quotes its message.
A bare ForeignKey carries no compile-time link to the entity it
references, so a guard on it could only be typed against attributes of the
wrong entity. Adding the type parameter — ForeignKey<Customer> — is a
non-breaking change that makes the guard available.
Example
classCustomerStoreextendsJoinTable<Customer, Store> { publicreadonlycustomerId: ForeignKey<Customer>; publicreadonlystoreId: ForeignKey; // bare: no target type }
interfaceUntypedForeignKeyTargetError{ __writeConditionError:"declare this foreign key with its target type, ForeignKey<Target> or NullableForeignKey<Target>, to guard the row it references"; }
__writeConditionError:"declare this foreign key with its target type, ForeignKey<Target> or NullableForeignKey<Target>, to guard the row it references"
The error surface presented when a
targetguard is written on a foreign key declared without its target type.Never written by hand: it is the type a
targettakes on a bareForeignKey, so the compile error on the guard quotes its message.A bare
ForeignKeycarries no compile-time link to the entity it references, so a guard on it could only be typed against attributes of the wrong entity. Adding the type parameter —ForeignKey<Customer>— is a non-breaking change that makes the guard available.Example