Skip to content

Commit 047316f

Browse files
committedApr 4, 2020
upgrade to latest: docs-ts, prettier, typescript
1 parent 2813cc5 commit 047316f

19 files changed

+1889
-1376
lines changed
 

‎.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"semi": false,
33
"singleQuote": true,
4-
"printWidth": 120
4+
"printWidth": 120,
5+
"trailingComma": "none"
56
}

‎docs/modules/PathReporter.ts.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Added in v1.0.0
2323
**Signature**
2424

2525
```ts
26-
export const PathReporter: Reporter<Array<string>> = ...
26+
export declare const PathReporter: Reporter<string[]>
2727
```
2828
2929
Added in v1.0.0
@@ -33,7 +33,7 @@ Added in v1.0.0
3333
**Signature**
3434
3535
```ts
36-
export function failure(es: Array<ValidationError>): Array<string> { ... }
36+
export declare function failure(es: Array<ValidationError>): Array<string>
3737
```
3838

3939
Added in v1.0.0
@@ -43,7 +43,7 @@ Added in v1.0.0
4343
**Signature**
4444

4545
```ts
46-
export function success(): Array<string> { ... }
46+
export declare function success(): Array<string>
4747
```
4848

4949
Added in v1.0.0

‎docs/modules/index.ts.md

+504-186
Large diffs are not rendered by default.

‎package-lock.json

