tsdjs / tsd

Check TypeScript type definitions
MIT License
2.4k stars 67 forks source link

ts2367 not implemented, unintentional comparison #222

Open Uzlopak opened 2 hours ago

Uzlopak commented 2 hours ago

Currently implementing something for fastify, which can be simplified to:

const b: 'GET' | 'POST' = 'GET'

expectError(b === 1)
✖  534:4   Found an error that tsd does not currently support (ts2367), consider creating an issue on GitHub.                                                   
  ✖  534:16  This comparison appears to be unintentional because the types string | (string & Record<never, never>) | HTTPMethods[] and number have no overlap.

And yes I could do

expectAssignable<string>(b)

but it is less expressive imho

mrazauskas commented 2 hours ago

Perhaps: expectType<'GET'>(b)?

But just like expectError(b === 1) these lines only proof that TypeScript works as expected. I understand the example you provided is simplified. It made me curious: what are you trying to test?