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
Additional Information:
This issue seems to have emerged after a recent update in the TypeScript version. The code logic appears to be accurate, and the TypeScript configuration in my tsconfig.json file seems appropriately configured. The discrepancy between the expected behavior and the actual TypeScript error suggests a potential bug in TypeScript's latest version or a misconfiguration.
Error Messages:
The error messages I'm encountering is:
TS2322: Type 1 is not assignable to type Both[K]
Type number is not assignable to type never.
TS2322: Type 2 is not assignable to type Both[K]
Type number is not assignable to type never.
🙂 Expected behavior
The function test should compile without any errors, as the return types are correctly inferred and match the expected types defined in the Both interface. The final call to test("a") should yield the expected return type of 1.
The text was updated successfully, but these errors were encountered:
🔎 Search Terms
"Function Return Types", "Type Inference", "Type Error", "keyof", "Type Assignment"
🕗 Version & Regression Information
Environment:
tsconfig.json:
Additional Information:
This issue seems to have emerged after a recent update in the TypeScript version. The code logic appears to be accurate, and the TypeScript configuration in my
tsconfig.json
file seems appropriately configured. The discrepancy between the expected behavior and the actual TypeScript error suggests a potential bug in TypeScript's latest version or a misconfiguration.⏯ Playground Link
https://www.typescriptlang.org/play?#code/FAFwngDgpgBAgjAvDAjKSsBCSYCZjACWAdiFAE4BmAhgMZYD2IAFjAN7AwzUBc8nMAEZ9MwAL4FKAV2K0QhBsRhkAziAA8AaRhQAHmWIATFTADWUMA0oxMTZgD4AFObB9NAShF2A2poC67AIqAO6EILSszhbugVxctNQqsABE1Mk8AnEw5FAgUuRKKNwmtIpqmTCGUDRSADYgGVlcOXkFeMUwpcTlXBISoFBqjqnJ7gDcAkA
💻 Code
🙁 Actual behavior
Error Messages:
The error messages I'm encountering is:
🙂 Expected behavior
The function
test
should compile without any errors, as the return types are correctly inferred and match the expected types defined in theBoth
interface. The final call totest("a")
should yield the expected return type of1
.The text was updated successfully, but these errors were encountered: