Skip to content

ts.createEmitHostFromProgram doesn't bind compilerHost methods to the compilerHost instance #1545

@Arnavion

Description

@Arnavion

Starting from 5a2fb94, the EmitHost returned from ts.createEmitHostFromProgram() returns functions on the compilerHost like so:

        return {
            getCanonicalFileName: compilerHost.getCanonicalFileName,
            getCurrentDirectory: compilerHost.getCurrentDirectory,
            getNewLine: compilerHost.getNewLine,
            writeFile: compilerHost.writeFile,
        };

Because of this, the implementations of those functions do not have access to the compilerHost object via this.

This doesn't matter for the default WScript and node.js compiler hosts because they use closures to capture their references, but it's a problem for custom compiler hosts that are implemented as classes, and worked before this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelates to the public API for TypeScriptBugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions