Socket
Socket
Sign inDemoInstall

io-ts

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

7

CHANGELOG.md

@@ -15,2 +15,9 @@ # Changelog

# 0.6.0
- **Breaking Change**
- upgrade to latest fp-ts (@gcanti)
- **Internal**
- allow for infinite unions (@gcanti)
# 0.5.1

@@ -17,0 +24,0 @@

20

lib/index.d.ts

@@ -28,13 +28,7 @@ import { Either } from 'fp-ts/lib/Either';

export declare function is<T>(value: any, type: Type<T>): value is T;
declare module 'fp-ts/lib/HKT' {
interface HKT<A> {
'io-ts/Type': Type<A>;
}
}
export declare const URI = "io-ts/Type";
export declare type URI = typeof URI;
export interface MapType<RT extends Any, B> extends Type<B> {
export interface MapType<RT extends Any, A> extends Type<A> {
readonly _tag: 'MapType';
readonly _A: A;
readonly type: RT;
readonly f: (a: TypeOf<RT>) => B;
readonly f: (a: TypeOf<RT>) => A;
}

@@ -149,11 +143,7 @@ export declare function map<RT extends Any, B>(f: (a: TypeOf<RT>) => B, type: RT): MapType<RT, B>;

export declare function dictionary<D extends Type<string>, C extends Any>(domain: D, codomain: C, name?: string): DictionaryType<D, C>;
export interface UnionType<RTS extends Array<Any>, U> extends Type<U> {
export interface UnionType<RTS extends [Any], U = TypeOf<RTS['_A']>> extends Type<U> {
readonly _tag: 'UnionType';
readonly types: RTS;
}
export declare function union<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any>(types: [A, B, C, D, E], name?: string): UnionType<[A, B, C, D, E], TypeOf<A> | TypeOf<B> | TypeOf<C> | TypeOf<D> | TypeOf<E>>;
export declare function union<A extends Any, B extends Any, C extends Any, D extends Any>(types: [A, B, C, D], name?: string): UnionType<[A, B, C, D], TypeOf<A> | TypeOf<B> | TypeOf<C> | TypeOf<D>>;
export declare function union<A extends Any, B extends Any, C extends Any>(types: [A, B, C], name?: string): UnionType<[A, B, C], TypeOf<A> | TypeOf<B> | TypeOf<C>>;
export declare function union<A extends Any, B extends Any>(types: [A, B], name?: string): UnionType<[A, B], TypeOf<A> | TypeOf<B>>;
export declare function union<A extends Any>(types: [A], name?: string): UnionType<[A], TypeOf<A>>;
export declare function union<RTS extends [Any]>(types: RTS, name?: string): UnionType<RTS>;
export interface IntersectionType<RTS extends Array<Any>, I> extends Type<I> {

@@ -160,0 +150,0 @@ readonly _tag: 'IntersectionType';

@@ -45,3 +45,2 @@ "use strict";

exports.is = is;
exports.URI = 'io-ts/Type';
function map(f, type) {

@@ -48,0 +47,0 @@ return mapWithName(f, type, "(" + type.name + " => ?)");

{
"name": "io-ts",
"version": "0.5.1",
"version": "0.6.0",
"description": "TypeScript compatible runtime type system for IO validation",

@@ -28,3 +28,3 @@ "files": ["lib"],

"dependencies": {
"fp-ts": "^0.3.0"
"fp-ts": "^0.4.0"
},

@@ -36,6 +36,6 @@ "devDependencies": {

"prettier": "1.5.2",
"ts-node": "2.0.0",
"ts-node": "3.2.0",
"tslint": "4.4.2",
"tslint-config-standard": "4.0.0",
"typescript": "2.4.0",
"typescript": "2.4.1",
"typings-checker": "1.1.2"

@@ -42,0 +42,0 @@ },

@@ -35,3 +35,3 @@ # The idea

Note: The `_A` field contains a dummy value and is useful to extract a static type from the runtime type (see the section "TypeScript integration" below)
Note: The `_A` field contains a dummy value and is useful to extract a static type from the runtime type (see the ["TypeScript integration"](#typescript-integration) section below)

@@ -111,2 +111,4 @@ A runtime type can be used to validate an object in memory (for example an API payload)

## Recursive types
Note that recursive types can't be inferred

@@ -145,19 +147,19 @@

| integer | ✘ | `t.Integer` |
| generic array | `Array<any>` | `t.Array` |
| generic dictionary | `{ [key: string]: any }` | `t.Dictionary` |
| array of any | `Array<any>` | `t.Array` |
| array of type | `Array<A>` | `t.array(A)` |
| dictionary of any | `{ [key: string]: any }` | `t.Dictionary` |
| dictionary of type | `{ [key: A]: B }` | `t.dictionary(A, B)` |
| function | `Function` | `t.Function` |
| arrays | `Array<A>` | `t.array(A)` |
| literal | `'s'` | `t.literal('s')` |
| maybe | `A | null` | `t.maybe(A)` |
| partial | `Partial<{ name: string }>` | `t.partial({ name: t.string })` |
| readonly | `Readonly<{ name: string }>` | `t.readonly({ name: t.string })` |
| readonly array | `ReadonlyArray<number>` | `t.readonlyArray(t.number)` |
| dictionaries | `{ [key: A]: B }` | `t.dictionary(A, B)` |
| interface | `interface A { name: string }` | `t.interface({ name: t.string })` |
| interface inheritance | `interface B extends A {}` | `t.intersection([ A, t.interface({}) ])` |
| tuple | `[ A, B ]` | `t.tuple([ A, B ])` |
| union | `A \| B` | `t.union([ A, B ])` |
| intersection | `A & B` | `t.intersection([ A, B ])` |
| keyof | `keyof M` | `t.keyof(M)` |
| recursive types | see [Recursive types](#recursive-types) | `t.recursion(name, definition)` |
| refinement | ✘ | `t.refinement(A, predicate)` |
| interface | `{ name: string }` | `t.interface({ name: t.string })` |
| tuple | `[A, B]` | `t.tuple([A, B])` |
| union | `A \| B` | `t.union([A, B])` |
| intersection | `A & B` | `t.intersection([A, B])` |
| keyof | `keyof M` | `t.keyof(M)` |
| recursive types | | `t.recursion(name, definition)` |
| map | ✘ | `t.map(f, type)` |

@@ -225,2 +227,4 @@ | prism | ✘ | `t.prism(type, getOption)` |

An equivalent to `T | null`
```ts

@@ -227,0 +231,0 @@ export function maybe<RT extends t.Any>(

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc