Closed
Description
TypeScript Version: 3.1.6 (previous: 3.0.1)
Code
const data = typeof fetcherParams === 'function'
? fetcherParams()
: fetcherParams
It doesn't work for me. Also, I tried to use instanceof
and it works:
const data = fetcherParams instanceof Function
? fetcherParams()
: fetcherParams
Expected behavior: no error with typeof
statement
Actual behavior:
TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Function | (() => object)' has no compatible call signatures.
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
jack-williams commentedon Nov 15, 2018
I think this is working as intended after a (breaking) change in 3.1.
Read here.
weswigham commentedon Nov 15, 2018
Working as intended, technically, but the union of an untyped call and a typed call should still be callable. (Likely as the typed call but with an untyped return)