io-ts
Advanced tools
Comparing version 2.2.17 to 2.2.18
@@ -17,2 +17,7 @@ # Changelog | ||
# 2.2.18 | ||
- **Bug Fix** | ||
- fix `typescript@4.8` errors, closes #656, closes #647 (@gcanti) | ||
# 2.2.17 | ||
@@ -19,0 +24,0 @@ |
@@ -15,3 +15,3 @@ /** | ||
import * as E from './Encoder' | ||
import { Literal } from './Schemable' | ||
import * as S from './Schemable' | ||
/** | ||
@@ -41,3 +41,3 @@ * Laws: | ||
*/ | ||
export declare function literal<A extends readonly [Literal, ...Array<Literal>]>( | ||
export declare function literal<A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
@@ -44,0 +44,0 @@ ): Codec<unknown, A[number], A[number]> |
@@ -6,2 +6,3 @@ import * as FS from './FreeSemigroup'; | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/prefer-as-const | ||
export var required = 'required'; | ||
@@ -12,2 +13,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/prefer-as-const | ||
export var optional = 'optional'; | ||
@@ -14,0 +16,0 @@ /** |
@@ -60,3 +60,3 @@ /** | ||
*/ | ||
export declare const literal: <A extends readonly [S.Literal, ...Array<S.Literal>]>( | ||
export declare const literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
@@ -63,0 +63,0 @@ ) => Decoder<unknown, A[number]> |
@@ -440,13 +440,16 @@ import * as E from 'fp-ts/es6/Either'; | ||
var res = []; | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
switch (focus._tag) { | ||
case 'Of': | ||
res.push(toTree(focus.value)); | ||
var tmp = stack.pop(); | ||
if (tmp === undefined) { | ||
return res; | ||
{ | ||
res.push(toTree(focus.value)); | ||
var tmp = stack.pop(); | ||
if (tmp === undefined) { | ||
return res; | ||
} | ||
else { | ||
focus = tmp; | ||
} | ||
} | ||
else { | ||
focus = tmp; | ||
} | ||
break; | ||
@@ -453,0 +456,0 @@ case 'Concat': |
@@ -12,3 +12,3 @@ /** | ||
import { Refinement } from 'fp-ts/es6/function' | ||
import { Literal, Schemable1, WithRefine1, WithUnion1, WithUnknownContainers1 } from './Schemable' | ||
import * as S from './Schemable' | ||
/** | ||
@@ -33,3 +33,5 @@ * @category model | ||
*/ | ||
export declare const literal: <A extends readonly [Literal, ...Literal[]]>(...values: A) => Guard<unknown, A[number]> | ||
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>( | ||
...values: A | ||
) => Guard<unknown, A[number]> | ||
/** | ||
@@ -183,3 +185,3 @@ * @category primitives | ||
*/ | ||
export declare const Schemable: Schemable1<URI> | ||
export declare const Schemable: S.Schemable1<URI> | ||
/** | ||
@@ -189,3 +191,3 @@ * @category instances | ||
*/ | ||
export declare const WithUnknownContainers: WithUnknownContainers1<URI> | ||
export declare const WithUnknownContainers: S.WithUnknownContainers1<URI> | ||
/** | ||
@@ -195,3 +197,3 @@ * @category instances | ||
*/ | ||
export declare const WithUnion: WithUnion1<URI> | ||
export declare const WithUnion: S.WithUnion1<URI> | ||
/** | ||
@@ -201,2 +203,2 @@ * @category instances | ||
*/ | ||
export declare const WithRefine: WithRefine1<URI> | ||
export declare const WithRefine: S.WithRefine1<URI> |
@@ -13,3 +13,3 @@ /** | ||
import { pipe } from 'fp-ts/es6/pipeable'; | ||
import { memoize } from './Schemable'; | ||
import * as S from './Schemable'; | ||
// ------------------------------------------------------------------------------------- | ||
@@ -197,3 +197,3 @@ // constructors | ||
export var lazy = function (f) { | ||
var get = memoize(f); | ||
var get = S.memoize(f); | ||
return { | ||
@@ -200,0 +200,0 @@ is: function (u) { return get().is(u); } |
@@ -1385,23 +1385,8 @@ /** | ||
codec: PartialType<P, A, O, I> | ||
): < | ||
AA extends Exact<A, AA>, | ||
OO extends Exact<O, OO> = O, | ||
PP extends Exact<P, PP> = P, | ||
II extends I = I | ||
>() => PartialType<PP, AA, OO, II> | ||
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => PartialType<PP, AA, OO, II> | ||
export declare function alias<A, O, P, I>( | ||
codec: StrictType<P, A, O, I> | ||
): < | ||
AA extends Exact<A, AA>, | ||
OO extends Exact<O, OO> = O, | ||
PP extends Exact<P, PP> = P, | ||
II extends I = I | ||
>() => StrictType<PP, AA, OO, II> | ||
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => StrictType<PP, AA, OO, II> | ||
export declare function alias<A, O, P, I>( | ||
codec: InterfaceType<P, A, O, I> | ||
): < | ||
AA extends Exact<A, AA>, | ||
OO extends Exact<O, OO> = O, | ||
PP extends Exact<P, PP> = P, | ||
II extends I = I | ||
>() => InterfaceType<PP, AA, OO, II> | ||
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => InterfaceType<PP, AA, OO, II> |
@@ -288,2 +288,3 @@ var __extends = (this && this.__extends) || (function () { | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export function mergeAll(base, us) { | ||
@@ -312,3 +313,3 @@ var equal = true; | ||
for (var k in u) { | ||
if (!r.hasOwnProperty(k) || baseIsNotADictionary || u[k] !== base[k]) { | ||
if (!hasOwnProperty.call(r, k) || baseIsNotADictionary || u[k] !== base[k]) { | ||
r[k] = u[k]; | ||
@@ -383,3 +384,3 @@ } | ||
for (var k in b) { | ||
if (a.hasOwnProperty(k)) { | ||
if (hasOwnProperty.call(a, k)) { | ||
var intersection_1 = intersect(a[k], b[k]); | ||
@@ -406,3 +407,3 @@ if (isNonEmpty(intersection_1)) { | ||
for (var k in a) { | ||
if (b.hasOwnProperty(k)) { | ||
if (hasOwnProperty.call(b, k)) { | ||
var intersection_2 = intersect(a[k], b[k]); | ||
@@ -409,0 +410,0 @@ if (intersection_2.length === 0) { |
@@ -19,3 +19,3 @@ /** | ||
import { MonadThrow2C } from 'fp-ts/es6/MonadThrow' | ||
import { Literal } from './Schemable' | ||
import * as S from './Schemable' | ||
import { Lazy, Refinement } from 'fp-ts/es6/function' | ||
@@ -43,4 +43,6 @@ /** | ||
): <I>( | ||
onError: (i: I, values: readonly [Literal, ...Array<Literal>]) => E | ||
) => <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kleisli<M, I, E, A[number]> | ||
onError: (i: I, values: readonly [S.Literal, ...ReadonlyArray<S.Literal>]) => E | ||
) => <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
) => Kleisli<M, I, E, A[number]> | ||
/** | ||
@@ -47,0 +49,0 @@ * @category combinators |
import * as E from 'fp-ts/es6/Either'; | ||
import * as G from './Guard'; | ||
import { intersect_, memoize } from './Schemable'; | ||
import * as S from './Schemable'; | ||
// ------------------------------------------------------------------------------------- | ||
@@ -187,3 +187,3 @@ // constructors | ||
decode: function (i) { | ||
return M.ap(M.map(left.decode(i), function (a) { return function (b) { return intersect_(a, b); }; }), right.decode(i)); | ||
return M.ap(M.map(left.decode(i), function (a) { return function (b) { return S.intersect_(a, b); }; }), right.decode(i)); | ||
} | ||
@@ -216,3 +216,3 @@ }); }; }; | ||
return function (onError) { return function (id, f) { | ||
var get = memoize(f); | ||
var get = S.memoize(f); | ||
return { | ||
@@ -219,0 +219,0 @@ decode: function (u) { return M.mapLeft(get().decode(u), function (e) { return onError(id, e); }); } |
@@ -22,3 +22,5 @@ /** | ||
readonly URI: S | ||
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => HKT<S, A[number]> | ||
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>( | ||
...values: A | ||
) => HKT<S, A[number]> | ||
readonly string: HKT<S, string> | ||
@@ -84,3 +86,5 @@ readonly number: HKT<S, number> | ||
readonly URI: S | ||
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kind<S, A[number]> | ||
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>( | ||
...values: A | ||
) => Kind<S, A[number]> | ||
readonly string: Kind<S, string> | ||
@@ -146,3 +150,5 @@ readonly number: Kind<S, number> | ||
readonly URI: S | ||
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kind2<S, E, A[number]> | ||
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>( | ||
...values: A | ||
) => Kind2<S, E, A[number]> | ||
readonly string: Kind2<S, E, string> | ||
@@ -149,0 +155,0 @@ readonly number: Kind2<S, E, number> |
@@ -67,3 +67,3 @@ /** | ||
*/ | ||
export declare const literal: <A extends readonly [S.Literal, ...Array<S.Literal>]>( | ||
export declare const literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
@@ -70,0 +70,0 @@ ) => TaskDecoder<unknown, A[number]> |
@@ -13,3 +13,5 @@ import { Refinement } from 'fp-ts/es6/function' | ||
*/ | ||
export declare const literal: <A extends readonly [S.Literal, ...S.Literal[]]>(...values: A) => Type<A[number]> | ||
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>( | ||
...values: A | ||
) => Type<A[number]> | ||
/** | ||
@@ -16,0 +18,0 @@ * @category primitives |
@@ -15,3 +15,3 @@ /** | ||
import * as E from './Encoder' | ||
import { Literal } from './Schemable' | ||
import * as S from './Schemable' | ||
/** | ||
@@ -41,3 +41,3 @@ * Laws: | ||
*/ | ||
export declare function literal<A extends readonly [Literal, ...Array<Literal>]>( | ||
export declare function literal<A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
@@ -44,0 +44,0 @@ ): Codec<unknown, A[number], A[number]> |
@@ -32,2 +32,3 @@ "use strict"; | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/prefer-as-const | ||
exports.required = 'required'; | ||
@@ -38,2 +39,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/prefer-as-const | ||
exports.optional = 'optional'; | ||
@@ -40,0 +42,0 @@ /** |
@@ -60,3 +60,3 @@ /** | ||
*/ | ||
export declare const literal: <A extends readonly [S.Literal, ...Array<S.Literal>]>( | ||
export declare const literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
@@ -63,0 +63,0 @@ ) => Decoder<unknown, A[number]> |
@@ -485,13 +485,16 @@ "use strict"; | ||
var res = []; | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
switch (focus._tag) { | ||
case 'Of': | ||
res.push(toTree(focus.value)); | ||
var tmp = stack.pop(); | ||
if (tmp === undefined) { | ||
return res; | ||
{ | ||
res.push(toTree(focus.value)); | ||
var tmp = stack.pop(); | ||
if (tmp === undefined) { | ||
return res; | ||
} | ||
else { | ||
focus = tmp; | ||
} | ||
} | ||
else { | ||
focus = tmp; | ||
} | ||
break; | ||
@@ -498,0 +501,0 @@ case 'Concat': |
@@ -12,3 +12,3 @@ /** | ||
import { Refinement } from 'fp-ts/lib/function' | ||
import { Literal, Schemable1, WithRefine1, WithUnion1, WithUnknownContainers1 } from './Schemable' | ||
import * as S from './Schemable' | ||
/** | ||
@@ -33,3 +33,5 @@ * @category model | ||
*/ | ||
export declare const literal: <A extends readonly [Literal, ...Literal[]]>(...values: A) => Guard<unknown, A[number]> | ||
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>( | ||
...values: A | ||
) => Guard<unknown, A[number]> | ||
/** | ||
@@ -183,3 +185,3 @@ * @category primitives | ||
*/ | ||
export declare const Schemable: Schemable1<URI> | ||
export declare const Schemable: S.Schemable1<URI> | ||
/** | ||
@@ -189,3 +191,3 @@ * @category instances | ||
*/ | ||
export declare const WithUnknownContainers: WithUnknownContainers1<URI> | ||
export declare const WithUnknownContainers: S.WithUnknownContainers1<URI> | ||
/** | ||
@@ -195,3 +197,3 @@ * @category instances | ||
*/ | ||
export declare const WithUnion: WithUnion1<URI> | ||
export declare const WithUnion: S.WithUnion1<URI> | ||
/** | ||
@@ -201,2 +203,2 @@ * @category instances | ||
*/ | ||
export declare const WithRefine: WithRefine1<URI> | ||
export declare const WithRefine: S.WithRefine1<URI> |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -16,3 +39,3 @@ exports.WithRefine = exports.WithUnion = exports.WithUnknownContainers = exports.Schemable = exports.URI = exports.id = exports.compose = exports.zero = exports.alt = exports.readonly = exports.lazy = exports.sum = exports.union = exports.intersect = exports.tuple = exports.record = exports.array = exports.partial = exports.type = exports.struct = exports.nullable = exports.refine = exports.UnknownRecord = exports.UnknownArray = exports.boolean = exports.number = exports.string = exports.literal = void 0; | ||
var pipeable_1 = require("fp-ts/lib/pipeable"); | ||
var Schemable_1 = require("./Schemable"); | ||
var S = __importStar(require("./Schemable")); | ||
// ------------------------------------------------------------------------------------- | ||
@@ -211,3 +234,3 @@ // constructors | ||
var lazy = function (f) { | ||
var get = (0, Schemable_1.memoize)(f); | ||
var get = S.memoize(f); | ||
return { | ||
@@ -214,0 +237,0 @@ is: function (u) { return get().is(u); } |
@@ -1385,23 +1385,8 @@ /** | ||
codec: PartialType<P, A, O, I> | ||
): < | ||
AA extends Exact<A, AA>, | ||
OO extends Exact<O, OO> = O, | ||
PP extends Exact<P, PP> = P, | ||
II extends I = I | ||
>() => PartialType<PP, AA, OO, II> | ||
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => PartialType<PP, AA, OO, II> | ||
export declare function alias<A, O, P, I>( | ||
codec: StrictType<P, A, O, I> | ||
): < | ||
AA extends Exact<A, AA>, | ||
OO extends Exact<O, OO> = O, | ||
PP extends Exact<P, PP> = P, | ||
II extends I = I | ||
>() => StrictType<PP, AA, OO, II> | ||
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => StrictType<PP, AA, OO, II> | ||
export declare function alias<A, O, P, I>( | ||
codec: InterfaceType<P, A, O, I> | ||
): < | ||
AA extends Exact<A, AA>, | ||
OO extends Exact<O, OO> = O, | ||
PP extends Exact<P, PP> = P, | ||
II extends I = I | ||
>() => InterfaceType<PP, AA, OO, II> | ||
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => InterfaceType<PP, AA, OO, II> |
@@ -298,2 +298,3 @@ "use strict"; | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
function mergeAll(base, us) { | ||
@@ -322,3 +323,3 @@ var equal = true; | ||
for (var k in u) { | ||
if (!r.hasOwnProperty(k) || baseIsNotADictionary || u[k] !== base[k]) { | ||
if (!hasOwnProperty.call(r, k) || baseIsNotADictionary || u[k] !== base[k]) { | ||
r[k] = u[k]; | ||
@@ -394,3 +395,3 @@ } | ||
for (var k in b) { | ||
if (a.hasOwnProperty(k)) { | ||
if (hasOwnProperty.call(a, k)) { | ||
var intersection_1 = intersect(a[k], b[k]); | ||
@@ -417,3 +418,3 @@ if (isNonEmpty(intersection_1)) { | ||
for (var k in a) { | ||
if (b.hasOwnProperty(k)) { | ||
if (hasOwnProperty.call(b, k)) { | ||
var intersection_2 = intersect(a[k], b[k]); | ||
@@ -420,0 +421,0 @@ if (intersection_2.length === 0) { |
@@ -19,3 +19,3 @@ /** | ||
import { MonadThrow2C } from 'fp-ts/lib/MonadThrow' | ||
import { Literal } from './Schemable' | ||
import * as S from './Schemable' | ||
import { Lazy, Refinement } from 'fp-ts/lib/function' | ||
@@ -43,4 +43,6 @@ /** | ||
): <I>( | ||
onError: (i: I, values: readonly [Literal, ...Array<Literal>]) => E | ||
) => <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kleisli<M, I, E, A[number]> | ||
onError: (i: I, values: readonly [S.Literal, ...ReadonlyArray<S.Literal>]) => E | ||
) => <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
) => Kleisli<M, I, E, A[number]> | ||
/** | ||
@@ -47,0 +49,0 @@ * @category combinators |
@@ -29,3 +29,3 @@ "use strict"; | ||
var G = __importStar(require("./Guard")); | ||
var Schemable_1 = require("./Schemable"); | ||
var S = __importStar(require("./Schemable")); | ||
// ------------------------------------------------------------------------------------- | ||
@@ -226,3 +226,3 @@ // constructors | ||
decode: function (i) { | ||
return M.ap(M.map(left.decode(i), function (a) { return function (b) { return (0, Schemable_1.intersect_)(a, b); }; }), right.decode(i)); | ||
return M.ap(M.map(left.decode(i), function (a) { return function (b) { return S.intersect_(a, b); }; }), right.decode(i)); | ||
} | ||
@@ -257,3 +257,3 @@ }); }; }; | ||
return function (onError) { return function (id, f) { | ||
var get = (0, Schemable_1.memoize)(f); | ||
var get = S.memoize(f); | ||
return { | ||
@@ -260,0 +260,0 @@ decode: function (u) { return M.mapLeft(get().decode(u), function (e) { return onError(id, e); }); } |
@@ -22,3 +22,5 @@ /** | ||
readonly URI: S | ||
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => HKT<S, A[number]> | ||
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>( | ||
...values: A | ||
) => HKT<S, A[number]> | ||
readonly string: HKT<S, string> | ||
@@ -84,3 +86,5 @@ readonly number: HKT<S, number> | ||
readonly URI: S | ||
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kind<S, A[number]> | ||
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>( | ||
...values: A | ||
) => Kind<S, A[number]> | ||
readonly string: Kind<S, string> | ||
@@ -146,3 +150,5 @@ readonly number: Kind<S, number> | ||
readonly URI: S | ||
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kind2<S, E, A[number]> | ||
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>( | ||
...values: A | ||
) => Kind2<S, E, A[number]> | ||
readonly string: Kind2<S, E, string> | ||
@@ -149,0 +155,0 @@ readonly number: Kind2<S, E, number> |
@@ -67,3 +67,3 @@ /** | ||
*/ | ||
export declare const literal: <A extends readonly [S.Literal, ...Array<S.Literal>]>( | ||
export declare const literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>( | ||
...values: A | ||
@@ -70,0 +70,0 @@ ) => TaskDecoder<unknown, A[number]> |
@@ -13,3 +13,5 @@ import { Refinement } from 'fp-ts/lib/function' | ||
*/ | ||
export declare const literal: <A extends readonly [S.Literal, ...S.Literal[]]>(...values: A) => Type<A[number]> | ||
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>( | ||
...values: A | ||
) => Type<A[number]> | ||
/** | ||
@@ -16,0 +18,0 @@ * @category primitives |
{ | ||
"name": "io-ts", | ||
"version": "2.2.17", | ||
"version": "2.2.18", | ||
"description": "TypeScript runtime type system for IO decoding/encoding", | ||
@@ -19,3 +19,2 @@ "main": "lib/index.js", | ||
"homepage": "https://github.com/gcanti/io-ts", | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
@@ -22,0 +21,0 @@ "fp-ts": "^2.5.0" |
461938
16430