Flow: `Function` has no callable signature

Created on 1 Feb 2017  路  3Comments  路  Source: facebook/flow

Function.prototype should be a callable property, currently flow complains that there is no "Callable signature".

The following is valid javascript, thus should not have flow errors:

/* @flow */
const noop = Function.prototype;
noop();

flow try

completeness enhancement

Most helpful comment

Another example of something that should work that doesn't:

// This works in JS, but flow rejects
Function('return {}')()

flow try

Use case in MDN docs

All 3 comments

I think I may be running into this issue when I use import type to import the type of a Function from another file.

import type {
  actionCreator,
} from 'redux/modules/reducer'

type Props = {
  action: actionCreator,
}

export default class TestComponent extends PureComponent<Props> {
  props: Props

  onClickHandler() {
    this.props.action()
    // ~~~~~~~~~~~~~~~
    //  [flow] call of method `action` (Callable signature not found in prototype)
  }
}

Is this the same issue?

Oh sorry, I need to use import typeof instead of import type. https://flow.org/en/docs/types/modules/#toc-importing-and-exporting-values

  • Use import type for classes.
  • Use import typeof for instances of classes and exported values, e.g. numbers, strings, functions.

Another example of something that should work that doesn't:

// This works in JS, but flow rejects
Function('return {}')()

flow try

Use case in MDN docs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamiebuilds picture jamiebuilds  路  3Comments

mmollaverdi picture mmollaverdi  路  3Comments

ctrlplusb picture ctrlplusb  路  3Comments

john-gold picture john-gold  路  3Comments

pelotom picture pelotom  路  3Comments