Open NielsCo opened 1 year ago
interesting, from looking at the error this seems to be due to the override check for model extends that check properties in derived models are compatible with the base model
@NielsCo Can you elaborate on the scenario where you would use this sort of API definition?
Sure. If I someone wanted to model a tree data-structure they could create a model like this. With the "link" property being the parent-node. And the need for generics because there are multiple node-types. Which obviously only is a good idea if the tree structure is and (will forever be) small enough to be transmitted via an endpoint.
I probably should have elaborated that for me the issue is not a blocker, as I was just trying out TypeSpec and noticed that this feature I know from other languages didn't work as I expected it to. Especially the part that the property being optional did not cause an error, looked like an interesting issue to me
Thanks, that helps. Definitely an issue we want to fix, but this helps us weigh the priority
The following TypeSpec Code:
Throws the following Error:
error missing-property Property 'link' is missing on type 'ExtendsMyModel' but required in 'MyModel<T>'
Playground LinkMaking the link-property optional makes it work though:
Playground Link
Maybe this has to do with the warning in the interface docs