microsoft / microsoft/TypeScript

Assigning window.location after 5.8.2 upgrade fails

Open
#61,335 16 comments 38 reactions 1 assignee View on GitHub

@sandersn is already working on this.

Since Mar 3, 2025.

Needs Investigation
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.