Skip to content

Commit

Permalink
upgrade to fp-ts@next (#61)
Browse files Browse the repository at this point in the history
* upgrade to ts 2.4.1

* allow for infinite unions

* bump version
  • Loading branch information
gcanti authored Jul 10, 2017
1 parent defba7e commit 2b68b18
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 46 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
**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.

# 0.6.0

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

# 0.5.1

- **Bug Fix**
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io-ts",
"version": "0.5.1",
"version": "0.6.0",
"description": "TypeScript compatible runtime type system for IO validation",
"files": ["lib"],
"main": "lib/index.js",
Expand All @@ -25,17 +25,17 @@
},
"homepage": "https://github.com/gcanti/io-ts",
"dependencies": {
"fp-ts": "^0.3.0"
"fp-ts": "^0.4.0"
},
"devDependencies": {
"@types/mocha": "2.2.38",
"@types/node": "7.0.4",
"mocha": "3.2.0",
"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"
},
"tags": ["typescript", "validation", "inference", "types", "runtime"],
Expand Down
40 changes: 5 additions & 35 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,11 @@ export function is<T>(value: any, type: Type<T>): value is T {
return isRight(validate(value, type))
}

//
// Functor
//

declare module 'fp-ts/lib/HKT' {
interface HKT<A> {
'io-ts/Type': Type<A>
}
}

export const URI = 'io-ts/Type'

export 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
}

export function map<RT extends Any, B>(f: (a: TypeOf<RT>) => B, type: RT): MapType<RT, B> {
Expand Down Expand Up @@ -478,29 +465,12 @@ export function dictionary<D extends Type<string>, C extends Any>(
// unions
//

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 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 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 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 function union<A extends Any, B extends Any>(
types: [A, B],
name?: string
): UnionType<[A, B], TypeOf<A> | TypeOf<B>>
export function union<A extends Any>(types: [A], name?: string): UnionType<[A], TypeOf<A>>
export function union<RTS extends Array<Any>>(types: RTS, name?: string): UnionType<RTS, any> {
export function union<RTS extends [Any]>(types: RTS, name?: string): UnionType<RTS> {
return {
_A,
_tag: 'UnionType',
Expand Down
5 changes: 1 addition & 4 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
"target": "es5",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"lib": [
"es6",
"dom"
]
"lib": ["es6", "dom"]
}
}
4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true
},
"include": [
"./src/**/*"
]
"include": ["./src/**/*"]
}

0 comments on commit 2b68b18

Please sign in to comment.