Open jvassev opened 11 months ago
This is somewhat related to the work I've started in #606 . It's a little tricky because TypeScript and EdgeQL have slightly different type systems, so I'm trying to tread carefully here. Definitely makes sense from the TypeScript perspective of wanting to define some function that is polymorphic based on some superclass/interface.
Thank you for the quick response! I tried to find a similar issue but did not discover #606. This is clearly a duplicate of it.
Code The code causing the error.
Schema
Generated EdgeQL
Error or desired behavior
I think it would be nice to treat EdgeQL subtypes as subtypes in TS code. If I ignore the compiler error from the example above (using
getConfigurationFor(e.default.User as any, x)
), the code works.The error has to do with the
__element__
property being different for the parent (HasConfiguration
) and child(User
orProject
);A solution I could think of is making the
__element__
s compatible or have a "cast" method, for example:It's like a handle to the
User
type which lets you only touch the properties inherited from one of its parents.Versions (please complete the following information):
OS:
EdgeDB version (e.g.
2.0
): edgedb-server, version 3.2+d2023072119.gb7dc55395.cv202305040002.r202307211907.tpa4dmxzwgqwxk3tlnzxxo3rnnruw45lyfvtw45i.bofficial.s99ce519EdgeDB CLI version (e.g.
2.0
): EdgeDB CLI 3.4.0+160d07dedgedb-js
version (e.g.0.20.10
;): 1.3.4@edgedb/generate
version (e.g.0.0.7
;): 0.3.3Typescript version: 5.1.3
Node/Deno version: v16.15.0