You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeT={k: symbol,other: boolean,// another key seems required for the bug to appear}// Type '"k"' cannot be used as an index type.(2538)typeC='k'extendskeyofT ? T['k'] : never;// any
π Actual behavior
An error is produced in the positive clause of the conditional type.
The resulting type is incorrect.
π Expected behavior
No error.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
ghostinpeace
changed the title
Literal tested as key of a certain type in condition cannot be used to index that type
Literal tested as key of a certain type cannot be used to index that type
Jan 20, 2024
ghostinpeace
changed the title
Literal tested as key of a certain type cannot be used to index that type
Literal tested as key of a certain type cannot be used as an index type
Jan 20, 2024
type T = {
k: symbol,
other: boolean, // another key seems required for the bug to appear
}
type C<U=T> = 'k' extends keyof U ? U['k'] : never;
type X = C; // symbol
π Search Terms
"literal", "extends", "keyof", "cannot be used to index type", "conditional"
π Version & Regression Information
Versions: ^5.0 (regression)
β― Playground Link
https://www.typescriptlang.org/play?ts=5.3.3&ssl=7&ssc=54&pln=1&pc=1#code/C4TwDgpgBAKlC8UDeBYAUFKBrAXFAziALYBGA9gDYA06mZwAFhAE57mUQCGAdlVAPT8oPek2bYIIAhAhF8UZhACOAVwCWigCZQAZmXGNoJFQHMowMsLCROzdAF906QbHDQA5ACIsn91ADGPNz0UCTQKvgQ2pzyPFBq3JoQAB7mbgB0ABQATACsAMwAHACU6KCQUADCCFDuWH4pwBCJ8liSZDqwUAD8sADade4AulB43BAAbiwA3AJCPCBAA
π» Code
π Actual behavior
An error is produced in the positive clause of the conditional type.
The resulting type is incorrect.
π Expected behavior
No error.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: