avajs / typescript

Test TypeScript projects using AVA.
MIT License
73 stars 16 forks source link

Investigate custom, TypeScript-specific assertions #21

Closed novemberborn closed 3 years ago

novemberborn commented 4 years ago

Coming out of discussions in https://github.com/avajs/ava/issues/2449 we may want to consider supporting additional assertions for use with TypeScript. Say a t.guard(obj, fn) which can be used in an if condition:

if (t.guard(fooOrBar, isFoo)) {
  // Do stuff know that we know fooOrBar is Foo
}

Of course AVA does not support custom assertions yet, but keep an eye on https://github.com/avajs/ava/pull/2435.

We'll also have to consider how you might import a test function that has these assertions installed.