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
typeProps={a: stringb: number}functiontest<KextendskeyofProps>(key: K,newVal: Props[K],oldVal: Props[K]){if(key==='a'){// K won't be inferred as 'a'shouldBeString(newVal)// and this line would trigger an error}elseif(key==='b'){shouldBeNumber(newVal)}}functionshouldBeString(v: string){}functionshouldBeNumber(v: string){}
The text was updated successfully, but these errors were encountered:
zaaack
changed the title
Generic function's parameter type cannot infer from condition
function's union generic parameter cannot be infered from condition
Mar 15, 2018
TypeScript Version: 2.7.2
Search Terms:
Code
Expected behavior:
Generic union should be infered.
Actual behavior:
Not
Playground Link: link
Related Issues:
The text was updated successfully, but these errors were encountered: