1
1
import { Errno , ErrnoError } from '../error.js' ;
2
- import type { File } from '../file.js' ;
3
2
import type { FileSystem , FileSystemMetadata } from '../filesystem.js' ;
4
- import type { Stats } from '../stats.js' ;
3
+ import type { StatsLike } from '../stats.js' ;
5
4
import type { Mixin } from './shared.js' ;
6
5
7
6
/**
8
7
* @internal
9
8
*/
10
9
export interface ReadonlyMixin {
11
10
metadata ( ) : FileSystemMetadata ;
12
- rename ( oldPath : string , newPath : string ) : Promise < void > ;
13
- renameSync ( oldPath : string , newPath : string ) : void ;
14
- createFile ( path : string , flag : string , mode : number ) : Promise < File > ;
15
- createFileSync ( path : string , flag : string , mode : number ) : File ;
16
- unlink ( path : string ) : Promise < void > ;
17
- unlinkSync ( path : string ) : void ;
18
- rmdir ( path : string ) : Promise < void > ;
19
- rmdirSync ( path : string ) : void ;
20
- mkdir ( path : string , mode : number ) : Promise < void > ;
21
- mkdirSync ( path : string , mode : number ) : void ;
22
- link ( srcpath : string , dstpath : string ) : Promise < void > ;
23
- linkSync ( srcpath : string , dstpath : string ) : void ;
24
- sync ( path : string , data : Uint8Array , stats : Readonly < Stats > ) : Promise < void > ;
25
- syncSync ( path : string , data : Uint8Array , stats : Readonly < Stats > ) : void ;
11
+ rename ( oldPath : string , newPath : string ) : Promise < never > ;
12
+ renameSync ( oldPath : string , newPath : string ) : never ;
13
+ createFile ( path : string , flag : string , mode : number ) : Promise < never > ;
14
+ createFileSync ( path : string , flag : string , mode : number ) : never ;
15
+ unlink ( path : string ) : Promise < never > ;
16
+ unlinkSync ( path : string ) : never ;
17
+ rmdir ( path : string ) : Promise < never > ;
18
+ rmdirSync ( path : string ) : never ;
19
+ mkdir ( path : string , mode : number ) : Promise < never > ;
20
+ mkdirSync ( path : string , mode : number ) : never ;
21
+ link ( srcpath : string , dstpath : string ) : Promise < never > ;
22
+ linkSync ( srcpath : string , dstpath : string ) : never ;
23
+ sync ( path : string , data : Uint8Array , stats : Readonly < StatsLike < number > > ) : Promise < never > ;
24
+ syncSync ( path : string , data : Uint8Array , stats : Readonly < StatsLike < number > > ) : never ;
25
+ write ( path : string , buffer : Uint8Array , offset : number ) : Promise < never > ;
26
+ writeSync ( path : string , buffer : Uint8Array , offset : number ) : Promise < never > ;
26
27
}
27
28
28
29
/**
@@ -35,59 +36,67 @@ export function Readonly<T extends typeof FileSystem>(FS: T): Mixin<T, ReadonlyM
35
36
return { ...super . metadata ( ) , readonly : true } ;
36
37
}
37
38
38
- public async rename ( ) : Promise < void > {
39
+ public async rename ( ) : Promise < never > {
39
40
throw new ErrnoError ( Errno . EROFS ) ;
40
41
}
41
42
42
- public renameSync ( ) : void {
43
+ public renameSync ( ) : never {
43
44
throw new ErrnoError ( Errno . EROFS ) ;
44
45
}
45
46
46
- public async createFile ( ) : Promise < File > {
47
+ public async createFile ( ) : Promise < never > {
47
48
throw new ErrnoError ( Errno . EROFS ) ;
48
49
}
49
50
50
- public createFileSync ( ) : File {
51
+ public createFileSync ( ) : never {
51
52
throw new ErrnoError ( Errno . EROFS ) ;
52
53
}
53
54
54
- public async unlink ( ) : Promise < void > {
55
+ public async unlink ( ) : Promise < never > {
55
56
throw new ErrnoError ( Errno . EROFS ) ;
56
57
}
57
58
58
- public unlinkSync ( ) : void {
59
+ public unlinkSync ( ) : never {
59
60
throw new ErrnoError ( Errno . EROFS ) ;
60
61
}
61
62
62
- public async rmdir ( ) : Promise < void > {
63
+ public async rmdir ( ) : Promise < never > {
63
64
throw new ErrnoError ( Errno . EROFS ) ;
64
65
}
65
66
66
- public rmdirSync ( ) : void {
67
+ public rmdirSync ( ) : never {
67
68
throw new ErrnoError ( Errno . EROFS ) ;
68
69
}
69
70
70
- public async mkdir ( ) : Promise < void > {
71
+ public async mkdir ( ) : Promise < never > {
71
72
throw new ErrnoError ( Errno . EROFS ) ;
72
73
}
73
74
74
- public mkdirSync ( ) : void {
75
+ public mkdirSync ( ) : never {
75
76
throw new ErrnoError ( Errno . EROFS ) ;
76
77
}
77
78
78
- public async link ( ) : Promise < void > {
79
+ public async link ( ) : Promise < never > {
79
80
throw new ErrnoError ( Errno . EROFS ) ;
80
81
}
81
82
82
- public linkSync ( ) : void {
83
+ public linkSync ( ) : never {
83
84
throw new ErrnoError ( Errno . EROFS ) ;
84
85
}
85
86
86
- public async sync ( ) : Promise < void > {
87
+ public async sync ( ) : Promise < never > {
87
88
throw new ErrnoError ( Errno . EROFS ) ;
88
89
}
89
90
90
- public syncSync ( ) : void {
91
+ public syncSync ( ) : never {
92
+ throw new ErrnoError ( Errno . EROFS ) ;
93
+ }
94
+
95
+ public async write ( ) : Promise < never > {
96
+ throw new ErrnoError ( Errno . EROFS ) ;
97
+ }
98
+
99
+ public writeSync ( ) : never {
91
100
throw new ErrnoError ( Errno . EROFS ) ;
92
101
}
93
102
}
0 commit comments