TypeScript Version: 3.7.2
Search Terms:
keyof interface function arguments args
Code
exportinterfaceISocialButtonTypes{vk: {vk: string};fb: {fb: string};ok: {ok: string};twitter: {tw: string};};exporttypecreateSocialItem=<TextendskeyofISocialButtonTypes>(socialType: T,params: ISocialButtonTypes[T])=>void;functioncreateSocialItem<TextendskeyofISocialButtonTypes>(socialType: T,params?: ISocialButtonTypes[T]): ISocialButtonTypes[T]{returnparams}// the compiler show error, but suggest all keyscreateSocialItem('vk',{ok: 'dwdw'})~~~~~~~~~~~~~Expected behavior:
The second param should suggest only vk key.
Actual behavior:
The params field suggests all keys, but the compiler show error on the incorrect key. The function return works correctly
Playground Link:
https://cutt.ly/cruK8eX
Related Issues:
TypeScript Version: 3.7.2
Search Terms:
keyof interface function arguments args
Code
Expected behavior:
The second param should suggest only
vkkey.Actual behavior:
The params field suggests all keys, but the compiler show error on the incorrect key. The function return works correctly
Playground Link:
https://cutt.ly/cruK8eX
Related Issues: