-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
61 lines (56 loc) · 1.24 KB
/
index.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import * as fs from '@ts-task/fs';
fs.appendFile('README.md', 'waat').fork(
err => {
// $ExpectType ErrnoException
err;
},
val => {
// $ExpectType void
val;
}
);
fs.mkdir('newdir', null).fork(
err => {
// $ExpectType ErrnoException
err;
},
val => {
// $ExpectType void
val;
}
);
fs.readFile('./README.md')
.fork(
err => {
err; // $ExpectType ErrnoException
if (err.code === 'ENOENT') {
console.error('Buu, the file does not exists');
}
},
buffer => {
buffer; // ExpectType Buffer
console.log(buffer.toString());
}
)
;
fs.open('./README.md', 'r')
.chain(fd => {
// $ExpectType number
fd;
const buf = Buffer.alloc(25);
return fs.read(fd, buf, 0, 24, 0)
.chain(_ => fs.close(fd))
.map(_ => buf)
;
}).fork(
err => {
// $ExpectType ErrnoException | UnknownError
err;
console.log('buu', err);
},
buff => {
// $ExpectType Buffer
buff;
console.log('wii', buff.toString());
}
);