io-ts
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -16,2 +16,8 @@ # Changelog | ||
# 1.1.2 | ||
* **Bug Fix** | ||
* fix `alias` implementation (@gcanti) | ||
* handle exact types in `isTagged` (@gcanti) | ||
# 1.1.1 | ||
@@ -18,0 +24,0 @@ |
@@ -273,2 +273,4 @@ import { Either } from 'fp-ts/lib/Either'; | ||
export declare type Tagged<Tag extends string, A = any, O = A> = InterfaceType<TaggedProps<Tag>, A, O> | StrictType<TaggedProps<Tag>, A, O> | TaggedRefinement<Tag, A, O> | TaggedUnion<Tag, A, O> | TaggedIntersection<Tag, A, O> | TaggedExact<Tag>; | ||
export declare const isTagged: <Tag extends string>(tag: Tag) => (type: Type<any, any, mixed>) => type is Tagged<Tag, any, any>; | ||
export declare const getTagValue: <Tag extends string>(tag: Tag) => (type: Tagged<Tag, any, any>) => string | number | boolean; | ||
export declare const taggedUnion: <Tag extends string, RTS extends Tagged<Tag, any, any>[]>(tag: Tag, types: RTS, name?: string) => UnionType<RTS, RTS["_A"]["_A"], RTS["_A"]["_O"], mixed>; | ||
@@ -275,0 +277,0 @@ export declare class ExactType<RT extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> { |
@@ -131,4 +131,6 @@ "use strict"; | ||
function NeverType() { | ||
var _this = _super.call(this, 'never', function (_) { return false; }, function (m, c) { return exports.failure(m, c); }, function () { | ||
throw new Error('cannot serialize never'); | ||
var _this = _super.call(this, 'never', function (_) { return false; }, function (m, c) { return exports.failure(m, c); }, | ||
/* istanbul ignore next */ | ||
function () { | ||
throw new Error('cannot encode never'); | ||
}) || this; | ||
@@ -430,2 +432,3 @@ _this._tag = 'NeverType'; | ||
if (vok !== ok) { | ||
/* istanbul ignore next */ | ||
if (a === o) { | ||
@@ -683,2 +686,3 @@ a = __assign({}, o); | ||
if (va !== a) { | ||
/* istanbul ignore next */ | ||
if (t === as) { | ||
@@ -775,3 +779,3 @@ t = as.slice(); | ||
}; | ||
var isTagged = function (tag) { | ||
exports.isTagged = function (tag) { | ||
var f = function (type) { | ||
@@ -787,3 +791,3 @@ if (type instanceof InterfaceType || type instanceof StrictType) { | ||
} | ||
else if (type instanceof RefinementType) { | ||
else if (type instanceof RefinementType || type instanceof ExactType) { | ||
return f(type.type); | ||
@@ -799,3 +803,3 @@ } | ||
var len = types.length; | ||
var is = isTagged(tag); | ||
var is = exports.isTagged(tag); | ||
var i = 0; | ||
@@ -810,3 +814,3 @@ for (; i < len - 1; i++) { | ||
}; | ||
var getTagValue = function (tag) { | ||
exports.getTagValue = function (tag) { | ||
var f = function (type) { | ||
@@ -834,3 +838,3 @@ switch (type._tag) { | ||
var useHash = true; | ||
var get = getTagValue(tag); | ||
var get = exports.getTagValue(tag); | ||
for (var i = 0; i < len; i++) { | ||
@@ -941,5 +945,5 @@ var value = get(types[i]); | ||
function alias(type) { | ||
return type; | ||
return function () { return type; }; | ||
} | ||
exports.alias = alias; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "io-ts", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "TypeScript compatible runtime type system for IO validation", | ||
@@ -12,3 +12,3 @@ "files": ["lib"], | ||
"typings-checker --allow-expect-error --project typings-checker/tsconfig.json typings-checker/index.ts", | ||
"mocha": "cross-env TS_NODE_CACHE=false TS_NODE_PROJECT=test/tsconfig.json mocha -r ts-node/register test/*.ts", | ||
"jest": "jest", | ||
"prettier": | ||
@@ -18,3 +18,3 @@ "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test}/**/*.ts\"", | ||
"prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test,examples,exercises}/**/*.ts\"", | ||
"test": "npm run prettier && npm run lint && npm run typings-checker && npm run mocha", | ||
"test": "npm run prettier && npm run lint && npm run typings-checker && npm run jest", | ||
"clean": "rimraf lib/*", | ||
@@ -39,10 +39,9 @@ "build": "npm run clean && tsc", | ||
"@types/benchmark": "1.0.31", | ||
"@types/mocha": "2.2.38", | ||
"@types/jest": "22.2.2", | ||
"@types/node": "7.0.4", | ||
"benchmark": "2.1.4", | ||
"cross-env": "^5.1.4", | ||
"mocha": "3.2.0", | ||
"jest": "22.4.3", | ||
"prettier": "1.12.1", | ||
"rimraf": "2.6.2", | ||
"ts-node": "3.2.0", | ||
"ts-jest": "22.4.2", | ||
"tslint": "5.9.1", | ||
@@ -54,3 +53,17 @@ "tslint-config-standard": "7.0.0", | ||
"tags": ["typescript", "validation", "inference", "types", "runtime"], | ||
"keywords": ["typescript", "validation", "inference", "types", "runtime"] | ||
"keywords": ["typescript", "validation", "inference", "types", "runtime"], | ||
"jest": { | ||
"globals": { | ||
"ts-jest": { | ||
"skipBabel": true | ||
} | ||
}, | ||
"collectCoverage": true, | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"testRegex": "test", | ||
"moduleFileExtensions": ["ts", "js"], | ||
"testPathIgnorePatterns": ["helpers.ts"] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
113076
12
1298