Microsoft/TypeScript
Auf GitHub ansehenAssignments to global objects in Javascript should be global declarations
Open
#22.446 geöffnet am 9. März 2018
BugDomain: JavaScriptEffort: ModerateExperience EnhancementHelp WantedRescheduled
Repository-Metriken
- Stars
- (48.455 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)
Beschreibung
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js
global.x = 1
window.y = 2
this.z = 3
var n = x + y + z
Expected behavior: No error, and x, y and z are visible globally.
Actual behavior: Errors:
- Can't find name 'global'
- 'Window' has no property 'y'
- Cannot find name 'x', 'y' or 'z'
Ideally, global should only be visible when targetting node and window should only be visible when targetting the browser. It's not a requirement, though.