Skip to content

Commit

Permalink
add loader example
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Jul 22, 2024
1 parent 23729ab commit a611a02
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
/test/**/fixtures/**/node_modules/*/
/examples/**/node_modules/
/examples/**/package-lock.json
/examples/**/build/
1 change: 1 addition & 0 deletions examples/typescript-basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
1 change: 1 addition & 0 deletions examples/typescript-context/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
1 change: 1 addition & 0 deletions examples/typescript-loader/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.tsimp
1 change: 1 addition & 0 deletions examples/typescript-loader/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const multiply = (a: number, b: number) => a * b;
22 changes: 22 additions & 0 deletions examples/typescript-loader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "ava-typescript-context",
"description": "TypeScript example for typing t.context",
"type": "module",
"scripts": {
"test": "ava"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^6.0.0",
"ava": "^6.1.3",
"tsimp": "^2.0.11",
"typescript": "~5.5.3"
},
"ava": {
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--import=tsimp"
]
}
}
5 changes: 5 additions & 0 deletions examples/typescript-loader/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TypeScript loader example

> TypeScript example for configuring AVA with [ESM loaders](https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md#enabling-avas-support-for-typescript-test-files)
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/typescript-loader?file=test.ts&terminal=test&view=editor)
8 changes: 8 additions & 0 deletions examples/typescript-loader/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import test from 'ava';

import { multiply } from './index.js';

test('multiply', (t) => {
t.is(multiply(1, 0), 0);
t.is(multiply(2, 3), 6);
});
3 changes: 3 additions & 0 deletions examples/typescript-loader/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@sindresorhus/tsconfig"
}

0 comments on commit a611a02

Please sign in to comment.