Runtime
node
Runtime version
24
Module version
18
Last module version without issue
17.x
Used with
hapi
Any other relevant information
It seems that a lot of expressions where the schema for array.items is dynamically chosen makes typescript really unhappy.
What are you trying to achieve or the steps to reproduce?
import joi from 'joi';
joi.array().items(Math.random() > 0.5 ? joi.string() : joi.number());
What was the result you got?
No overload matches this call.
Overload 1 of 7, '(a: SchemaLikeWithoutArray<number>): ArraySchema<number[]>', gave the following error.
Argument of type 'StringSchema<string> | NumberSchema<number>' is not assignable to parameter of type 'SchemaLikeWithoutArray<number>'.
Type 'StringSchema<string>' is not assignable to type 'SchemaLikeWithoutArray<number>'.
Type 'StringSchema<string>' is not assignable to type 'StringSchema<number>'.
Type 'string' is not assignable to type 'number'.
Overload 2 of 7, '(...types: SchemaLikeWithoutArray<number>[]): ArraySchema<any[]>', gave the following error.
Argument of type 'StringSchema<string> | NumberSchema<number>' is not assignable to parameter of type 'SchemaLikeWithoutArray<number>'.
Type 'StringSchema<string>' is not assignable to type 'SchemaLikeWithoutArray<number>'.
Type 'StringSchema<string>' is not assignable to type 'StringSchema<number>'.
Type 'string' is not assignable to type 'number'.ts(2769)
What result did you expect?
No error.
Runtime
node
Runtime version
24
Module version
18
Last module version without issue
17.x
Used with
hapi
Any other relevant information
It seems that a lot of expressions where the schema for
array.itemsis dynamically chosen makes typescript really unhappy.What are you trying to achieve or the steps to reproduce?
What was the result you got?
What result did you expect?
No error.