Open
Description
From bluebird user test
// @Filename: release/util.js
var ret = {
isNode: isNode,
isClass: isClass, // etc
}
ret.isRecentNode = ret.isNode && (function() { ... })();
// @Filename: release/async.js
const util = require('./util')
util.isNode // error
util.isRecentNode // ok
// @Filename: util.js
var globalObject = this;
var ret = {
x: 1,
global: globalObject,
}
ret.extra = 2;
module.exports = ret;
// @Filename: user.js
var util = require('./util')
util.global // ok
util.x // ok
util.extra // ok?
Expected behavior:
all util.* ok
Actual behavior:
error on global and x
Due to toplevel this
now having a type in the globalThis PR.
Note that this is a dist file from bluebird, where the intent is to provide a consistent global object as well as a consistent module.exports. But we get confused early on by module.exports
references and incorrectly assume that the file is intended to be a module, and that toplevel this
refers to the module, not globalThis
.