-
-
Notifications
You must be signed in to change notification settings - Fork 511
Expand file tree
/
Copy pathJson.ts
More file actions
47 lines (37 loc) · 915 Bytes
/
Copy pathJson.ts
File metadata and controls
47 lines (37 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as E from '../../src/Either'
import { pipe } from '../../src/function'
import * as _ from '../../src/Json'
declare const s: string
//
// parse
//
// $ExpectType Either<SyntaxError, Json>
_.parse(s)
//
// stringify
//
// $ExpectError
_.stringify<_.Json>(undefined)
// $ExpectError
_.stringify<_.Json>(() => {})
// $ExpectError
_.stringify<_.Json>(Symbol())
// $ExpectError
_.stringify<_.Json>({ a: undefined })
// $ExpectError
_.stringify<_.Json>({ ...{ a: undefined } })
// tslint:disable-next-line: interface-over-type-literal
interface AB {
readonly a: string
readonly b: number
}
const ab: AB = { a: 'a', b: 1 }
const abs: ReadonlyArray<AB> = [{ a: 'a', b: 1 }]
_.stringify({ a: 'a', b: 1 })
_.stringify(ab)
_.stringify({ ...ab })
_.stringify([{ a: 'a', b: 1 }])
_.stringify(abs)
_.stringify([...abs])
// $ExpectType Either<TypeError, string>
pipe(E.right('a'), E.chainFirst(_.stringify))