Skip to content

Commit 79dc0f9

Browse files
Merge pull request #1546 from Arnavion/fix-emithost-this-binding
Don't lose the this reference for compilerHost methods.
2 parents b8ebf56 + 0d6ce02 commit 79dc0f9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/compiler/program.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ module ts {
171171
getDiagnosticsProducingTypeChecker,
172172
getCommonSourceDirectory: () => commonSourceDirectory,
173173
emit,
174-
getCurrentDirectory: host.getCurrentDirectory,
174+
getCurrentDirectory: () => host.getCurrentDirectory(),
175175
getNodeCount: () => getDiagnosticsProducingTypeChecker().getNodeCount(),
176176
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
177177
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
@@ -181,14 +181,15 @@ module ts {
181181

182182
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
183183
return {
184-
getCanonicalFileName: host.getCanonicalFileName,
184+
getCanonicalFileName: fileName => host.getCanonicalFileName(fileName),
185185
getCommonSourceDirectory: program.getCommonSourceDirectory,
186186
getCompilerOptions: program.getCompilerOptions,
187-
getCurrentDirectory: host.getCurrentDirectory,
188-
getNewLine: host.getNewLine,
187+
getCurrentDirectory: () => host.getCurrentDirectory(),
188+
getNewLine: () => host.getNewLine(),
189189
getSourceFile: program.getSourceFile,
190190
getSourceFiles: program.getSourceFiles,
191-
writeFile: writeFileCallback || host.writeFile,
191+
writeFile: writeFileCallback || (
192+
(fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)),
192193
};
193194
}
194195

0 commit comments

Comments
 (0)