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
{{ message }}
Repository navigation
Generic return type (T[K]) is intersection among all properties of T instead of unionΒ #54901
Type 'ConfigA | ConfigB | undefined' is not assignable to type 'Config[K]'.
Type 'ConfigA' is not assignable to type 'Config[K]'.
Type 'ConfigA' is not assignable to type 'ConfigA & ConfigB'.
Type 'ConfigA' is not assignable to type 'ConfigB'.
Index signature for type 'string' is missing in type 'ConfigA'.
π Expected behavior
I would expect no error of returning config.get(key) within function a
thanks! But even with Config[keyof T], should not it be ConfigA | ConfigB instead of ConfigA & ConfigB ?
The example is a simplified case just for the minimum repro, in reality we are having this issue with a IPC proxy, and the final xx.get is also generic, but I am getting exact same error, maybe I should update the playground with a more realistic case.
Activity
olivermrose commentedon Jul 6, 2023
getneeds to be generic; otherwise, the return type is essentiallyConfig[keyof T].taozhou-glean commentedon Jul 7, 2023
thanks! But even with
Config[keyof T], should not it beConfigA | ConfigBinstead ofConfigA & ConfigB?The example is a simplified case just for the minimum repro, in reality we are having this issue with a IPC proxy, and the final
xx.getis also generic, but I am getting exact same error, maybe I should update the playground with a more realistic case.fatcerberus commentedon Jul 7, 2023
Itβs a side effect of #30769.
typescript-bot commentedon Jul 9, 2023
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.