typescript-runtime-type-benchmarks
typescript-runtime-type-benchmarks copied to clipboard
fix(deps): update dependency decoders to v2
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| decoders | 1.25.5 -> 2.5.0 |
Release Notes
nvie/decoders (decoders)
v2.5.0
New decoders:
v2.4.2
- Fix a regression in
taggedUnion(thanks for reporting, @βprogramever) - Upgrade all dependencies
v2.4.1
v2.4.0
New features:
- A new
.pipe()method onDecoderallows you to pass the output of one decoder into another:
This was previously possible already withstring .transform((s) => s.split(',')) // transform first... .pipe(array(nonEmptyString)); // ...then validate that result.then, but it wasn't as elegant to express. - The new
.pipe()can also dynamically select another decoder, based on the input:string .transform((s) => s.split(',').map(Number)) // transform first... .pipe((tup) => tup.length === 2 ? point2d : tup.length === 3 ? point3d : never('Invalid coordinate'), ); - Decoder error messages will now quote identifiers using single quotes, which makes them more human-readable in JSON responses. Compare: "Value at key "foo": Must be "bar", "qux"" // β Previously "Value at key 'foo': Must be 'bar', 'qux'" // β Now
- Some runtime perf optimizations
New decoders:
Removed decoders:
- Remove
numericBooleandecoder, which was deprecated since 2.3.0.
v2.3.0
New features:
- All
enumtypes are now supported (docs) - Record decoder now supports both
record(values)andrecord(keys, values)forms (docs) - Add
datelikedecoder (docs) - Add support for
bigint(docs) - Add built-in support for common string validations
- Better support for symbols in
constant()andoneOf()
New decoders:
enum_(see docs)record()(see docs)select()(see docs)bigint(see docs)datelike(see docs)decimal(see docs)hexadecimal(see docs)numeric(see docs)
Renamed decoders:
Some decoders have been renamed because their names were based on Flowisms. Names have been updated to better reflect TypeScript terminology:
dict()βrecord()maybe()βnullish()set()βsetFromArray()(to make room for a betterset()decoder in a future version)
Deprecated decoders:
The following decoders are deprecated because they were not commonly used, and a bit too specific to be in the standard library. They are also scheduled for removal in a future decoders version.
dict()(preferrecord())hardcoded()(preferalways())maybe()(prefernullish())mixed(preferunknown)numericBoolean()
Other changes:
- Fix:
positiveNumberandpositiveIntegerno longer accept-0as valid inputs - Fix:
eitherreturn type would sometimes get inferred incorrectly if members partially overlapped (see #β941) - Reorganized internal module structure
- Simplified some of the more complicated internal types
v2.2.0
Breaking change: Dropped Flow support*.
Breaking change: Projects that are not yet using strict: true in their
tsconfig.json files files are no longer supported. Previously, decoders went to great
lenghts to support both configurations, but the internal typing magic was getting too
complex to maintain without much benefit.
Breaking change: A small breaking change is introduced that removes the need for some packaging workarounds to support projects using old TypeScript/Node versions. Itβs now simpler to use, and simpler to maintain:
-import { formatInline, formatShort } from 'decoders/format'; // β
+import { formatInline, formatShort } from 'decoders'; // β
-import { Result, ok, err } from 'decoders/result'; // β
+import { Result, ok, err } from 'decoders'; // β
Other, smaller changes, mostly internal:
- Rewritten source code in TypeScript (previously Flow)
- Rewritten test suite in Vitest (previously Jest)
- Modern ESM and CJS dual exports (fully tree-shakable when using ESM)
- Further reduced bundle size
- Related, greatly simplified complex internal typing magic to make it work in projects
with and without
strictmode.
(*: I'm still open to bundling Flow types within this package, but only if that can be
supported in a maintenance-free way, for example by using a script that will generate
*.flow files from TypeScript source files. If someone can add support for that, I'm open
to pull requests! π )
v2.1.0
- Officially drop Node 12 and 14 support (they may still work)
- Fix unintentional inclusion of
lib.dom.d.tsin TypeScript
v2.0.5
- The returned value for
positiveInteger(-0)is now0, not-0 - The returned value for
positiveNumber(-0)is now0, not-0
v2.0.4
- Fix a bug in the
urldecoder, which could incorrectly reject URLs with a/in the query path. Thanks, @βgcampax!
v2.0.3
-
Fix bundling issue where TypeScript types would not get picked up correctly in old TypeScript versions. Thanks, @βrobinchow!
-
Fix TypeScript types for Resulttype to allow implicit-undefineds.
v2.0.2
Fix TypeScript types for formatShortandformatInlinehelper functions
v2.0.1
-
TypeScript-only: Fix definition of JSONObject to
reflect that its values might always be undefinedas well. -
TypeScript-only: Changed return types of
{ [key: string]: T }toRecord<string, T>. -
TypeScript-only: Fine-tune the type of
instanceOf().
v2.0.0
This is a breaking change, which brings numerous benefits:
- A simpler API π
- Smaller bundle size (67% reduction π±)
- Tree-shaking support π
- Runtime speed ποΈ
- Better documentation π
- Better support for writing your own decoders π οΈ
Please see the migration guide for precise instructions on how to adjust your v1 code.
The main change is the brand new Decoder<T> API! The tl;dr is:
| Replace this v1 pattern... | ...with this v2 API | Notes | |
|---|---|---|---|
mydecoder(input) |
β | mydecoder.decode(input) |
migration instructions |
guard(mydecoder)(input) |
β | mydecoder.verify(input) |
migration instructions |
map(mydecoder, ...) |
β | mydecoder.transform(...) |
migration instructions |
compose(mydecoder, predicate(...)) |
β | mydecoder.refine(...) |
migration instructions |
describe(mydecoder, ...) |
β | mydecoder.describe(...) |
|
mydecoder(input).value() |
β | mydecoder.value(input) |
|
either, either3, ..., either9 |
β | either |
migration instructions |
tuple1, tuple2, ... tuple6 |
β | tuple |
migration instructions |
dispatch |
β | taggedUnion |
migration instructions |
url(...) |
β | httpsUrl / url (signature has changed) |
migration instructions |
The full documentation is available on decoders.cc.
Other features:
- Include ES modules in published NPM builds (yay tree-shaking! π)
- Much smaller total bundle size (67% smaller compared to v1 π±)
Other potentially breaking changes:
- Drop support for all Node versions below 12.x
- Drop support for TypeScript versions below 4.1.0
- Drop support for Flow versions below 0.142.0
- Drop all package dependencies
- Direct reliance on
lemonshas been removed
New decoders:
Other improvements:
optional(),nullable(), andmaybe()now each take an optional 2nd param to specify a default value- Better error messages for nested
eithers
Implementation changes:
- Major reorganization of internal module structure
- Various simplification of internals
Configuration
π Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
π¦ Automerge: Disabled by config. Please merge this manually once you are satisfied.
β» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
π Ignore: Close this PR and you won't be reminded about these updates again.
- [ ] If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.