Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function has no callable signature #3317

Open
Naddiseo opened this issue Feb 1, 2017 · 3 comments
Open

Function has no callable signature #3317

Naddiseo opened this issue Feb 1, 2017 · 3 comments
Labels
enhancement Typing: completeness No false positives (type checker claims that there are some errors in the correct program)

Comments

@Naddiseo
Copy link

Naddiseo commented Feb 1, 2017

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

@vkurchatkin vkurchatkin added incompleteness Something is missing enhancement labels Feb 1, 2017
@ndbroadbent
Copy link

ndbroadbent commented Sep 29, 2017

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?

@ndbroadbent
Copy link

ndbroadbent commented Sep 29, 2017

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.

@duffytilleman
Copy link

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

@goodmind goodmind added Typing: completeness No false positives (type checker claims that there are some errors in the correct program) and removed incompleteness Something is missing labels Jul 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Typing: completeness No false positives (type checker claims that there are some errors in the correct program)
Projects
None yet
Development

No branches or pull requests

5 participants