Skip to content

Commit 4b4b2f6

Browse files
committed
Refactor type definition
* Split across multiple files. * Rename types, most noticeably `TestInterface` is now `TestFn`, but really anything that had the Interface suffix has been changed. * Update some documentation.
1 parent fe12bd4 commit 4b4b2f6

File tree

10 files changed

+656
-646
lines changed

10 files changed

+656
-646
lines changed

.xo-config.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
},
2424
"overrides": [
2525
{
26-
"files": "index.d.ts",
26+
"files": [
27+
"index.d.ts",
28+
"types/*.d.ts"
29+
],
2730
"rules": {
28-
"@typescript-eslint/member-ordering": "off",
29-
"@typescript-eslint/method-signature-style": "off",
30-
"@typescript-eslint/prefer-readonly-parameter-types": "off",
31-
"@typescript-eslint/prefer-function-type": "off",
32-
"@typescript-eslint/unified-signatures": "off"
31+
"import/extensions": "off"
3332
}
3433
},
3534
{

docs/recipes/typescript.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,11 @@ test('providedTitle', macro, '3 * 3', 9);
186186

187187
## Typing [`t.context`](../01-writing-tests.md#test-context)
188188

189-
By default, the type of `t.context` will be the empty object (`{}`). AVA exposes an interface `TestInterface<Context>` which you can use to apply your own type to `t.context`. This can help you catch errors at compile-time:
189+
By default, the type of `t.context` will be the empty object (`{}`). AVA exposes an interface `TestInterface<Context>` (in AVA 4 this is `TestFn<Context>`) which you can use to apply your own type to `t.context`. This can help you catch errors at compile-time:
190190

191191
```ts
192-
import anyTest, {TestInterface} from 'ava';
192+
import anyTest, {TestInterface} from 'ava'; // AVA 3
193+
// import anyTest, {TestFn as TestInterface} from 'ava'; // AVA 4, usage is the same
193194

194195
const test = anyTest as TestInterface<{foo: string}>;
195196

@@ -213,7 +214,7 @@ test('an actual test', t => {
213214
You can also type the context when creating macros:
214215

215216
```ts
216-
import anyTest, {Macro, TestInterface} from 'ava';
217+
import anyTest, {Macro, TestInterface} from 'ava'; // AVA 3
217218

218219
interface Context {
219220
foo: string

0 commit comments

Comments
 (0)