Skip to content

Commit

Permalink
Polish: remove useless module augmentation of Array
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Dec 20, 2018
1 parent 94da6fb commit ac6173f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
**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.

# 1.5.1

- **Polish**
- remove useless module augmentation of `Array` (@gcanti)

# 1.5.0

- **New Feature**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io-ts",
"version": "1.5.0",
"version": "1.5.1",
"description": "TypeScript compatible runtime type system for IO validation",
"files": [
"lib"
Expand Down
16 changes: 5 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Either, Left, Right } from 'fp-ts/lib/Either'
import { Predicate } from 'fp-ts/lib/function'

declare global {
interface Array<T> {
_A: T
}
}

/**
* @since 1.0.0
*/
Expand Down Expand Up @@ -997,11 +991,11 @@ export class UnionType<RTS extends Array<Any>, A = any, O = A, I = mixed> extend
export const union = <RTS extends Array<Mixed>>(
types: RTS,
name: string = `(${types.map(type => type.name).join(' | ')})`
): UnionType<RTS, TypeOf<RTS['_A']>, OutputOf<RTS['_A']>, mixed> => {
): UnionType<RTS, TypeOf<RTS[number]>, OutputOf<RTS[number]>, mixed> => {
const len = types.length
return new UnionType(
name,
(m): m is TypeOf<RTS['_A']> => types.some(type => type.is(m)),
(m): m is TypeOf<RTS[number]> => types.some(type => type.is(m)),
(m, c) => {
const errors: Errors = []
for (let i = 0; i < len; i++) {
Expand Down Expand Up @@ -1459,7 +1453,7 @@ export const taggedUnion = <Tag extends string, RTS extends Array<Tagged<Tag>>>(
tag: Tag,
types: RTS,
name: string = `(${types.map(type => type.name).join(' | ')})`
): TaggedUnionType<Tag, RTS, TypeOf<RTS['_A']>, OutputOf<RTS['_A']>, mixed> => {
): TaggedUnionType<Tag, RTS, TypeOf<RTS[number]>, OutputOf<RTS[number]>, mixed> => {
const len = types.length
const values: Array<string | number | boolean> = new Array(len)
const hash: { [key: string]: number } = {}
Expand Down Expand Up @@ -1491,9 +1485,9 @@ export const taggedUnion = <Tag extends string, RTS extends Array<Tagged<Tag>>>(
(m, c) => (isTagValue(m) ? success(m) : failure(m, c)),
identity
)
return new TaggedUnionType<Tag, RTS, TypeOf<RTS['_A']>, OutputOf<RTS['_A']>, mixed>(
return new TaggedUnionType<Tag, RTS, TypeOf<RTS[number]>, OutputOf<RTS[number]>, mixed>(
name,
(v): v is TypeOf<RTS['_A']> => {
(v): v is TypeOf<RTS[number]> => {
if (!Dictionary.is(v)) {
return false
}
Expand Down

0 comments on commit ac6173f

Please sign in to comment.