resolve: fix type of readFileSync (#22571)

This commit is contained in:
Klaus Meinhardt
2018-01-04 18:25:40 +01:00
committed by Mohamed Hegazy
parent 46afc73cfb
commit ff8a4cfaa2
2 changed files with 7 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
// Type definitions for resolve
// Project: https://github.com/substack/node-resolve
// Definitions by: Mario Nebl <https://github.com/marionebl>
// Klaus Meinhardt <https://github.com/ajafff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -88,7 +89,7 @@ declare namespace resolve {
export interface SyncOpts extends Opts {
// how to read files synchronously (defaults to fs.readFileSync)
readFileSync?: (file: string) => Buffer;
readFileSync?: (file: string, charset: string) => string | Buffer;
// function to synchronously test whether a file exists
isFile?: (file: string) => boolean;
}

View File

@@ -73,6 +73,11 @@ function test_options_sync() {
}
});
console.log(resolved);
resolved = resolve.sync('typescript', {
readFileSync(file, charset) {
return fs.readFileSync(file, charset);
}
});
}
function test_is_core() {