Any ideas why Parameter Info lacks inference and does not match the correct Quick Documentation (works in VSC)?
Below is a simplified code example and a few screenshots to demonstrate my issue.
Example #1:
type OmitFirst<T extends any[]> = T extends [infer A, ...infer B] ? B : never;
type OmitFirstParameter<T extends (...args: any) => any> = OmitFirst<Parameters<T>>;
type Validator = (value: any, ...args: any[]) => boolean
interface Validators {
[name: string]: Validator
}
type ValidatorName = keyof typeof SchemaBuilder.validators;
class SchemaBuilder {
private static _validators = {
isInt: (value: any) => Number.isInteger(value),
min: (value: number | string, min: number) => (typeof value === "number") ? value >= min : value.length >= min,
max: (value: number | string, min: number) => (typeof value === "number") ? value <= min : value.length <= min,
between: (value: number, min: number, max: number) => value >= min && value <= max,
} satisfies Validators;
public static get validators(): Readonly<typeof SchemaBuilder._validators> {
return SchemaBuilder._validators;
}
public static test<T extends ValidatorName>(
name: T,
...args: typeof SchemaBuilder.validators[T] extends infer F extends (...args: any) => any ? OmitFirstParameter<F> : never
): void {
};
}
// PROBLEM OCCURS HERE!!!
SchemaBuilder.test("min", 3)
If you'll note the last line in the above code block, this is where the issue will appear in the following screenshots.
And below are the Visual Studio Code results of the same exact code snippet
Any ideas why this discrepancy exists?
请先登录再写评论。
Submitted to developers as https://youtrack.jetbrains.com/issue/WEB-58940/Wrong-type-inferred-when-using-conditional-types-with-spread, please follow it for updates