elysia
elysia copied to clipboard
Recursive schema regression between v1.2.25 and v1.3, value type never instead of expected type, now with runtime error in 1.3.21
Hi @SaltyAom, I'm getting this exact same issue on 1.3.21 on this example and what's more is, during runtime, the endpoints with recursive query schemas are failing with:
Error: Unable to dereference schema with $id 'T0'.Btw, I've also tested this example on 1.3.8, there's still the typing regression (
value: never[]), however there's no runtime errors (like in 1.3.21)For this example on 1.3.21, the first time the endpoint is run, Elysia gives this output:
Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues { [Symbol(TypeBox.Kind)]: "Object", type: "object", required: [ "filter" ], properties: { filter: { $id: "T0", [Symbol(TypeBox.Hint)]: "Recursive", anyOf: [ { [Symbol(TypeBox.Kind)]: "Union", anyOf: [ { type: "string", [Symbol(TypeBox.Kind)]: "String", format: "ObjectString", default: "{\"type\":\"eq\",\"value\":{}}", properties: { type: { const: "eq", type: "string", [Symbol(TypeBox.Kind)]: "Literal", }, value: { [Symbol(TypeBox.Kind)]: "Any", }, }, }, { type: "object", required: [ "type", "value" ], [Symbol(TypeBox.Kind)]: "Object", properties: { type: { const: "eq", type: "string", [Symbol(TypeBox.Kind)]: "Literal", }, value: { [Symbol(TypeBox.Kind)]: "Any", }, }, } ], [Symbol(TypeBox.Transform)]: { Decode: [Function], Encode: [Function], }, }, { [Symbol(TypeBox.Kind)]: "Union", anyOf: [ { type: "string", [Symbol(TypeBox.Kind)]: "String", format: "ObjectString", default: "{\"type\":\"and\",\"value\":[]}", properties: { type: { const: "and", type: "string", [Symbol(TypeBox.Kind)]: "Literal", }, value: { type: "array", items: { $ref: "T0", [Symbol(TypeBox.Kind)]: "This", }, [Symbol(TypeBox.Kind)]: "Array", }, }, }, { type: "object", required: [ "type", "value" ], [Symbol(TypeBox.Kind)]: "Object", properties: { type: { const: "and", type: "string", [Symbol(TypeBox.Kind)]: "Literal", }, value: { type: "array", items: { $ref: "T0", [Symbol(TypeBox.Kind)]: "This", }, [Symbol(TypeBox.Kind)]: "Array", }, }, } ], [Symbol(TypeBox.Transform)]: { Decode: [Function], Encode: [Function], }, } ], [Symbol(TypeBox.Kind)]: "Union", }, }, additionalProperties: false, }
Originally posted by @coscura in #1278
Hello, can you also share the schema code/Elysia code as well, thanks
It's the same example code from https://github.com/elysiajs/elysia/issues/1278