ava
ava copied to clipboard
Ava test() expression is not callable / has no call signatures
After updating Typescript from 5.5.4 to 5.6.3 i started to have an error
error TS2349: This expression is not callable.
Type 'typeof import("<full_path_to_project>/node_modules/ava/entrypoints/main")' has no call signatures.
Version of ava - 6.2.0 Version of Typescript - 5.6.3 Version of tsimp - 2.0.12
ava config
export default {
files: ['tests/**/*.spec.ts'],
extensions: {
ts: 'module',
},
nodeArguments: ['--import=tsimp/import', '--no-warnings'],
timeout: '2m',
serial: true,
concurrency: 1,
};
test example
import test from 'ava';
import type { ExecutionContext } from 'ava';
test('example', (t: ExecutionContext) => {
t.is('8080', '8080');
});
I expect not to have this warning from Typescript when using Ava.
There was similar issue #2539, but it's closed and nothing from comments there helping me (first of all because I can not use require syntax).
Can you reproduce this outside of your project? With and without tsimp/import? Nothing would have changed in AVA so it suggests a problem elsewhere.
Same issue. Same versions of ava, TypeScript, tsimp.
Tests are still passing, but there are also these error messages in the output. The one as reported above and the other:
error TS7006: Parameter 't' implicitly has an 'any' type.
@KillyMXI Can you reproduce this outside of your project? With and without tsimp/import? Nothing would have changed in AVA so it suggests a problem elsewhere.
All experiments done with Node.js v20.18.0
The issue reproduces if I bump typescript version to 5.6.3 or 5.7.2.
Trying to replace tsimp:
tsx- can't make it work anymore;ts-nodewith"--loader=ts-node/esm"- it gives a warning about--experimental-loader, but no type errors.
Trying to roll back versions of tsimp:
avatimes out when usingtsimp2.0.11 andtypescript5.6.3 or 5.7.2 - only works with 5.5.4. No useful messages in case of timeout:
> npx ava --verbose
✘ Timed out while running tests
Failed to exit when running test-ava\test.ts
Trying tsimp 2.0.12 and typescript 5.5.4 (clean npm i) - no errors.
tsimp 2.0.11 |
tsimp 2.0.12 |
|
|---|---|---|
typescript 5.5.4 |
fine | fine |
typescript 5.6.3, 5.7.2 |
timeout | test pass with displayed errors |
After facing the issue in one of my packages repo, I reproduced this in my playground repo with a single trivial test. My repro branch: https://github.com/mxxii/yet-another-typescript-package-template/tree/tsimp-issue-repro Test run log with the error messages: https://github.com/mxxii/yet-another-typescript-package-template/actions/runs/12484026510/job/34840790959#step:5:10 (Edit: logs are not public, but the error messages are also shown in the Annotations section.)
I've no idea how ava uses tsimp, so I'm not sure if this is enough to bring to their repo.
@KillyMXI
I've no idea how ava uses tsimp, so I'm not sure if this is enough to bring to their repo.
AVA doesn't, you are through your config. Raising an issue with them makes sense, I can help point out how AVA loads files etc if needed.
This seems to be related to typescript issue #54593 together with how ava is packaged for dual CJS/ESM
See how 'arethetypeswrong' reports ava's npm package
@cunneen There is a default property though, see these lines: https://github.com/avajs/ava/blob/024de32a15aba9fac4002aa8d3c2c076955f44f4/lib/create-chain.js#L104-L127
Just wanted to share a workaround for this issue. You can suppress TypeScript compilation errors in AVA/TSIMP by setting the TSIMP_DIAG environment variable in your AVA config:
export default {
...
environmentVariables: {
TSIMP_DIAG: 'ignore',
}
};
But this will ignore all TypeScript diagnostics.