TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms: Intersection interfaces, Ternary operator, Intersect interfaces instead of union
Code
constsomeCondition=trueinterfaceFunc1Options{name: string}interfaceFunc2Options{age: number}functionFunc1(options: Func1Options){console.log(options)}functionFunc2(options: Func2Options){console.log(options)}constselectedFunc=someCondition ? Func1
: Func2selectedFunc({age: 20,name: 'Alastar'})Expected behavior:
selectedFunc accepts Func1Options
Actual behavior:
selectedFunc accepts Func1Options & Func2Options
Playground Link:Playground
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms: Intersection interfaces, Ternary operator, Intersect interfaces instead of union
Code
Expected behavior:
selectedFuncacceptsFunc1OptionsActual behavior:
selectedFuncacceptsFunc1Options & Func2OptionsPlayground Link:Playground