vendredi 19 mars 2021

Testing if object implements interface (type alias)

I am using a minimal testing library (Tape) which has a handful of testing methods available similar to many test frameworks. I have a type alias and an object which implements it.

export type myType = {
   myFunc(cb: (val: string) => void): void
}

const myObj = {
   myFunc: (cb) => { return }
} as myType

Using how can I test that an object implements the myType type alias using tape.equal(actual, expected) or otherwise?

Aucun commentaire:

Enregistrer un commentaire