microsoft / microsoft/TypeScript

"used before being assigned" fires on LHS inside parens/type assertion

Aperta
#62,127 1 commento 1 reazione 1 assegnatario Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

### 🔎 Search Terms

used before being assigned cast type assertion left side LHS parens parentheses

### 🕗 Version & Regression Information

- This is the behavior changed in 5.7

### ⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250725#code/CYUwxgNghgTiAEAzArgOzAFwJYHtX1AGcwYsAjEAClSgFsQAueQjU1AcwBolUnKBKeAF4AfPABuOLMH5NJ0gLAAoZaEiwEKdNjzwKiHHACiUMAAtKiXvAHCx8mXKnAA3MtXhoceOsKF4AMo49BhmWBzwAN7K8Eg4OAJMqMi0FDBuSgC+7kpEJORUAESF3LaiUTHwECAYetBmTEEhYRwZlfqGICbmlGVi0UqxsZRk9fBQ-lCoAJ6CQj7QfvAA6jgA7lGZGbGZ-Mq7OR7EpBSUxaVz-ZXVtaNQDYHBNS3sbYN6IAbGphZ9Fe-DO5mOYLCb+VYbSJbSoHLJ7JRAA

### 💻 Code

```ts
declare function describe(name: string, fn: () => void): void

declare function beforeEach(fn: () => void): void;

declare class Something {
foo(): number;
}

describe("", () => {
let blah: Something;

beforeEach(() => {
(blah as any) = class Wow {};
})
})

describe("", () => {
let blah: Something;

beforeEach(() => {
(blah) = class Wow {};
})
})
```

### 🙁 Actual behavior

Both assignments error with `is used before being assigned`.

### 🙂 Expected behavior

Neither should, as they are writes.

### Additional information about the issue

_No response_

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.