-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specifically
Milestone
Description
The addition of element accesses on exports
broke the uglify-js
user suite test. This is a minimal repro:
Code
// @noEmit: true
// @checkJs: true
// @allowJs: true
// @strict: true
// @filename: file1.js
// this file _should_ be a global file
var GlobalThing = { x: 12 };
/**
* @param {*} type
* @param {*} ctor
* @param {*} exports
*/
function f(type, ctor, exports) {
if (typeof exports !== "undefined") {
exports["AST_" + type] = ctor;
}
}
// @filename: ref.js
GlobalThing.x;
Expected behavior:
file1.js
is treated as a globally scoped file and ref.js
typechecks.
Actual behavior:
Err in ref.js
, no referenced found to GlobalThing
in file1.js
because file1.js
is treated like a module.
cc @sandersn @andrewbranch While this error only appeared once we started to recognize element access export assignments (even if we can't bind them because they're computed names, for some reason), that we flag a reference to a variable named exports
within a function body (and a conditional!) as a module also seems questionable.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specifically