MCPcopy Index your code
hub / github.com/avajs/typescript

github.com/avajs/typescript @v7.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v7.0.0 ↗ · + Follow
24 symbols 63 edges 17 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@ava/typescript

Adds TypeScript support to AVA.

This is designed to work for projects that precompile TypeScript. It allows AVA to load the compiled JavaScript, while configuring AVA to treat the TypeScript files as test files.

In other words, say you have a test file at src/test.ts. You've configured TypeScript to output to build/. Using @ava/typescript you can run the test using npx ava src/test.ts.

Compatible with AVA 6, 7 and 8. Requires Node.js 22.20, 24.12 or 25 (or newer).

Enabling TypeScript support

Add this package to your project:

npm install --save-dev @ava/typescript

Then, enable TypeScript support either in package.json or ava.config.*:

package.json:

{
    "ava": {
        "typescript": {
            "rewritePaths": {
                "src/": "build/"
            },
            "compile": false
        }
    }
}

Both keys and values of the rewritePaths object must end with a /. Paths are relative to your project directory.

You can enable compilation via the compile property. If false, AVA will assume you have already compiled your project. If set to 'tsc', AVA will run the TypeScript compiler before running your tests. This can be inefficient when using AVA in watch mode.

Output files are expected to have the .js extension.

AVA searches your entire project for *.js, *.mjs, *.ts and *.mts files﹡ (or other extensions you've configured). It will ignore such files found in the rewritePaths targets (e.g. build/). If you use more specific paths, for instance build/main/, you may need to change AVA's files configuration to ignore other directories.

﹡ AVA 6 and 7 will also search for *.cjs and *.cts files.

ES Modules

With AVA 6 and 7, if your package.json has configured "type": "module", or you've configured AVA to treat the js extension as module, then @ava/typescript will import the output file as an ES module. Note that this is based on the output file, not the ts extension.

AVA 8 will always import all files as ES modules.

Add additional extensions

You can configure AVA to recognize additional file extensions. To add (partial†) JSX support:

package.json:

{
    "ava": {
        "typescript": {
            "extensions": ["ts", "tsx"],
            "rewritePaths": {
                "src/": "build/"
            }
        }
    }
}

If you use the allowJs TypeScript option you'll have to specify the js, cjs and mjs extensions for them to be rewritten.

See also AVA's extensions option.

† Note that the preserve mode for JSX is not (yet) supported.

Core symbols most depended-on inside this repo

validateConfig
called by 13
test/protocol-ava-6.js
validateConfig
called by 13
test/protocol-ava-8.js
createProviderMacro
called by 8
test/_with-provider.js
setup
called by 3
test/load.js
compile
called by 3
test/compilation.js
isPlainObject
called by 2
index.js
validate
called by 1
index.js
compileTypeScript
called by 1
index.js

Shape

Function 24

Languages

TypeScript100%

Modules by API surface

index.js14 symbols
test/_with-provider.js5 symbols
test/protocol-ava-8.js1 symbols
test/protocol-ava-6.js1 symbols
test/load.js1 symbols
test/fixtures/install-and-load.js1 symbols
test/compilation.js1 symbols

For agents

$ claude mcp add typescript \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact