|
1 | 1 | import {expectType} from 'tsd-check';
|
2 | 2 | import writeJsonFile, {sync, Replacer, SortKeys, JSONStringifyable} from '.';
|
3 | 3 |
|
4 |
| -(async () => { |
5 |
| - expectType<JSONStringifyable>('π¦'); |
6 |
| - expectType<JSONStringifyable>(1); |
7 |
| - expectType<JSONStringifyable>(true); |
8 |
| - expectType<JSONStringifyable>(new Date()); |
9 |
| - expectType<JSONStringifyable>(['hello', 'world']); |
10 |
| - expectType<JSONStringifyable>({unicorn: 'π¦'}); |
| 4 | +expectType<JSONStringifyable>('π¦'); |
| 5 | +expectType<JSONStringifyable>(1); |
| 6 | +expectType<JSONStringifyable>(true); |
| 7 | +expectType<JSONStringifyable>(new Date()); |
| 8 | +expectType<JSONStringifyable>(['hello', 'world']); |
| 9 | +expectType<JSONStringifyable>({unicorn: 'π¦'}); |
11 | 10 |
|
12 |
| - expectType<SortKeys>(() => 1); |
13 |
| - expectType<SortKeys>((a: string) => a.length); |
14 |
| - expectType<SortKeys>((a: string, b: string) => a.length - b.length); |
| 11 | +expectType<SortKeys>(() => 1); |
| 12 | +expectType<SortKeys>((a: string) => a.length); |
| 13 | +expectType<SortKeys>((a: string, b: string) => a.length - b.length); |
15 | 14 |
|
16 |
| - expectType<Replacer>(() => 1); |
17 |
| - expectType<Replacer>(() => 'unicorn'); |
18 |
| - expectType<Replacer>(() => true); |
19 |
| - expectType<Replacer>(() => null); |
20 |
| - expectType<Replacer>(() => undefined); |
21 |
| - expectType<Replacer>(() => ({unicorn: 'π¦'})); |
22 |
| - expectType<Replacer>(() => ['unicorn', 1]); |
23 |
| - expectType<Replacer>(() => () => 'foo'); |
24 |
| - expectType<Replacer>((key: string) => key.toUpperCase()); |
25 |
| - expectType<Replacer>((key: string, value: string) => (key + value).toUpperCase()); |
| 15 | +expectType<Replacer>(() => 1); |
| 16 | +expectType<Replacer>(() => 'unicorn'); |
| 17 | +expectType<Replacer>(() => true); |
| 18 | +expectType<Replacer>(() => null); |
| 19 | +expectType<Replacer>(() => undefined); |
| 20 | +expectType<Replacer>(() => ({unicorn: 'π¦'})); |
| 21 | +expectType<Replacer>(() => ['unicorn', 1]); |
| 22 | +expectType<Replacer>(() => () => 'foo'); |
| 23 | +expectType<Replacer>((key: string) => key.toUpperCase()); |
| 24 | +expectType<Replacer>((key: string, value: string) => (key + value).toUpperCase()); |
26 | 25 |
|
27 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'})); |
28 |
| - expectType<void>(await writeJsonFile('unicorn.json', 'π¦')); |
29 |
| - expectType<void>(await writeJsonFile('date.json', new Date())); |
30 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {detectIndent: true})); |
31 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {indent: ' '})); |
32 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {indent: 4})); |
33 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {mode: 0o666})); |
34 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {replacer: ['unicorn', 1]})); |
35 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {replacer: () => 'unicorn'})); |
36 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {sortKeys: () => -1})); |
37 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {sortKeys: (a: string, b: string) => a.length - b.length})); |
38 |
| - expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {sortKeys: true})); |
| 26 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'})); |
| 27 | +expectType<void>(await writeJsonFile('unicorn.json', 'π¦')); |
| 28 | +expectType<void>(await writeJsonFile('date.json', new Date())); |
| 29 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {detectIndent: true})); |
| 30 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {indent: ' '})); |
| 31 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {indent: 4})); |
| 32 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {mode: 0o666})); |
| 33 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {replacer: ['unicorn', 1]})); |
| 34 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {replacer: () => 'unicorn'})); |
| 35 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {sortKeys: () => -1})); |
| 36 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {sortKeys: (a: string, b: string) => a.length - b.length})); |
| 37 | +expectType<void>(await writeJsonFile('unicorn.json', {unicorn: 'π¦'}, {sortKeys: true})); |
39 | 38 |
|
40 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'})); |
41 |
| - expectType<void>(sync('unicorn.json', 'π¦')); |
42 |
| - expectType<void>(sync('date.json', new Date())); |
43 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {detectIndent: true})); |
44 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {indent: ' '})); |
45 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {indent: 4})); |
46 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {mode: 0o666})); |
47 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {replacer: ['unicorn', 1]})); |
48 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {replacer: () => 'unicorn'})); |
49 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {sortKeys: () => -1})); |
50 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {sortKeys: (a: string, b: string) => a.length - b.length})); |
51 |
| - expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {sortKeys: true})); |
52 |
| -})(); |
| 39 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'})); |
| 40 | +expectType<void>(sync('unicorn.json', 'π¦')); |
| 41 | +expectType<void>(sync('date.json', new Date())); |
| 42 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {detectIndent: true})); |
BBC4
| 43 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {indent: ' '})); |
| 44 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {indent: 4})); |
| 45 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {mode: 0o666})); |
| 46 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {replacer: ['unicorn', 1]})); |
| 47 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {replacer: () => 'unicorn'})); |
| 48 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {sortKeys: () => -1})); |
| 49 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {sortKeys: (a: string, b: string) => a.length - b.length})); |
| 50 | +expectType<void>(sync('unicorn.json', {unicorn: 'π¦'}, {sortKeys: true})); |
0 commit comments