-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Description
🚀 Feature Proposal
this will always fail, but since typescript infers the type as unknown, there's no compile error:
expect('foo').toBe(1) // no error
expect<string>('foo').toBe(1) // no errorMotivation
it will allow you to identify errors in your tests much earlier, speeding up development 🚀🚀🚀
Example
// the new and improved expect 🚀:
declare const expect: <T>(actual: T) => { toBe: (expected: T) => void}
// usage:
expect('foo').toBe(1) // TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.Pitch
the current expect types make using typescript with jest pretty much useless. i think if jest is going to support typescript, it should support basic functionality like this
DetachHead, Isaius, michal-kocarek, sand4rt, CreativeTechGuy and 5 more