+1,208-1,113
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@
4646
"@types/jest": "^23.3.8",
4747
"@types/node": "7.0.4",
4848
"benchmark": "2.1.4",
49-
"docs-ts": "^0.3.4",
49+
"docs-ts": "^0.4.0",
5050
"doctoc": "^1.4.0",
5151
"dtslint": "github:gcanti/dtslint",
5252
"fp-ts": "^2.0.0",
5353
"import-path-rewrite": "github:gcanti/import-path-rewrite",
5454
"jest": "^24.8.0",
5555
"mocha": "^5.2.0",
56-
"prettier": "^1.19.1",
56+
"prettier": "^2.0.2",
5757
"rimraf": "2.6.2",
5858
"ts-jest": "^24.0.2",
5959
"ts-node": "^7.0.1",
6060
"tslint": "^5.11.0",
6161
"tslint-config-standard": "^8.0.1",
62-
"typescript": "^3.7.4"
62+
"typescript": "^3.8.3"
6363
},
6464
"tags": [
6565
"typescript",

‎src/ThrowReporter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { isLeft } from 'fp-ts/lib/Either'
1111
* @deprecated
1212
*/
1313
export const ThrowReporter: Reporter<void> = {
14-
report: validation => {
14+
report: (validation) => {
1515
if (isLeft(validation)) {
1616
throw new Error(PathReporter.report(validation).join('\n'))
1717
}

‎src/index.ts

+136-37
Large diffs are not rendered by default.

‎test/PathReporter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { NumberFromString } from './helpers'
66
describe('PathReporter', () => {
77
it('should use the function name as error message', () => {
88
// tslint:disable-next-line: no-empty
9-
assert.deepStrictEqual(PathReporter.report(t.number.decode(function() {})), [
9+
assert.deepStrictEqual(PathReporter.report(t.number.decode(function () {})), [
1010
'Invalid value <function0> supplied to : number'
1111
])
1212
// tslint:disable-next-line: no-empty

‎test/TypeClass.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const BAA = new t.Type<number, string, string>(
1111
const n = parseFloat(s)
1212
return isNaN(n) ? t.failure(s, c) : t.success(n)
1313
},
14-
n => String(n)
14+
(n) => String(n)
1515
)
1616

1717
const BAI = t.string.pipe(BAA, 'T')

‎test/exact.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('exact', () => {
5353

5454
it('should succeed validating a valid value (refinement)', () => {
5555
// tslint:disable-next-line: deprecation
56-
const T = t.exact(t.refinement(t.type({ foo: t.string }), p => p.foo.length > 2))
56+
const T = t.exact(t.refinement(t.type({ foo: t.string }), (p) => p.foo.length > 2))
5757
assertSuccess(T.decode({ foo: 'foo' }))
5858
})
5959

@@ -108,14 +108,14 @@ describe('exact', () => {
108108

109109
it('should fail validating an invalid value (refinement)', () => {
110110
// tslint:disable-next-line: deprecation
111-
const T = t.exact(t.refinement(t.type({ foo: t.string }), p => p.foo.length > 2))
111+
const T = t.exact(t.refinement(t.type({ foo: t.string }), (p) => p.foo.length > 2))
112112
assertFailure(T, null, ['Invalid value null supplied to : Exact<({ foo: string } | <function1>)>'])
113113
assertFailure(T, { foo: 'a' }, ['Invalid value {"foo":"a"} supplied to : Exact<({ foo: string } | <function1>)>'])
114114
})
115115

116116
it('should strip additional properties (refinement)', () => {
117117
// tslint:disable-next-line: deprecation
118-
const T = t.exact(t.refinement(t.type({ foo: t.string }), p => p.foo.length > 2))
118+
const T = t.exact(t.refinement(t.type({ foo: t.string }), (p) => p.foo.length > 2))
119119
assertSuccess(T.decode({ foo: 'foo', bar: 1 }), { foo: 'foo' })
120120
})
121121

‎test/helpers.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function assertStrictEqual<T>(result: t.Validation<T>, expected: any): vo
1212
() => {
1313
throw new Error(`${result} is not a right`)
1414
},
15-
a => {
15+
(a) => {
1616
assert.deepStrictEqual(a, expected)
1717
}
1818
)
@@ -27,7 +27,7 @@ export function assertSuccess<T>(result: t.Validation<T>, expected?: T): void {
2727
() => {
2828
throw new Error(`${result} is not a right`)
2929
},
30-
a => {
30+
(a) => {
3131
if (expected !== undefined) {
3232
assert.deepStrictEqual(a, expected)
3333
}
@@ -44,7 +44,7 @@ export function assertStrictSuccess<T>(result: t.Validation<T>, expected: T): vo
4444
() => {
4545
throw new Error(`${result} is not a right`)
4646
},
47-
a => {
47+
(a) => {
4848
/* istanbul ignore next */
4949
if (expected !== undefined) {
5050
assert.strictEqual(a, expected)
@@ -74,7 +74,7 @@ export const NumberFromString = new t.Type<number, string, unknown>(
7474
'NumberFromString',
7575
t.number.is,
7676
(u, c) =>
77-
either.chain(t.string.validate(u, c), s => {
77+
either.chain(t.string.validate(u, c), (s) => {
7878
const n = +s
7979
return isNaN(n) ? t.failure(u, c, 'cannot parse to a number') : t.success(n)
8080
}),
@@ -85,14 +85,14 @@ export const HyphenatedString = new t.Type<string, string, unknown>(
8585
'HyphenatedString',
8686
(v): v is string => t.string.is(v) && v.length === 3 && v[1] === '-',
8787
(u, c) =>
88-
either.chain(t.string.validate(u, c), s => {
88+
either.chain(t.string.validate(u, c), (s) => {
8989
if (s.length === 2) {
9090
return right(s[0] + '-' + s[1])
9191
} else {
9292
return t.failure(s, c)
9393
}
9494
}),
95-
a => a[0] + a[2]
95+
(a) => a[0] + a[2]
9696
)
9797

9898
// tslint:disable-next-line: deprecation
@@ -105,7 +105,7 @@ export function withDefault<T extends t.Mixed>(
105105
return new t.Type(
106106
`withDefault(${type.name}, ${JSON.stringify(defaultValue)})`,
107107
type.is,
108-
v => type.decode(v != null ? v : defaultValue),
108+
(v) => type.decode(v != null ? v : defaultValue),
109109
type.encode
110110
)
111111
}

‎test/readonly.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ describe('readonly', () => {
4545

4646
it('should freeze the value', () => {
4747
const T = t.readonly(t.type({ a: t.number }))
48-
either.map(T.decode({ a: 1 }), x => assert.ok(Object.isFrozen(x)))
48+
either.map(T.decode({ a: 1 }), (x) => assert.ok(Object.isFrozen(x)))
4949
})
5050

5151
it('should not freeze in production', () => {
5252
const env = process.env.NODE_ENV
5353
process.env.NODE_ENV = 'production'
5454
const T = t.readonly(t.type({ a: t.number }))
55-
either.map(T.decode({ a: 1 }), x => assert.ok(!Object.isFrozen(x)))
55+
either.map(T.decode({ a: 1 }), (x) => assert.ok(!Object.isFrozen(x)))
5656
process.env.NODE_ENV = env
5757
})
5858
})

‎test/readonlyArray.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ describe('readonlyArray', () => {
4747

4848
it('should freeze the value', () => {
4949
const T = t.readonlyArray(t.number)
50-
either.map(T.decode([1]), x => assert.ok(Object.isFrozen(x)))
50+
either.map(T.decode([1]), (x) => assert.ok(Object.isFrozen(x)))
5151
})
5252

5353
it('should not freeze in production', () => {
5454
const env = process.env.NODE_ENV
5555
process.env.NODE_ENV = 'production'
5656
const T = t.readonlyArray(t.number)
57-
either.map(T.decode([1]), x => assert.ok(!Object.isFrozen(x)))
57+
either.map(T.decode([1]), (x) => assert.ok(!Object.isFrozen(x)))
5858
process.env.NODE_ENV = env
5959
})
6060
})

‎test/record.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe('record', () => {
159159
assertStrictEqual(T1.decode(value1), value1)
160160
const T2 = t.record(
161161
// tslint:disable-next-line: deprecation
162-
t.refinement(t.string, s => s.length >= 2),
162+
t.refinement(t.string, (s) => s.length >= 2),
163163
t.number
164164
)
165165
const value2 = { aa: 1 }

‎test/recursion.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type T = {
66
a: number
77
b: T | undefined | null
88
}
9-
const T: t.Type<T> = t.recursion('T', self =>
9+
const T: t.Type<T> = t.recursion('T', (self) =>
1010
t.type({
1111
a: t.number,
1212
b: t.union([self, t.undefined, t.null])
@@ -20,7 +20,7 @@ describe('recursion', () => {
2020
a: number
2121
b: A | null
2222
}
23-
const T: t.Type<A> = t.recursion('T', self =>
23+
const T: t.Type<A> = t.recursion('T', (self) =>
2424
t.type({
2525
a: t.number,
2626
b: t.union([self, t.null])
@@ -39,7 +39,7 @@ describe('recursion', () => {
3939
a: string
4040
b: O | null
4141
}
42-
const T: t.Type<A, O> = t.recursion('T', self =>
42+
const T: t.Type<A, O> = t.recursion('T', (self) =>
4343
t.type({
4444
a: NumberFromString,
4545
b: t.union([self, t.null])
@@ -61,7 +61,7 @@ describe('recursion', () => {
6161
a: number
6262
b: T | null | undefined
6363
}
64-
const T: t.Type<T> = t.recursion('T', self =>
64+
const T: t.Type<T> = t.recursion('T', (self) =>
6565
t.type({
6666
a: t.number,
6767
b: t.union([self, t.undefined, t.null])
@@ -92,7 +92,7 @@ describe('recursion', () => {
9292
a: string
9393
b: O | null
9494
}
95-
const T: t.Type<A, O> = t.recursion('T', self =>
95+
const T: t.Type<A, O> = t.recursion('T', (self) =>
9696
t.type({
9797
a: NumberFromString,
9898
b: t.union([self, t.null])
@@ -108,7 +108,7 @@ describe('recursion', () => {
108108
a: number
109109
b: T | null
110110
}
111-
const T = t.recursion<T>('T', self =>
111+
const T = t.recursion<T>('T', (self) =>
112112
t.type({
113113
a: t.number,
114114
b: t.union([self, t.null])

‎test/refinement.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ describe('refinement', () => {
66
describe('name', () => {
77
it('should assign a default name', () => {
88
// tslint:disable-next-line: deprecation
9-
const T = t.refinement(t.number, n => n >= 0)
9+
const T = t.refinement(t.number, (n) => n >= 0)
1010
assert.strictEqual(T.name, '(number | <function1>)')
1111
})
1212

1313
it('should accept a name', () => {
1414
// tslint:disable-next-line: deprecation
15-
const T = t.refinement(t.number, n => n >= 0, 'T')
15+
const T = t.refinement(t.number, (n) => n >= 0, 'T')
1616
assert.strictEqual(T.name, 'T')
1717
})
1818
})
@@ -28,7 +28,7 @@ describe('refinement', () => {
2828

2929
it('should check a prismatic value', () => {
3030
// tslint:disable-next-line: deprecation
31-
const T = t.refinement(NumberFromString, n => n % 1 === 0)
31+
const T = t.refinement(NumberFromString, (n) => n % 1 === 0)
3232
assert.strictEqual(T.is(1.2), false)
3333
assert.strictEqual(T.is('a'), false)
3434
assert.strictEqual(T.is(1), true)
@@ -38,7 +38,7 @@ describe('refinement', () => {
3838
describe('decode', () => {
3939
it('should succeed validating a valid value', () => {
4040
// tslint:disable-next-line: deprecation
41-
const T = t.refinement(t.number, n => n >= 0)
41+
const T = t.refinement(t.number, (n) => n >= 0)
4242
assertSuccess(T.decode(0))
4343
assertSuccess(T.decode(1))
4444
})

‎test/taggedUnion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('taggedUnion', () => {
7373
type: 'B'
7474
forest: Array<B>
7575
}
76-
const B = t.recursion<B>('B', Self =>
76+
const B = t.recursion<B>('B', (Self) =>
7777
t.type({
7878
type: t.literal('B'),
7979
forest: t.array(Self)

‎test/type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('type', () => {
130130
() => {
131131
assert.ok(false)
132132
},
133-
a => {
133+
(a) => {
134134
assert.deepStrictEqual(a, { a: 's', b: 1 })
135135
}
136136
)

‎test/union.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('union', () => {
5050
it('should handle refinements', () => {
5151
const A = t.type({ type: t.literal('A'), a: t.number })
5252
// tslint:disable-next-line: deprecation
53-
const B = t.refinement(A, x => x.a > 0)
53+
const B = t.refinement(A, (x) => x.a > 0)
5454
const T = t.union([B, A])
5555
assertSuccess(T.decode({ type: 'A', a: -1 }))
5656
})
@@ -113,8 +113,8 @@ describe('union', () => {
113113
super(
114114
'DateT',
115115
(u): u is Date => u instanceof Date,
116-
(u, c) => either.map(t.number.validate(u, c), n => new Date(n)),
117-
a => a.valueOf()
116+
(u, c) => either.map(t.number.validate(u, c), (n) => new Date(n)),
117+
(a) => a.valueOf()
118118
)
119119
}
120120
}

0 commit comments

Comments
 (0)
Please sign in to comment.