From d6d237faa049576703260db44a11ec03f409a29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20=C5=BDilinskas?= Date: Wed, 15 Feb 2023 03:18:20 +0200 Subject: [PATCH 1/3] Update typescript recipe with ts-node. --- docs/recipes/typescript.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/recipes/typescript.md b/docs/recipes/typescript.md index bd2083a66..1bd922be5 100644 --- a/docs/recipes/typescript.md +++ b/docs/recipes/typescript.md @@ -76,7 +76,25 @@ If your `package.json` does not have `"type": "module"`, then this is the AVA co } ``` -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`. +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` or add environment variable for ts-node to log errors to stderr instead of throwing exception. + +`package.json`: + +```json +{ + "ava": { + "extensions": [ + "ts" + ], + "environmentVariables": { + "TS_NODE_LOG_ERROR": "true" + }, + "require": [ + "ts-node/register" + ] + } +} +``` ## Writing tests From e067431d4b2ce49417627e134ad6a1ffeebcb990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20=C5=BDilinskas?= Date: Wed, 15 Feb 2023 03:26:49 +0200 Subject: [PATCH 2/3] Rewording and grammar. --- docs/recipes/typescript.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/recipes/typescript.md b/docs/recipes/typescript.md index 1bd922be5..e3c06ec10 100644 --- a/docs/recipes/typescript.md +++ b/docs/recipes/typescript.md @@ -76,7 +76,7 @@ If your `package.json` does not have `"type": "module"`, then this is the AVA co } ``` -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` or add environment variable for ts-node to log errors to stderr instead of throwing exception. +It's worth noting that with this configuration, tests will fail if there are TypeScript build errors. Suppose you want to test while ignoring these errors. In that case, you can use `ts-node/register/transpile-only` instead of `ts-node/register` or add an environment variable for ts-node to log errors to stderr instead of throwing an exception. `package.json`: From 3644c87d1392264adf924c461b2050c9094d63d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20=C5=BDilinskas?= Date: Wed, 15 Feb 2023 03:32:23 +0200 Subject: [PATCH 3/3] Fixed formatting in code snippet. --- docs/recipes/typescript.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/recipes/typescript.md b/docs/recipes/typescript.md index e3c06ec10..06163b675 100644 --- a/docs/recipes/typescript.md +++ b/docs/recipes/typescript.md @@ -88,7 +88,7 @@ It's worth noting that with this configuration, tests will fail if there are Typ ], "environmentVariables": { "TS_NODE_LOG_ERROR": "true" - }, + }, "require": [ "ts-node/register" ]