-
Notifications
You must be signed in to change notification settings - Fork 747
Open
Description
Note: This is a refiling of #61728 due to being closed due to being related to quick info display (see #62827).
Version & Regression Information
This changed in PR microsoft/TypeScript#51621
Playground Link
Code:
Poor quick info:
type BasicConditional<T> = keyof T extends any
? true
: false;
type Config = { rejectClose: true };
type Test =
Config extends {}
? {
rejectClose: BasicConditional<Config>;
}
: never;
type RejectClose = Test["rejectClose"];
// ^? keyof Config extends any ? true : falseBroken assignability (found by @Andarist, see microsoft/TypeScript#61728 (comment))
type BasicConditional<T> = keyof T extends infer R ? R : never;
type Config = { rejectClose: true };
type Test = Config extends {}
? {
rejectClose: BasicConditional<Config>;
}
: never;
const test: Test["rejectClose"] = "rejectClose";
// ^ Type 'string' is not assignable to type 'BasicConditional<Config>'.
const ok: BasicConditional<Config> = "rejectClose"; // No errorActual behavior
RejectClose's quick info is keyof Config extends any ? true : false which is un-simplified and rather ugly. In addition in the second snippet const test: Test["rejectClose"] = "rejectClose"; fails.
Expected behavior
The quick info should look nice and const test: Test["rejectClose"] = "rejectClose"; should succeed.
See microsoft/TypeScript#61999 for a TS-JS based fix.
RyanCavanaugh
Metadata
Metadata
Assignees
Labels
No labels