From 199cc70f20c79755595872274b2fb4a8e6509377 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Wed, 13 Jun 2018 07:15:59 -0700 Subject: [PATCH] Update TypeScript recipe for new extensions support --- docs/recipes/typescript.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/recipes/typescript.md b/docs/recipes/typescript.md index e58f9827f..5ce0980d7 100644 --- a/docs/recipes/typescript.md +++ b/docs/recipes/typescript.md @@ -6,6 +6,28 @@ AVA comes bundled with a TypeScript definition file. This allows developers to l This guide assumes you've already set up TypeScript for your project. Note that AVA's definition has been tested with version 2.8.3. +## Configuring AVA to compile TypeScript files on the fly + +You can configure AVA to recognize TypeScript files. Then, with `ts-node` installed, you can compile them on the fly: + +```json +{ + "ava": { + "compileEnhancements": false, + "extensions": [ + "ts" + ], + "require": [ + "ts-node/register" + ] + } +} +``` + +It's worth noting that with this configuration tests will fail if there are TypeScript build errors. If you want to test while ignoring these errors you can use `ts-node/register/transpile-only` instead of `ts-node/register`. + +## Compiling TypeScript files before running AVA + Add a `test` script in the `package.json` file. It will compile the project first and then run AVA. ```json