microsoft / microsoft/TypeScript
Assignments to global objects in Javascript should be global declarations
Open
Nobody has claimed this yet.
Bug
Domain: JavaScript
Effort: Moderate
Experience Enhancement
Help Wanted
Rescheduled
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
// @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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied JavaScript sample using @allowJs, @checkJs, and @noEmit, and compare how assignments through global, window, and this are checked. Done means the sample reports no errors and x, y, and z are visible globally, while the optional Node/browser distinction is considered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100