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
Compiler and intellisense fail to determine that test in test1, test2 functions have the toDisplay function even though they can determine that when T is explicitly stated as Example in test3. As a result, there are errors in the functions test1 and test2 but not test3.
π Expected behavior
There should be no error with test and test2 because T[ValidKey[T]] can only return fields of type IDisplayable or function type ()=>string
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
Typed key access generic
π Version & Regression Information
This is the behavior in every version I tried (4.9.5 and latest 5.4.4), and I reviewed the FAQ for entries about "Generics", "Type Guards"
β― Playground Link
https://www.typescriptlang.org/play?ts=5.4.4#code/JYOwLgpgTgZghgYwgAgJIBFgGcAOAbOATzgCM8UBvAKGVuTAHtNcDCAKASgC5kswpQAcwDcVAL5UwhHCgBiAVxAIAShDDyoILAGV+Q5AF5knQwD5eekCMnSUGbPiKlyAaQiEAPABVzR6rQBtF2RQZABrdwYYZC8AXR4vINjkCAAPSBAAEyw0ZkdiMhQAfmRgnhAIADdoUTEAiMIomNjRKRlkADU4PGBMt08fQ2R-ZCCQkHDI6LiEpJT0iCyc+xYnQuQAH2QFJVV1TR1LQWQSsuQK6qha+qnm0SpQSFhEFABRVLgAW3xKGnOviA8PgCKyiWhwQSA4Z-WiMPKsThAo5g5BiFEkL48TgGUzAoS1KgIBhaMDIIl4LA8Fb5ZwQfoed5fH6mALJIwBADkEIgHIANMgORjPnyBSAARyWoTiXwyQw8Dwuj0+u4GR9vuQWWzRlzISLBV89WLPjzJVQYIoEGBgMT6BA+ABGbymNipBL8hBU+FrVwqnwcaF0WUk20yoypAIISWBqBqDQTSB8AB0cIcCI4BPNSitNoTYAATE6XW6yQrur16X6A3QicHc0Nw5GUbRgNE2G0IE06wZuwLM5brSAOf6RtHY5oQ2BOE3USkKb9A7QY-t43awMmmKmiFOYajxGaLdmV3wAMxF5CM9UQd2lpX0i-M4c7msyrvIBtRugt4ztzurww9jk+0PIcq1HZcJ23QMxFnLB5wXJc4wndcvXYdMdwkMQgA
π» Code
π Actual behavior
Compiler and intellisense fail to determine that test in test1, test2 functions have the toDisplay function even though they can determine that when T is explicitly stated as Example in test3. As a result, there are errors in the functions test1 and test2 but not test3.
π Expected behavior
There should be no error with test and test2 because T[ValidKey[T]] can only return fields of type IDisplayable or function type ()=>string
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: