microsoft / microsoft/TypeScript

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

Đang mở
#62,127 1 bình luận 1 reaction 1 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

🔎 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
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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.