Typescript: window.location is not supposed to be a read-only property

Created on 18 Oct 2017  路  2Comments  路  Source: microsoft/TypeScript

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.
Bug lib.d.ts Fixed help wanted

Most helpful comment

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

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

All 2 comments

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings