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
typeK='x'|'y'typeO={x: number}declareconstk: Kdeclareconsto: Oif(kino){// Element implicitly has an 'any' type because expression of type 'K' can't be used to index type 'O'.// Property 'y' does not exist on type 'O'.(7053)console.log(o[k])}
🙁 Actual behavior
The error is present in the v5.5.1-rc. The error text:
Element implicitly has an 'any' type because expression of type 'K' can't be used to index type 'O'. Property 'y' does not exist on type 'O'.(7053)
🙂 Expected behavior
The error should've been resolved in the TypeScript 5.5
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
@MartinJohns you are correct, I mistakingly assumed a broader feature scope. Anyway, considering this logic TypeScript cannot guess a better type for O[k] then unknown
🔎 Search Terms
5.5 Control Flow Narrowing for Constant Indexed Accesses
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.5.1-rc#code/C4TwDgpgBA0lC8UDkAPJUA+yRIFC9EigHkEoBvXKaqFALigDsBXAWwCMIAnXAX3wAmEAMYAbAIZdowgPaMAzsCgBrBjFxCxk6XMVQZDYvgCWAMygAKZVGON9ASgpUashTNEQAdKJkBzCzIA2soAuvZ8QA
💻 Code
🙁 Actual behavior
The error is present in the v5.5.1-rc. The error text:
🙂 Expected behavior
The error should've been resolved in the TypeScript 5.5
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: