Skip to content

Commit

Permalink
Clarify usage with AVA 3
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn authored Nov 16, 2021
1 parent a3b205a commit fe34ddd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# @ava/typescript

Adds [TypeScript](https://www.typescriptlang.org/) support to [AVA](https://avajs.dev).
Adds [TypeScript](https://www.typescriptlang.org/) support to [AVA 4](https://avajs.dev).

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

## For AVA 3 users

Use version 2:

```console
npm install --save-dev @ava/typescript@2
```

Note that v2 does not support ES modules. This requires v3 and AVA 4.

## Enabling TypeScript support

Add this package to your project:
Expand Down Expand Up @@ -41,7 +51,7 @@ AVA searches your entire project for `*.js`, `*.cjs`, `*.mjs` and `*.ts` files (

## ES Modules

When used with AVA 4, 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.
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.

## Add additional extensions

Expand Down

0 comments on commit fe34ddd

Please # to comment.