Closed winston0410 closed 1 year ago
Based on the readme, this is how we get a tuple type from this library:
const tupleSchema = { type: "array", items: [{ type: "boolean" }, { type: "string" }], additionalItems: false, } as const; type Tuple = FromSchema<typeof tupleSchema>;
Which will give:
[] | [boolean] | [boolean, string] | [boolean, string, ...unknown[]]
But when I tried to put it in an object like this:
const tupleInObjSchema = { type: "object", properties: { foo: { type: "array", items: [{ type: "boolean" }, { type: "string" }], additionalItems: false, } }, additionalProperties: false, required: ['foo'] } as const type TupleInObj = FromSchema<typeof tupleInObjSchema>;
I get the following type:
{ foo: unknown[] }
Is it a bug or something intended?
I am facing the exact same issue
Hi @orekav and @winston0410
Can you try with v2.7.2 ? It seems like it's fixed
I can confirm that the fix worked for me. Thank you so much for fixing this issue.
Based on the readme, this is how we get a tuple type from this library:
Which will give:
But when I tried to put it in an object like this:
I get the following type:
Is it a bug or something intended?