microsoft / microsoft/TypeScript
Assigning window.location after 5.8.2 upgrade fails
@sandersn is already working on this.
Since Mar 3, 2025.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
### 🔎 Search Terms
Unable to assign window.location typescript 5.8.2
error TS2322: Type 'Location' is not assignable to type 'string & Location'.
Type 'Location' is not assignable to type 'string'.
### 🕗 Version & Regression Information
- This changed between versions 5.7.3 and 5.8.2
### ⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.8.2#code/O4SwdgJg9sB0A2UDGBDALiKYAEBebokMCy6mYA3AFBA
### 💻 Code
```ts
window.location = window.location;
```
### 🙁 Actual behavior
Failing with error:
```
error TS2322: Type 'Location' is not assignable to type 'string & Location'.
Type 'Location' is not assignable to type 'string'.
```
### 🙂 Expected behavior
Expect it to either be a documented breaking change, OR it should continue to work as it did in 5.7.3:
https://www.typescriptlang.org/play/?ts=5.7.3#code/O4SwdgJg9sB0A2UDGBDALiKYAEBebokMCy6mYA3AFBA
### Additional information about the issue
_No response_
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.
Assessment
This issue has not been assessed yet.