tsdjs / tsd

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

does not catch `never` type #78

Closed dgreene1 closed 3 years ago

dgreene1 commented 4 years ago

Expected Behavior:

I would expect the following to fail. It does not.

const result: never = () => { throw new Error() };

expectType<string>(result);
BendingBender commented 3 years ago

@dgreene1 @fregante @sindresorhus I've tried to reproduce this issue in the latest version of tsd without success. Can you please confirm that the latest version of tsd is not affected by this?

JGJP commented 9 months ago

@BendingBender I can confirm that the latest version of tsd is affected by this. The original example needed some amending though:

const returnsNever = () => { throw new Error() }
const result: never = returnsNever()
expectType<string>(result)
JGJP commented 9 months ago

@BendingBender This fails appropriately when using ts-expect:

expectType<TypeEqual<string, never>>(true)