From ff8a4cfaa2af9626ef6faac938f933fec8cd30f5 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 4 Jan 2018 18:25:40 +0100 Subject: [PATCH] resolve: fix type of readFileSync (#22571) --- types/resolve/index.d.ts | 3 ++- types/resolve/resolve-tests.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/resolve/index.d.ts b/types/resolve/index.d.ts index ed047af9c6..fd3bf8272b 100644 --- a/types/resolve/index.d.ts +++ b/types/resolve/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for resolve // Project: https://github.com/substack/node-resolve // Definitions by: Mario Nebl +// Klaus Meinhardt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -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; } diff --git a/types/resolve/resolve-tests.ts b/types/resolve/resolve-tests.ts index 1f9f50b5ee..c4b89feb46 100644 --- a/types/resolve/resolve-tests.ts +++ b/types/resolve/resolve-tests.ts @@ -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() {