TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx)
typescript@beta or typescript@next
Code
// A *self-contained* demonstration of the problem follows...
import require from "some/module"
export foo from "some/other/module"
require("a single arg")
Expected behavior:
has a binding for foo
Actual behavior:
require() call expression is not checked for scope, that it is the module's require or that externalModuleIndicator already is present, it will redefine the symbol.
workaround in a custom host getSourceFile
Object.defineProperty(sourceFile, "commonJsModuleIndicator", {
get: () => sourceFile["externalModuleIndicator"]
});