edgedb-js
edgedb-js copied to clipboard
Shape with pointer of `false` produces type suggesting the pointer is returned
e.select(e.X, {
foo: false
})
Runtime omits foo from EdgeQL, but TS types it as never.
This allows it to be compatible, somehow, with a type expecting that property.
class X {
foo: string;
}
const withX = (x: X) => {...};
const result = await e.select(e.X, {
foo: false
}).run();
// This is fine even though `foo` is required, and not in the DB result.
withX(result[0]);
I think the type should be changed to undefined, or maybe unknown instead?
Yeah, great point. "never is assignable to anything"
Options:
- Remove this key from the resulting object.
- Assign
undefinedto this key in the resulting object and make the type reflect that. - Use
unknownand... not sure what the runtime should be here sinceunknowndoesn't really imply anything to me about this key in the resulting object. Other than maybe that it exists?
I think the first option makes the most sense since I think that's kind of how you would instinctively use false: as a way to remove a property (for instance after a ["*"] splat spread).
Could we change the arg shape to reject false?
https://github.com/edgedb/edgedb-js/blob/0bf404ec6e3479379417b234e0500e2f4b76310d/packages/generate/src/syntax/select.ts#L755-L755
| true
We fixed this issue with first @scotttrinh recommendation above. We don't return anymore "these keys" in the resulting objects.