You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ This is designed to work for projects that precompile TypeScript. It allows AVA
6
6
7
7
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`.
8
8
9
+
Compatible with AVA 6, 7 and 8. Requires Node.js 22.20, 24.12 or 25 (or newer).
10
+
9
11
## Enabling TypeScript support
10
12
11
13
Add this package to your project:
@@ -37,11 +39,15 @@ You can enable compilation via the `compile` property. If `false`, AVA will assu
37
39
38
40
Output files are expected to have the `.js` extension.
39
41
40
-
AVA searches your entire project for `*.js`, `*.cjs`, `*.mjs`, `*.ts`, `*.cts` 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.
42
+
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.
43
+
44
+
﹡ AVA 6 and 7 will also search for `*.cjs` and `*.cts` files.
41
45
42
46
## ES Modules
43
47
44
-
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.
48
+
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.
49
+
50
+
AVA 8 will _always_ import all files as ES modules.
45
51
46
52
## Add additional extensions
47
53
@@ -53,10 +59,7 @@ You can configure AVA to recognize additional file extensions. To add (partial
53
59
{
54
60
"ava": {
55
61
"typescript": {
56
-
"extensions": [
57
-
"ts",
58
-
"tsx"
59
-
],
62
+
"extensions": ["ts", "tsx"],
60
63
"rewritePaths": {
61
64
"src/": "build/"
62
65
}
@@ -69,4 +72,4 @@ If you use the [`allowJs` TypeScript option](https://www.typescriptlang.org/tsco
69
72
70
73
See also AVA's [`extensions` option](https://github.com/avajs/ava/blob/master/docs/06-configuration.md#options).
71
74
72
-
† Note that the [*preserve* mode for JSX](https://www.typescriptlang.org/docs/handbook/jsx.html) is not (yet) supported.
75
+
† Note that the [_preserve_ mode for JSX](https://www.typescriptlang.org/docs/handbook/jsx.html) is not (yet) supported.
0 commit comments