Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change type guards to return
never
instead of false
in option
Previously when invoking the `isSome` on None type or `isNone` on Some type would return always false and the corresponding type would be set as the original type. This however does not work with the newest TypeScript version `5.5.3`. The failure in this case is correct as the inference does not work as expected if a false is returned instead of a type guard. The 'correct' change here is to instead return never type guard as we can never enter that block that checks for isNone or isSome on a type that does not reflect it. Example: ```ts const some = Some(42); // Previously this was accepted and the type was inferred as Some in the // code block if (some.isNone()) { some; // ^? Some<number>; } // However now the type would be never, which is less flexible, but // correct behaviour if (some.isNone()) { some; // ^? never } ```
- Loading branch information