Skip to content

Commit

Permalink
fix tuples fixed length bug (ts v2.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Nov 10, 2017
1 parent 8cdf540 commit 787f5fb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export const dictionary = <C extends Any>(codomain: C, name?: string): Dictionar
// unions
//

export class UnionType<RTS extends [Any]> extends Type<any, TypeOf<RTS['_A']>> {
export class UnionType<RTS extends Array<Any>> extends Type<any, TypeOf<RTS['_A']>> {
readonly _tag: 'UnionType' = 'UnionType'
constructor(readonly types: RTS, readonly name: string = `(${types.map(type => type.name).join(' | ')})`) {
super(
Expand Down Expand Up @@ -526,18 +526,18 @@ export class UnionType<RTS extends [Any]> extends Type<any, TypeOf<RTS['_A']>> {
}
}

export const union = <RTS extends [Any]>(types: RTS, name?: string): UnionType<RTS> => new UnionType(types, name)
export const union = <RTS extends Array<Any>>(types: RTS, name?: string): UnionType<RTS> => new UnionType(types, name)

//
// intersections
//

export class IntersectionType<RTS extends Array<Any>, I> extends Type<any, I> {
export class IntersectionType<RTS extends Array<Any>, A> extends Type<any, A> {
readonly _tag: 'IntersectionType' = 'IntersectionType'
constructor(readonly types: RTS, readonly name: string = `(${types.map(type => type.name).join(' & ')})`) {
super(
name,
(v): v is I => types.every(type => type.is(v)),
(v): v is A => types.every(type => type.is(v)),
(v, c) => {
let deserialized = v
let changed = false
Expand Down Expand Up @@ -594,12 +594,12 @@ export function intersection<RTS extends Array<Any>>(types: RTS, name?: string):
// tuples
//

export class TupleType<RTS extends Array<Any>, I> extends Type<any, I> {
export class TupleType<RTS extends Array<Any>, A> extends Type<any, A> {
readonly _tag: 'TupleType' = 'TupleType'
constructor(readonly types: RTS, readonly name: string = `[${types.map(type => type.name).join(', ')}]`) {
super(
name,
(v): v is I => types.every((type, i) => type.is(v[i])),
(v): v is A => types.every((type, i) => type.is(v[i])),
(v, c) =>
arrayType.validate(v, c).chain(as => {
const t: Array<any> = []
Expand Down

0 comments on commit 787f5fb

Please sign in to comment.