-
Notifications
You must be signed in to change notification settings - Fork 12.8k
4.9 regression on conditional type #51540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here is a slightly smaller example to reproduce the issue. type PathImpl<T, K extends keyof T> =
K extends string | number
? T[K] extends Record<string, any>
? T[K] extends ArrayLike<any>
? PathImpl<T[K], number>
: never
: never
: never All three conditionals are needed to reproduce the error. There is no error if you remove the first conditional. type PathImpl<T, K extends keyof T> =
T[K] extends Record<string, any>
? T[K] extends ArrayLike<any>
? PathImpl<T[K], number>
: never
: never Which seems counterintuitive to me. |
I think we might have a similar issue, but it is related to |
The change between release-4.8 and main occurred at 6e8337e. |
Seeing a similar issue in
where the code looks like this: export declare type Modifier<Name, Options> = {
name: Name;
enabled: boolean;
phase: ModifierPhases;
requires?: Array<string>;
requiresIfExists?: Array<string>;
fn: (arg0: ModifierArguments<Options>) => State | void; // <-- fails here
effect?: (arg0: ModifierArguments<Options>) => (() => void) | void; // <-- and here
options?: Partial<Options>;
data?: Obj;
};
export declare type ModifierArguments<Options extends Obj> = {
state: State;
instance: Instance;
options: Partial<Options>;
name: string;
};
export declare type Obj = {
[key: string]: any;
}; So it looks like it's failing to assign an untyped generic arg to |
@JGJP that looks like a correct error to me (kinda hard to say since the example is self-contained). |
@RyanCavanaugh this is not my code, it's from popperjs typings, used by |
This issue no longer reproduces. Looks like it was fixed in TS 5.0. |
Bug Report
π Search Terms
4.9 Type 'number' does not satisfy the constraint
π Version & Regression Information
This changed between versions 4.8 and 4.9.3
β― Playground Link
tsplay.dev/NdrGyW
π» Code
π Actual behavior
π Expected behavior
Since
T[K] extends ArrayLike<any>
then I should be able to index by number. This was working on 4.8The text was updated successfully, but these errors were encountered: