io-ts
Version:
TypeScript runtime type system for IO decoding/encoding
897 lines (669 loc) • 23 kB
Markdown
# Changelog
> **Tags:**
>
> - [New Feature]
> - [Bug Fix]
> - [Breaking Change]
> - [Documentation]
> - [Internal]
> - [Polish]
> - [Experimental]
> - [Deprecation]
**Note**: Gaps between patch versions are faulty/broken releases.
**Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.
# 2.2.22
- **Bug Fix**
- Test for readonly type when optimizing tagged unions, #719
# 2.2.21
- **Bug Fix**
- Handle `record` keys outside `domain`, #705 ( )
# 2.2.20
- undeprecate `FunctionType`, `FunctionC`, `Function`
- undeprecate `NeverType`, `NeverC`, `never`
- undeprecate `AnyType`, `AnyC`, `any`
- undeprecate `RefinementC`, `refinement`, `Integer`
- add refinement overload to allow custom branding, closes #373
# 2.2.19
- **Bug Fix**
- allow `Error` to be decoded with `UnknownRecord`, #664 ( )
# 2.2.18
- **Bug Fix**
- fix `typescript@4.8` errors, closes #656, closes #647 ( )
# 2.2.17
- **Bug Fix**
- Don't throw a TypeError when trying to decode a sum value that contains a dangerous string, #650 ( )
# 2.2.16
Experimental modules require `fp-ts@^2.5.0`.
- **Experimental**
- `Codec`
- add `readonly` combinator ( )
- `Encoder`
- add `readonly` combinator ( )
# 2.2.15
- **Experimental**
- `Schemable`
- (\*) add `readonly` combinator ( )
- (\*) add `struct` combinator ( )
- deprecate `type` in favour of `struct` ( )
- deprecate `fromType` in favour of `fromStruct` ( )
(\*) breaking change
# 2.2.14
- **Experimental**
- `Guard`
- relax `UnknownRecord` check, closes #559 ( )
# 2.2.13
- **Bug Fix**
- improve internal `mergeAll` function, closes #532 ( )
# 2.2.12
- **Experimental**
- (\*) make `sum` safer, closes #523 ( )
(\*) breaking change
In case of non-`string` tag values, the respective key must be enclosed in brackets
```ts
export const MySum: D.Decoder<
unknown,
| {
type: 1 // non-`string` tag value
a: string
}
| {
type: 2 // non-`string` tag value
b: number
}
> = D.sum('type')({
[1]: D.type({ type: D.literal(1), a: D.string }),
[2]: D.type({ type: D.literal(2), b: D.number })
})
```
# 2.2.11
- **Experimental**
- `Decoder`
- make `toForest` stack-safe, #520 ( )
# 2.2.10
- **Polish**
- expose modules without lib/es6 prefix, #507 ( )
# 2.2.9
- **Polish**
- remove `Object.freeze` calls, closes #497 ( )
- **Experimental**
- `DecodeError`
- add `Wrap` member ( )
- `Decoder`
- add `withMessage` combinator ( )
- `TaskDecoder`
- add `withMessage` combinator ( )
# 2.2.8
- **Experimental**
- (\*) remove `KleisliDecoder` module ( )
- (\*) remove `KleisliTaskDecoder` module ( )
- (\*) remove `JsonCodec` module ( )
- (\*) remove `JsonEncoder` module ( )
- `Codec`
- (\*) make `Codec` more general by adding a `I` type parameter ( )
- add `fromType` function ( )
- add `fromPartial` function ( )
- add `fromArray` function ( )
- add `fromRecord` function ( )
- add `fromTuple` function ( )
- add `fromSum` function ( )
- add `compose` function ( )
- `Decoder`
- (\*) make `Decoder` more general by adding a `I` type parameter ( )
- add `fromRefinement` function ( )
- change `fromGuard` signature ( )
- add `fromType` function ( )
- add `fromPartial` function ( )
- add `fromArray` function ( )
- add `fromRecord` function ( )
- add `fromTuple` function ( )
- add `fromSum` function ( )
- add `compose` function ( )
- add `id` function ( )
- (\*) rename `functorDecoder` instance to `Functor` ( )
- (\*) rename `altDecoder` instance to `Alt` ( )
- (\*) rename and split `schemableDecoder` ( )
- add `Category` instance ( )
- add `InputOf` type ( )
- `TaskDecoder`
- (\*) make `TaskDecoder` more general by adding a `I` type parameter ( )
- add `fromRefinement` function ( )
- change `fromDecoder` signature ( )
- add `fromType` function ( )
- add `fromPartial` function ( )
- add `fromArray` function ( )
- add `fromRecord` function ( )
- add `fromTuple` function ( )
- add `fromSum` function ( )
- add `compose` function ( )
- add `id` function ( )
- (\*) rename `functorTaskDecoder` instance to `Functor` ( )
- (\*) rename `altTaskDecoder` instance to `Alt` ( )
- (\*) rename and split `schemableTaskDecoder` ( )
- add `Category` instance ( )
- add `InputOf` type ( )
- `Guard`
- (\*) make `Guard` more general by adding a `I` type parameter ( )
- (\*) rename `schemableGuard` ( )
- add `InputOf` type ( )
- add `alt` function ( )
- add `zero` function ( )
- add `compose` function ( )
- add `id` function ( )
- `Codec`
- (\*) rename `invariantCodec` to `Invariant` ( )
- `Encoder`
- (\*) rename `contravariantEncoder` to `Contravariant` ( )
- (\*) rename `categoryEncoder` to `Category` ( )
- `Eq`
- (\*) rename and split `schemableEq` ( )
- `Kleisli`
- add `id` ( )
- rename `type` to `fromType` ( )
- rename `partial` to `fromPartial` ( )
- rename `array` to `fromArray` ( )
- rename `record` to `fromRecord` ( )
- rename `tuple` to `fromTuple` ( )
- rename `sum` to `fromSum` ( )
- `Schemable`
- add `Schemable2C`, `WithUnknownContainers2C`, `WithUnion2C`, `WithRefine2C` ( )
- `Type`
- (\*) rename and split `schemableType` ( )
(\*) breaking change
# 2.2.7
- **Experimental**
- add `DecodeError` module ( )
- add `FreeSemigroup` module ( )
- add `TaskDecoder` module ( )
- add `Kleisli` module ( )
- add `KleisliDecoder` module ( )
- add `KleisliTaskDecoder` module ( )
- (\*) remove `NaN` from `number` instances ( )
- (\*) remove `Tree` module ( )
- (\*) make `Json` type immutable ( )
- `Decoder`
- (\*) remove `never` ( )
- (\*) make `parse` pipeable and change its `parser` argument ( )
- (\*) change `DecoderError` ( )
- (\*) remove `withExpected` in favour of `mapLeftWithInput` ( )
- `Guard`
- (\*) remove `never` ( )
- `Schemable`
- (\*) better `literal` signature ( )
- (\*) better `union` signature ( )
- (\*) make intersections pipeables ( )
- (\*) make refinements pipeables ( )
(\*) breaking change
# 2.2.6
- **Experimental**
- `Decoder`
- add support for non-`string` tag values to `sum`, closes #481 ( )
- `intersection` should accumulate all errors ( )
# 2.2.5
- **Experimental**
- fix type information lost from nested decoder types, #479 ( )
- `JsonEncoder`
- change `id` signature ( )
# 2.2.4
- **Polish**
- remove the dependency on the `either` instance as a mean of improving tree shaking ( )
# 2.2.3
- **Polish**
- use the built-in `Readonly` type in `readonly` combinator, closes #472 ( )
- **Experimental**
- split instances ( )
- add `Type` experimental module, #464 ( )
- restore the `O` type parameter to `Encoder`, #469 ( )
- add the `O` type parameter to `Codec` ( )
- add `JsonCodec` experimental module ( )
- add `JsonEncoder` experimental module ( )
- `Schemable`
- rename `Schemable` interface to `Schemable1` ( )
- rename `WithUnion` interface to `WithUnion1` ( )
- add `Schemable` interface ( )
- add `WithUnion` interface ( )
- add `WithRefinement` / `WithRefinement1` interfaces ( )
- add `WithUnknownContainers` / `WithUnknownContainers1` interfaces ( )
- move `UnknownArray` and `UnknownRecord` to `WithUnknownContainers` ( )
- `Schema`
- refactoring with the new `Schemable` interface ( )
- add `interpreter` function ( )
- **Internal**
- upgrade to `typescript@3.9.3` ( )
# 2.2.2
- **Experimental**
- add `Eq` module ( )
- `Codec`
- add `TypeOf` operator ( )
- `Decoder`
- add `DecodeError` interface ( )
- `Encoder`
- add `TypeOf` operator ( )
- `Guard`
- add `TypeOf` operator ( )
# 2.2.1
- **Experimental**
- `Decoder`
- collect all errors while decoding, closes #449 ( )
# 2.2.0
- **Experimental**
- add `Codec`, `Decoder`, `Encoder`, `Guard`, `Schema`, `Schemable`, `Tree` modules ( )
# 2.1.3
- **Polish**
- remove useless `hasOwnProperty` calls, closes #423 ( )
# 2.1.1
- **Bug Fix**
- fix `record` domain handling, closes #391 ( )
# 2.1.0
- **New Feature**
- add `bigint` codec ( )
# 2.0.6
- **Bug Fix**
- whitelist `window` in `UnknownRecord`, fix #413 ( )
# 2.0.5
- **Bug Fix**
- `partial` shouldn't allow arrays, fix #407 ( )
# 2.0.4
- **Bug Fix**
- remove getters, fix #404 ( )
# 2.0.3
- **Bug Fix**
- rewrite es6 imports ( )
# 2.0.2
- **Bug Fix**
- fix #397 ( )
# 2.0.1
- **Bug Fix**
- fix `getTags` algorithm for mutually recursive codecs, closes #354 ( )
# 2.0.0
- **Breaking Change**
- upgrade to `fp-ts@2.x` ( )
- move `fp-ts` to `peerDependencies` ( )
# 1.10.4
- **Polish**
- remove unneeded internal code ( )
# 1.10.3
- **Bug Fix**
- revert `1.10.0` compatibility, fix #344 ( )
# 1.10.2
- **Bug Fix**
- move `fp-ts` back to dependencies ( )
# 1.10.1
- **Bug Fix**
- handle `strict`, `exact` and `refinement` codecs when optimizing tagged unions, fix #339 ( )
# 1.10.0
- **New Feature**
- make `io-ts` compatible with both `fp-ts@1.x`, `fp-ts@2.x` ( )
# 1.9.0
- **New Feature**
- `union` is now able to detect and optimize tagged unions ( )
- **Deprecation**
- deprecate `taggedUnion` in favour of `union` ( )
# 1.8.6
output ES modules to better support tree-shaking, closes #326 ( )
# 1.8.5
- **Bug Fix**
- change how types and output types are retrieved in `IntersectionC` and `TupleC`, fix #315 ( )
# 1.8.4
- **Polish**
- autobind `decode` method ( )
# 1.8.3
- **Polish**
- add `stripInternal` flag to `tsconfig.json` ( )
- handle `NaN` in `PathReporter` ( )
- throw if union encoding doesn't find a usable codec ( )
- **Deprecation**
- deprecate `NeverType` ( )
- deprecate `FunctionType` ( )
# 1.8.2
- **Bug Fix**
- align the runtime behavior of `Exact.is` with the type system, fix #288 ( )
# 1.8.1
- **New Feature**
- add `brand` combinator ( , )
- add `Int` codec ( )
- `exact` strips additional properties while decoding / encoding ( )
- un-deprecate `strict` combinator, is now an alias of `exact(type(...))` ( )
- **Bug Fix**
- fix wrong context keys for tagged unions ( )
- **Deprecation**
- deprecate `refinement` combinator in favour of `brand` ( )
- deprecate `Integer` codec in favour of `Int` ( )
- deprecate `StrictType` class ( )
- deprecate `StrictC` interface ( )
- **Polish**
- modify the implementation of `intersection` in order to support combinators that strip additional properties ( )
- do not validate the codomain of a key of a record if its domain in invalid ( )
- normalize missing `message` field in `ValidationError` ( )
- fix name of recursive codec definitions ( )
- remove unexpected validation path from partial type, closes #195 ( )
- do not leak taggedUnion implementation when tag validation fails ( )
- add `actual` value to all context entries ( )
- `exact` now bails out when the value is not an `UnknownRecord` ( )
- `tuple` should not leak the implementation (`never` usage) ( )
- `exact` should not leak the implementation (`never` usage) ( )
- use `Number.isInteger` in `Integer` implementation ( )
- use the Flow convention to name `exact` codecs ( )
# 1.7.1
- **Deprecation**
- deprecate `any` ( )
- deprecate `object` ( )
- deprecate `Dictionary` in favour of `UnknownRecord` ( )
- deprecate `Array` in favour of `UnknownArray` ( )
- deprecate `dictionary` in favour of `record` ( )
# 1.7.0
- **New Feature**
- better support for custom messages, closes #148 ( )
- add optional message field to `ValidationError`
- add `message` argument to `failure`
- `PathReporter` should account for the new field
- add `actual` optional field to `ContextEntry`, closes #194 ( )
- **Deprecation**
- deprecate `getValidationError` ( )
- deprecate `getDefaultContext` ( )
# 1.6.4
- **Bug Fix**
- `getIndexRecord`: getIndexRecord: handle conflicting tags in different positions, ref #263 ( )
- **Experimental**
- added a warning to the console if a tagged union cannot be created ( )
- revert `union` optimization, needs more work to make it happen ( )
# 1.6.3
- **Bug Fix**
- prevent maximum call stack size exceeded when indexing recursive codecs, closes #259 ( )
# 1.6.2
- **Polish**
- make `isIndexableCodec` more strict ( )
# 1.6.1
- **Bug Fix**
- `taggedUnion` should handle sub unions / tagged unions correctly, closes #257 ( )
- **Experimental**
- optimize `union` with the same algorithm used in `taggedUnion` ( )
# 1.6.0
**Important**. This version requires `typescript@3.2.2+`
- **New Feature**
- leverage `typescript@3.2.2` ( )
- `TypeC`
- `PartialC`
- `RecordC`
- `UnionC`
- `ReadonlyC`
- `StrictC`
- `TaggedUnionC`
# 1.5.3
- **Bug Fix**
- missing context info while decoding an intersection, fix #246 ( )
- **Experimental**
- add intermediary interfaces, closes #165 ( )
- `NullC`
- `UndefinedC`
- `VoidC`
- `AnyC`
- `UnknownC`
- `NeverC`
- `StringC`
- `NumberC`
- `BooleanC`
- `UnknownArrayC`
- `UnknownRecordC`
- `ObjectC`
- `FunctionC`
- `RefinementC`
- `LiteralC`
- `KeyofC`
- `ArrayC`
- `TypeC`
- `PartialC`
- `RecordC`
- `UnionC`
- `IntersectionC`
- `TupleC`
- `ReadonlyC`
- `ReadonlyArrayC`
- `StrictC`
- `TaggedUnionC`
- `ExactC`
- **Polishs**
- use rest elements in tuple types (`typescript@3.0.1` feature) ( )
- `union` should handle zero types ( )
- `intersection` should handle zero / one types ( )
- **Deprecation**
- deprecate `clean` ( )
- deprecate `alias` ( )
- deprecate `PropsOf` type ( )
- deprecate `Exact` type ( )
# 1.5.2
- **Deprecation**
- deprecate `Compact` type ( )
# 1.5.1
- **Polish**
- remove useless module augmentation of `Array` ( )
# 1.5.0
- **New Feature**
- add `UnknownType`, closes #238 ( )
- **Deprecation**
- `ThrowReporter` is now deprecated ( )
# 1.4.2
use `Compact` in `intersection` signatures as a workaround for #234 ( )
# 1.4.1
- **Polish**
- `Type.prototype.pipe` now allows more types as input, #231 #232 ( )
# 1.4.0
- **New Feature**
- use `unknown` as `mixed` ( )
# 1.3.4
- **Bug Fix**
- should emit expected keys while decoding, fix #214 ( )
# 1.3.3
- **Bug Fix**
- align `TaggedExact` definition with siblings, fix #223 ( )
# 1.3.2
- **Bug Fix**
- dictionary type should not allow arrays, fix #218 ( )
# 1.3.1
- **Polish**
- use interface instead of type alias ( )
- `Context`
- `Errors`
- `Any`
- `Mixed`
# 1.3.0
- **New Feature**
- add `TaggedUnionType` ( )
# 1.2.1
- **Polish**
- allow recursive types in tagged unions ( )
# 1.2.0
- **New Feature**
- add `void` runtime type ( )
# 1.1.5
- **Bug Fix**
- partial combinator should preserve additional properties while encoding, fixes #179 ( )
- **Polish**
- use `useIdentity` when possible ( )
# 1.1.4
- **Internal**
- fix broken build with `typescript@2.9.1`, closes #174 ( )
# 1.1.3
- **Internal**
- upgrade to `typings-checker@2.0.0` ( )
# 1.1.2
- **Bug Fix**
- fix `alias` implementation ( )
- handle exact types in `isTagged` ( )
# 1.1.1
- **Experimental**
- add `clean` / `alias` functions, closes #149 ( )
- add `exact` combinator ( )
- the `strict` combinator is deprecated
- remove `optional` combinator ( )
- it doesn't play well with advanced combinators, see [here](https://github.com/gcanti/io-ts/issues/140) for a discussion
# 1.0.6
- **Bug Fix**
- `taggedUnion` fails to decode when tag values are not string literals, fix #161 ( )
# 1.0.5
- **Bug Fix**
- workaround for upstream TypeScript bug 14041 (wrong generated declarations) ( )
- **Internal**
- optimize InterfaceType.encode ( )
- use definite assignment assertion for phantom fields ( )
# 1.0.4
- **Bug Fix**
- make `Context` readonly ( )
- **Internal**
- optimizations, #137 ( , )
# 1.0.3
- **Internal**
- optimizations, #134 ( , )
# 1.0.2
- **Bug Fix**
- fix `OutputOfPartialProps` name ( )
# 1.0.1
- **Bug Fix**
- fix `AnyType` by extending `Type<any>` ( )
# 1.0.0
- **Breaking Change**
- upgrade to `fp-ts@1.0.0`
- see https://github.com/gcanti/io-ts/pull/112 (@gcanti)
# 0.9.8
- **New Feature**
- add decode and deprecate top level validate ( )
- **Internal**
- when checking validations use methods instead of top level functions ( )
# 0.9.7
- **New Feature**
- add `taggedUnion` combinator ( , )
# 0.9.6
- **New Feature**
- `recursive` combinator
- add support for mutually recursive types, closes #114 ( )
- make it safer: `RT` now must extend `Type<mixed, A>` ( )
# 0.9.5
- **New Feature**
- add `mixed` type ( )
- replace `any` with `mixed` in all input type parameters ( )
```diff
-export class StringType extends Type<any, string> {
+export class StringType extends Type<mixed, string> {
}
```
# 0.9.4
- **Bug Fix**
- strict: should succeed validating an undefined field, closes #106 ( )
# 0.9.3
- **Bug Fix**
- revert 37c74a5e2038de063a950f9ba8d18b1f132ef450, closes #8 ( )
# 0.9.2
- **New Feature**
- add `Decoder` / `Encoder` interfaces ( , )
- **Internal**
- perf optimizations ( , )
# 0.9.1
- **Bug Fix**
- make all classes "dumb", fix #95 ( )
# 0.9.0
- **Breaking Change**
- remove `t.map` and `t.mapWithName` (in general doesn't look serializable, needs more investigation)
- remove `t.prism` (in general doesn't look serializable, needs more investigation)
- change `Type` from interface to class and add `S` type parameter
- remove `t._A`
- add `Type#serialize`
- add `Type#is` (in order to serialize unions and while we're at it, looks useful anyway)
- remove `t.is` (now that there's `Type#is` is misleading)
- **Experimental**
- add Flowtype support ( )
# 0.8.2
- **New Feature**
- add `object` type, closes #86 ( )
# 0.8.1
- **New Feature**
- add `strict` combinator, closes #84 ( , )
# 0.8.0
- **Breaking Change**
- upgrade `fp-ts` dependency ( )
# 0.7.2
- **Bug Fix**
- tag recursive types, fix #80 ( )
# 0.7.1
- **Bug Fix**
- incorrect compile time type for dictionary, fix #75 ( )
# 0.7.0
- **Breaking Change**
- upgrade to latest fp-ts (0.5.1) ( )
# 0.6.2
- **New Feature**
- add aliases for `null` and `interface`, closes #63 ( )
# 0.6.1
- **Internal**
- handle latest fp-ts (0.4.3) ( )
# 0.6.0
- **Breaking Change**
- upgrade to latest fp-ts (0.4.0) ( )
- **Internal**
- allow for infinite unions ( )
# 0.5.1
- **Bug Fix**
- export and rename `interfaceType` to `_interface`, fix #57 ( )
# 0.5.0
- **Breaking Change**
- `Type` is now an interface
- types no more own a `is` method, use `t.is` instead
- unions no more own a `fold` method
- `Reporter`, `PathReporter`, `ThrowReporter` are now top level modules
# 0.4.0
- **Breaking Change**
- upgrade to latest `fp-ts` (`io-ts` APIs are not changed though) ( )
- drop `lib-jsnext` folder
# 0.3.2
- **Bug Fix**
- remove excess overloadings, fix #43 ( )
# 0.3.1
- **New Feature**
- add mapWithName and Functor instance, fix #37 ( )
- add prism combinator, fix #41 ( )
# 0.3.0
This is a breaking change _only_ if you are using fp-ts APIs
- **Breaking Change**
- upgrade to latest fp-ts v0.2 ( )
# 0.2.3
- **Internal**
- upgrade to fp-ts v0.1 ( )
# 0.2.2
- **New Feature**
- add `partial` combinator (makes optional props possible)
- add `readonly` combinator (values are not frozen in production)
- add `readonlyArray` combinator (values are not frozen in production)
- add `never` type
- **Breaking Changes**
- remove `maybe` combinator, can be defined in userland as
```ts
export function maybe<RT extends t.Any>(
type: RT,
name?: string
): t.UnionType<[RT, typeof t.null], t.TypeOf<RT> | null> {
return t.union([type, t.null], name)
}
```
- **Polish**
- export `pathReporterFailure` function from default reporters
- **Bug Fix**
- revert pruning excess properties (see https://github.com/gcanti/io-ts/pull/27 for context)
- revert `intersection` combinator accepting only `InterfaceType`s
- **Experimental**
- Pattern matching / catamorphism for unions
# 0.1.0
- **New Feature**
- add support for jsnext
- add `Integer` type
- **Breaking Changes**
- `t.Object` type. Renamed to `t.Dictionary`, now accepts arrays so is fully equivalent to `{ [key: string]: any }`.
- `t.instanceOf` combinator. Removed.
- `t.object` combinator. Renamed to `t.interface`. `ObjectType` to `InterfaceType`. Excess properties are now pruned.
- `mapping` combinator. Renamed to `dictionary`. `MappingType` to `DictionaryType`.
- `intersection` combinator. Due to the new excess property pruning in `t.interface` now only accept `InterfaceType`s.
- API `isSuccess` removed, use `either.isRight` instead
- API `isFailure` removed, use `either.isLeft` instead
- API `fromValidation` removed
# 0.0.2
- **Bug Fix**
- reverse overloading definitions for unions, intersections and tuples, fix inference bug
# 0.0.1
Initial release