feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.02k stars 745 forks source link

Recursive schemas not working or not possible #3177

Open SeanMXD opened 1 year ago

SeanMXD commented 1 year ago

Steps to reproduce

Start with the feathers-chat example and try to add replies to messages from there.

Expected behavior

One would expect to be able to change the messageSchema const at feathers-chat-ts/src/services/messages/messages.schema.ts:9 to Type.Recursive with its parameter being an arrow function that returns the original Type.Object call with an added line inside this object that looks like parent: Type.Optional(Type.Ref(_messageSchema)), add an optional parentId to the schema and that would be the end of it.

Actual behavior

When messageSchema is a Type.Recursive instead of a Type.Object it causes several TypeScript errors and fails to compile.

System configuration

I'm using the latest versions of FeathersJS, NodeJS, and Ubuntu Server.