Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignments to global objects in Javascript should be global declarations #22446

Open
sandersn opened this issue Mar 9, 2018 · 3 comments
Open
Labels
Bug A bug in TypeScript Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Rescheduled This issue was previously scheduled to an earlier milestone
Milestone

Comments

@sandersn
Copy link
Member

sandersn commented Mar 9, 2018

// @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:

  1. Can't find name 'global'
  2. 'Window' has no property 'y'
  3. 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.

@sandersn sandersn added Bug A bug in TypeScript Salsa labels Mar 9, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Mar 9, 2018

Should be covered by #14052 and #19816

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Bug A bug in TypeScript Salsa labels Mar 9, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
@sandersn sandersn added Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". and removed Duplicate An existing issue was already created labels Jun 12, 2020
@sandersn sandersn reopened this Jun 12, 2020
@sandersn
Copy link
Member Author

Not really a dupe of those other issues; this one is about assignment declarations on a value (window) creating properties in the global symbol table.

#14052 is just about types.
#19816 is about making window show properties from globalThis, which is backward from this feature.

@sandersn sandersn added Experience Enhancement Noncontroversial enhancements Bug A bug in TypeScript Help Wanted You can do this labels Jun 12, 2020
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.1.1 milestone Sep 2, 2020
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

6 participants