-
-
Notifications
You must be signed in to change notification settings - Fork 574
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
TS 5.4.2 breaks ConditionalKeys
and SetParameterType
#831
Comments
How come the canary is not picking up on this? https://github.com/sindresorhus/type-fest/actions/workflows/ts-canary.yml |
@trevorade Extending the tests to highlight this failure would be a good first step I think 👍 This is the second breakage in the 5.4-line, after #784 |
Hey @voxpelli, we were just updating our code repository in my company to 5.4.2 and this test started breaking so I figured I would send an early signal. I'm not really looking for contribution opportunities at the moment. Here's the |
We don't use |
For export type ConditionalKeys<Base, Condition> = {
// Map through all the keys of the given base type.
[Key in keyof Base]-?:
// Pick only keys with types extending the given `Condition` type.
Base[Key] extends Condition
// Retain this key since the condition passes.
? Key
// Discard this key since the condition fails.
: never;
// Convert the produced object into a union type of the keys which passed the conditional test.
}[keyof Base]; Fixes the tests on our end anyways. |
Here's some debugging info for TS Playground link (change the version to 5.3.3 to see the difference) This one may indicate a TypeScript bug |
Simpler repro of the underlying issue. TS Playground link (change the version to 5.3.3 to see the difference) I'll see about logging an issue. |
Hi @trevorade I did some test, If we focus only on the results of type But whatever this is a breaking change.. type Test<Tuple extends unknown[]> = {
[K in keyof Tuple]: K
};
type A = Test<[a: number, b: string, c: Object, ...arguments: boolean[]]>
// v5.3.3 type A = [a: "0", b: "1", c: "2", ...arguments: "3"[]]
// v5.4.2 type A = [a: "0", b: "1", c: "2", ...arguments: number[]] |
Looks like I haven't looked closer to see what the correct rewrite would be. |
|
Thanks. I'll verify the fix on our end later today |
|
Apologies, For this case in tsc 5.4.2: // Test another define way
declare const test3: SetParameterType<typeof fn, [a: string, b: boolean]>;
expectType<(a: string, b: boolean, c: Object, ...args: boolean[]) => null>(test3);
test3('1', true, {}, true); I'm seeing the type of type test3Type = (_a: string, _b: boolean, _c: Object, ..._arguments: (string | boolean)[]) => null You can ignore the difference in parameter names but the last rest parameter is resolving to |
Sorry, I made a mistake that ignore the number key when input is an array. I'm fixing it right now. It seems that the improvement of the testing system is more urgent. |
|
For
ConditionalKeys
, the root issue is: microsoft/TypeScript#56644 which sound slike it will not be fixed. Basically, theNonNullable
call in theConditionalKeys
type is ignored and does not run. Based on that issue, it's possible this type can be rewritten to be compatible with 5.4.2 but I'm unclear exactly on how...I haven't debugged
SetParameterType
very closely but I just noticed that it too has issues in TS 5.4.2Upvote & Fund
The text was updated successfully, but these errors were encountered: