Full Changelog: 0.15.0...0.16.0
Breaking changes
Change type guards to return never instead of false
Previously when invoking the isOk
on Err type or isErr
on Ok 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 isErr or isOk on a type that
does not reflect it.
Example:
const ok = Ok(42);
// Previously this was accepted and the type was inferred as Ok in the
// code block
if (ok.isErr()) {
ok;
// ^? Ok<number>;
}
// However now the type would be never, which is less flexible, but
// correct behaviour
if (ok.isErr()) {
ok;
// ^? never
}
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:
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
}
Changes
Add terser to minify code published to npm
Terser is a JavaScript mangler/compressor. More info here:
https://github.com/terser/terser
By utilizing terser the size of the output distribution files is
considerable smaller as the code is compressed and mangled to minimum
functional state. Terser also removes comments, which in turn replaces
the naive comment remove solution that was relying on regex.
The compressed output file size is around 50% smaller from 4.33kb to
2.2kb for option module.
Fixes
Fix details tags in Option and Result README
Some of the details tags were missing ending tag counterpart.