edgedb-js
edgedb-js copied to clipboard
Generated exclusive types are not accurate when using `constraint exclusive on` syntax for a single attribute
Code The code causing the error.
e.select(e.Example, () => ({
filter_single: {name: 'Iron Man'}
}));
Schema
Your application schema.
module default {
type Example {
required property name -> str;
constraint exclusive on (.name);
}
}
The above TS filter_single logic works at runtime, but throws a TS error. If we modify the schema to be:
module default {
type Example {
required property name -> str {
constraint exclusive;
}
}
}
then the type error is fixed (and runtime logic is unchanged).
Here's the associated Discord thread https://discord.com/channels/841451783728529451/849377751370432573/1125534997021986896