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 1.2.0 to 1.2.1

5

CHANGELOG.md

@@ -16,2 +16,7 @@ # Changelog

# 1.2.1
- **Polish**
- allow recursive types in tagged unions (@gcanti)
# 1.2.0

@@ -18,0 +23,0 @@

2

lib/index.d.ts

@@ -280,3 +280,3 @@ 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 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> | RecursiveType<any, A, O>;
export declare const isTagged: <Tag extends string>(tag: Tag) => (type: Type<any, any, mixed>) => type is Tagged<Tag, any, any>;

@@ -283,0 +283,0 @@ export declare const getTagValue: <Tag extends string>(tag: Tag) => (type: Tagged<Tag, any, any>) => string | number | boolean;

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

case 'ExactType':
case 'RecursiveType':
return f(type.type);

@@ -835,0 +836,0 @@ }

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

@@ -5,0 +5,0 @@ "files": [

@@ -194,3 +194,3 @@ [![build status](https://img.shields.io/travis/gcanti/io-ts/master.svg?style=flat-square)](https://travis-ci.org/gcanti/io-ts)

// helper type
type ICategory = {
interface ICategory {
name: string

@@ -200,6 +200,6 @@ categories: Array<ICategory>

const Category = t.recursion<ICategory>('Category', self =>
const Category = t.recursion<ICategory>('Category', Category =>
t.type({
name: t.string,
categories: t.array(self)
categories: t.array(Category)
})

@@ -209,2 +209,32 @@ )

## Mutually recursive types
```ts
interface IFoo {
type: 'Foo'
b: IBar | undefined
}
interface IBar {
type: 'Bar'
a: IFoo | undefined
}
const Foo: t.RecursiveType<t.Type<IFoo>, IFoo> = t.recursion<IFoo>('Foo', _ =>
t.interface({
type: t.literal('Foo'),
b: t.union([Bar, t.undefined])
})
)
const Bar: t.RecursiveType<t.Type<IFoo>, IBar> = t.recursion<IBar>('Bar', _ =>
t.interface({
type: t.literal('Bar'),
a: t.union([Foo, t.undefined])
})
)
const FooBar = t.taggedUnion('type', [Foo, Bar])
```
# Tagged unions

@@ -211,0 +241,0 @@

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