Closed
Description
TypeScript Version: 2.5.2
Code
interface IFoo {
a: ((x: number) => string) | ((x: number, y: boolean) => string)
}
const z: IFoo = {
a(x: number) { return '' }
}
if (z.a.length === 1) {
z.a(1)
}
Expected behavior:
Type of z.a
is narrowed to (x: number) => string)
from the if statement
Actual behavior:
Error:
'Cannot invoke an expression whose type lacks a call signature. Type '((x: number) => string) | ((x: number, y: boolean) => string)' has no compatible call signatures.'
I'm trying to express an interface that can implement a method in one of two ways. Let me know if there is a better way to express this