Add fs.writeFileSync overloads and tests

This commit is contained in:
kimu_shu
2017-06-28 11:58:50 +09:00
parent c126a9ec44
commit 1205f064bd
9 changed files with 18 additions and 0 deletions
+1
View File
@@ -2835,6 +2835,7 @@ declare module "fs" {
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFileSync(filename: string, data: any, encoding: string): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
+3
View File
@@ -169,6 +169,9 @@ namespace fs_tests {
encoding: "ascii"
},
assert.ifError);
fs.writeFileSync("testfile", "content", "utf8");
fs.writeFileSync("testfile", "content", { encoding: "utf8" });
}
{
+2
View File
@@ -47,6 +47,8 @@ fs.writeFile("Harry Potter",
},
assert.ifError);
fs.writeFileSync("testfile", "content", { encoding: "utf8" });
var content: string,
buffer: Buffer;
+1
View File
@@ -1775,6 +1775,7 @@ declare module "fs" {
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFileSync(filename: string, data: any, encoding: string): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
+3
View File
@@ -151,6 +151,9 @@ namespace fs_tests {
encoding: "ascii"
},
assert.ifError);
fs.writeFileSync("testfile", "content", "utf8");
fs.writeFileSync("testfile", "content", { encoding: "utf8" });
}
{
+1
View File
@@ -2564,6 +2564,7 @@ declare module "fs" {
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFileSync(filename: string, data: any, encoding: string): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
+3
View File
@@ -168,6 +168,9 @@ namespace fs_tests {
encoding: "ascii"
},
assert.ifError);
fs.writeFileSync("testfile", "content", "utf8");
fs.writeFileSync("testfile", "content", { encoding: "utf8" });
}
{
+1
View File
@@ -2693,6 +2693,7 @@ declare module "fs" {
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFileSync(filename: string, data: any, encoding: string): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
+3
View File
@@ -169,6 +169,9 @@ namespace fs_tests {
encoding: "ascii"
},
assert.ifError);
fs.writeFileSync("testfile", "content", "utf8");
fs.writeFileSync("testfile", "content", { encoding: "utf8" });
}
{