ava: Ava `test()` expression is not callable / has no call signatures
I ran npm ava init in a project and created a first test as per ava docs.
Immediately the vscode editor is giving me a typescript warning error.
This expression is not callable.
Type 'typeof import("/Users/dc/dev/exiteer/xbot/server/node_modules/ava/index")' has no call signatures.

I did look if there were separate typings but there is a index.d.ts as part of the basic module that’s installed.
We’ll also need your AVA configuration (in
package.jsonorava.config.*configuration files) and how you’re invoking AVA. Share the installed AVA version (get it by runningnpx ava --version).
At this point i don’t have any config files for ava, the initial install didn’t seem to create.
FWIW this is a js file but I am leaving the typescript error checking running, i find it catches a lot of type errors even in plain JS files without type declarations.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
Commits related to this issue
- Add a mostly hidden test.default that provides test Our type definition uses ESM syntax; when using CJS with VSCode, the auto-completion assumes the root is accessed through `require('ava').default`.... — committed to avajs/ava by novemberborn 3 years ago
- Add a mostly hidden test.default that provides test Our type definition uses ESM syntax; when using CJS with VSCode, the auto-completion assumes the root is accessed through `require('ava').default`.... — committed to avajs/ava by novemberborn 3 years ago
@novemberborn
export default testin a type definition.d.tsonly works for ESM imports butexport = testwill work for both. Could we revisit the idea of usingexport = test? You can test this by creating the following type definition files and doing bothimportandrequire.Now if you replace
export default testin the above example withexport = testthe types work as expected. The below video shows this in action.https://user-images.githubusercontent.com/19195374/114308335-b65e2480-9aa0-11eb-8c9e-da374b376bc1.mp4
I also tested this with all plugins disabled in VSCode and it still happens. I also tried it with my TypeScript version set to
typescript@latest.const test = require('ava').defaultinstead ofconst test = require('ava')fixes it!That’s a great clue 😄