Skip to content

Commit 0d6ce02

Browse files
author
Arnavion
committed
Don't lose the this reference for compilerHost methods.
Fixes #1545
1 parent 755d806 commit 0d6ce02

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/compiler/program.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ module ts {
149149
getDiagnosticsProducingTypeChecker,
150150
getCommonSourceDirectory: () => commonSourceDirectory,
151151
emit,
152-
getCurrentDirectory: host.getCurrentDirectory,
152+
getCurrentDirectory: () => host.getCurrentDirectory(),
153153
getNodeCount: () => getDiagnosticsProducingTypeChecker().getNodeCount(),
154154
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
155155
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
@@ -159,14 +159,15 @@ module ts {
159159

160160
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
161161
return {
162-
getCanonicalFileName: host.getCanonicalFileName,
162+
getCanonicalFileName: fileName => host.getCanonicalFileName(fileName),
163163
getCommonSourceDirectory: program.getCommonSourceDirectory,
164164
getCompilerOptions: program.getCompilerOptions,
165-
getCurrentDirectory: host.getCurrentDirectory,
166-
getNewLine: host.getNewLine,
165+
getCurrentDirectory: () => host.getCurrentDirectory(),
166+
getNewLine: () => host.getNewLine(),
167167
getSourceFile: program.getSourceFile,
168168
getSourceFiles: program.getSourceFiles,
169-
writeFile: writeFileCallback || host.writeFile,
169+
writeFile: writeFileCallback || (
170+
(fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)),
170171
};
171172
}
172173

0 commit comments

Comments
 (0)