Closed
Description
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
Actual behavior:
selectedFunc
accepts Func1Options & Func2Options
Playground Link: Playground
Metadata
Metadata
Assignees
Labels
No labels