Skip to content

Ava test() expression is not callable / has no call signatures #3349

Closed

Description

@zavoloklom

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).

Activity

  1. novemberborn commented on Nov 15, 2024

    @novemberborn
    Member

    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.

  2. KillyMXI commented on Dec 21, 2024

    @KillyMXI
    Contributor

    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.
    
  3. novemberborn commented on Dec 23, 2024

    @novemberborn
    Member

    @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.

  4. KillyMXI commented on Dec 24, 2024

    @KillyMXI
    Contributor

    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-node with "--loader=ts-node/esm" - it gives a warning about --experimental-loader, but no type errors.

    Trying to roll back versions of tsimp:

    • ava times out when using tsimp 2.0.11 and typescript 5.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.)

    image

    I've no idea how ava uses tsimp, so I'm not sure if this is enough to bring to their repo.

  5. novemberborn commented on Jan 6, 2025

    @novemberborn
    Member

    @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.

  6. cunneen commented on Feb 7, 2025

    @cunneen

    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

    Image
  7. novemberborn commented on Mar 19, 2025

    @novemberborn
    Member

    @cunneen There is a default property though, see these lines:

    ava/lib/create-chain.js

    Lines 104 to 127 in 024de32

    // The ESM and CJS type definitions export the chain (`test()` function) as
    // the default. TypeScript's CJS output (when `esModuleInterop` is disabled)
    // assume `require('ava').default` is available. The same goes for `import ava
    // = require('ava')` syntax.
    //
    // Add `test.default` to make this work. Use a proxy to avoid
    // `test.default.default` chains.
    Object.defineProperty(root, 'default', {
    configurable: false,
    enumerable: false,
    writable: false,
    value: new Proxy(root, {
    apply(target, thisArg, argumentsList) {
    target.apply(thisArg, argumentsList);
    },
    get(target, prop) {
    if (prop === 'default') {
    throw new TypeError('Cannot access default.default');
    }
    return target[prop];
    },
    }),
    });

  8. zavoloklom commented on Jul 22, 2025

    @zavoloklom
    Author

    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.

  9. sindresorhus commented on Apr 8, 2026

    @sindresorhus
    Member

    The issue here is that entrypoints/main.d.cts declares export default test, but entrypoints/main.cjs uses module.exports = value — the correct TypeScript declaration for that CJS pattern is export = test. This mismatch is a FalseExportDefault (confirmed by @arethetypeswrong/cli). TypeScript 5.6 added stricter detection of it, which tsimp now surfaces as TS2349: This expression is not callable.

    The fix is to change main.d.cts to use export = with the standard declare function + declare namespace merge pattern.

    That being said, I don't think this is worth fixing. I think it's better to just remove CommonJS support for tests. It's time.

  10. novemberborn commented on Apr 8, 2026

    @novemberborn
    Member

    @sindresorhus do you have time to implement that? main needs a major bump now anyway.

    IIRC we can require the ESM entrypoint now, so there's no need to have the CJS entrypoint.

  11. sindresorhus commented on Apr 8, 2026

    @sindresorhus
    Member

    Yup will do. Would be great with no other commits until then since it will touch a lot of files.

  12. novemberborn commented on Apr 9, 2026

    @novemberborn
    Member

    No need to get rid of all CJS, just change the entrypoint.

  13. added a commit that references this issue on Apr 9, 2026
    aba422a
  14. sindresorhus commented on Apr 9, 2026

    @sindresorhus
    Member

    I think it's better to do it fully and get everything cleaned up.

    #3437

  15. added a commit that references this issue on Apr 26, 2026
    a304990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions