question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

t.throw flow type check is giving a false-positive (Callable signature not found in)

See original GitHub issue

Description

I am getting an “Callable signature not found in” when using t.throws.

The type error originates in the node_modules/ava/index.js.flow definition.

This could be simply me misunderstanding what the error is saying.

I’d expect Flow to pickup:

throws(value: Promise<mixed>, error?: ErrorValidator, message?: string): Promise<mixed>;

annotation and ignore:

throws(value: () => void, error?: ErrorValidator, message?: string): mixed;

I even explicitly cast the result to Promise<void>.

If I remove the Promise<void> cast, I am getting a different error, https://gist.github.com/gajus/5c42f0262874a2bae7842691eea28a60#file-ava-flow-sh-L2.

Test Source

test('timesout after 60 seconds', async (t): Promise<void> => {
  const {
    document
  } = createDocument();

  global.document = document;

  const result: Promise<void> = loadScript('http://dailymail.co.uk/');

  clock.tick(6e4 + 1);

  t.throws(result, 'Script loading time has exceeded the maximum configured time limit.');
});

Error Message & Stack Trace

$ flow
node_modules/ava/index.js.flow:71
 71: 	throws(value: () => void, error?: ErrorValidator, message?: string): mixed;
     	              ^^^^^^^^^^ function type. Callable signature not found in
 94:   t.throws(result, 'Script loading time has exceeded the maximum configured time limit.');
                ^^^^^^ Promise. See: test/utilities/loadScript.js:94


Found 1 error

Config

Copy the relevant section from package.json:

{
  "ava": {
    "babel": {
      "plugins": [
        "transform-flow-strip-types",
        "transform-async-to-generator",
        "transform-es2015-modules-commonjs"
      ]
    },
    "require": [
      "babel-register"
    ]
  }
}

Command-Line Arguments

ava

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:

Node.js v7.2.1
darwin 16.1.0
0.17.0
3.10.10

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jamestalmagecommented, Dec 8, 2016

pinging @thejameskyle

0reactions
leebyroncommented, Feb 2, 2017

A simpler repro case is simply:

t.throws(Promise.reject(new Error()))

Which yields:

index.js.flow:61
 61: 	throws(value: () => void, error?: ErrorValidator, message?: string): mixed;
     	              ^^^^^^^^^^ function type. Callable signature not found in
 13:   t.throws(Promise.reject(new Error()))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Promise. See: test.js.flow:13
Read more comments on GitHub >

github_iconTop Results From Across the Web

`Function` has no callable signature · Issue #3317 - GitHub
Function.prototype should be a callable property, currently flow complains that there is no "Callable signature".
Read more >
Cannot call `data` because a callable signature is missing in ...
I am trying to declare the type of a function that can take function or object as a parameter, but the result is...
Read more >
Types-First | Flow
Flow checks codebases by processing each file separately in dependency order. After a file has been checked, a signature is extracted and stored...
Read more >
Advanced googletest Topics
This has the problem of not showing you the values of the parts of the expression, making it hard to understand what went...
Read more >
Service | Android Developers
A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found