We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms: Intersection interfaces, Ternary operator, Intersect interfaces instead of union
Code
const someCondition = true interface Func1Options { name: string } interface Func2Options { age: number } function Func1 (options: Func1Options) { console.log(options) } function Func2 (options: Func2Options) { console.log(options) } const selectedFunc = someCondition ? Func1 : Func2 selectedFunc({ age: 20, name: 'Alastar' })
Expected behavior: selectedFunc accepts Func1Options
selectedFunc
Func1Options
Actual behavior: selectedFunc accepts Func1Options & Func2Options
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