Skip to content

Commit 2840242

Browse files
authored
🤖 Merge PR DefinitelyTyped#73616 feat(emscripten) : Update writeFile API by @R3gardless
1 parent 492a7ba commit 2840242

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎types/emscripten/emscripten-tests.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ function FSTest(): void {
108108
FS.symlink("file", "link");
109109

110110
FS.writeFile("/foobar.txt", "Hello, world");
111+
112+
// Test writeFile with extended options
113+
FS.writeFile("/test-with-mode.txt", "content", { mode: parseInt("0644", 8) });
114+
FS.writeFile("/test-with-flags.txt", "content", { flags: "w+" });
115+
FS.writeFile("/test-with-canown.txt", "content", { canOwn: true });
116+
FS.writeFile("/test-with-all-opts.txt", "content", {
117+
flags: "w",
118+
mode: parseInt("0755", 8),
119+
canOwn: false,
120+
});
111121
FS.unlink("/foobar.txt");
112122

113123
FS.writeFile("file", "foobar");

‎types/emscripten/index.d.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,11 @@ declare namespace FS {
336336
function readFile(path: string, opts: { encoding: "binary"; flags?: string | undefined }): Uint8Array;
337337
function readFile(path: string, opts: { encoding: "utf8"; flags?: string | undefined }): string;
338338
function readFile(path: string, opts?: { flags?: string | undefined }): Uint8Array;
339-
function writeFile(path: string, data: string | ArrayBufferView, opts?: { flags?: string | undefined }): void;
339+
function writeFile(
340+
path: string,
341+
data: string | ArrayBufferView,
342+
opts?: { flags?: string | undefined; mode?: number | undefined; canOwn?: boolean | undefined },
343+
): void;
340344

341345
//
342346
// module-level FS code

0 commit comments

Comments
 (0)