mobxjs / mobx-state-tree

Full-featured reactive state management without the boilerplate
https://mobx-state-tree.js.org/
MIT License
6.9k stars 640 forks source link

is<TypeIdentifier> functions mark argument as `never` when they returns `false`. #2184

Open coolsoftwaretyler opened 3 weeks ago

coolsoftwaretyler commented 3 weeks ago

Bug report

Sandbox link or minimal reproduction code

https://codesandbox.io/p/sandbox/isoptional-type-bug-repro-9h8cqg?file=%2Fsrc%2Findex.ts%3A11%2C6-12%2C1

Describe the expected behavior

x shouldn't be type never. Should be ISimpleType<number>

Describe the observed behavior

TypeScript thinks x is of type never:

Screenshot 2024-06-07 at 8 11 16 AM

dbstraight commented 3 weeks ago

The same is true of others: isIdentifierType, isLiteralType, isPrimitiveType, isReferenceType, isUnionType, maybe others I haven't tried.

coolsoftwaretyler commented 3 weeks ago

Updated the title to reflect that (pun intended). Thank you!