Skip to content

window.location is not supposed to be a read-only property #19277

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

Closed
haskaalo opened this issue Oct 18, 2017 · 2 comments
Closed

window.location is not supposed to be a read-only property #19277

haskaalo opened this issue Oct 18, 2017 · 2 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@haskaalo
Copy link

In lib.dom.d.ts L13157 window.location is set as a read-only property but it can also be used to redirect a user by changing the value of it.

For example:

window.location = "/";

Error:

[ts] Cannot assign to 'location' because it is a constant or a read-only property.
@mhegazy mhegazy added Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this Bug A bug in TypeScript labels Oct 18, 2017
@mhegazy mhegazy added this to the Community milestone Oct 18, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 18, 2017

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

Kingwl added a commit to Kingwl/TSJS-lib-generator that referenced this issue Oct 20, 2017
@KINGH242
Copy link

KINGH242 commented Jan 16, 2018

Workaround, or maybe what is actually supposed to be used is:

window.location.href = "http://www.google.com"

@mhegazy mhegazy modified the milestones: Community, TypeScript 2.8 Mar 9, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 9, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants