microsoft / microsoft/TypeScript

Semantic highlighting: Non-explicit readonly properties not shown as such

Đang mở
#56,563 0 bình luận 2 reaction 0 người được giao Xem trên GitHub

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

Awaiting More Feedback Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

🔎 Search Terms

readonly, readonly properties

🕗 Version & Regression Information

Nothing to put in here, has never worked, I don't think.

Might be a language server issue, idk

⏯ Playground Link

https://www.typescriptlang.org/play#code/CYUwxgNghgTiAEYD2A7AzgF3lAXPA3gFACQcUwqEAntgEZigBmeKArgLa0gyEC+hUAHRR6TQqEiwEydFlp4ASiHKUqAHiLERDEM3htO3PgD5CtYaN3jw0OIlSZEefPDIUU1Ojr0YYrBLzwAD4ErsruntpMeIxQEGgBhGAW3oQAlozwABTJUboAlAQkuZaMfEnQaGjwACJFxADmIFh5jFmFmqTNrDAo8ACMJPz8ErbSDljAeDXiKWJAA

💻 Code

In this example, there are 4 variables, all with a readonly property called abcdef, only the first one is registered by the IDE as being readonly, even though they are.

declare const a: {
	readonly abcdef: number
}
a.abcdef
declare const b: Readonly<{
	abcdef: number
}>
b.abcdef
declare const c: { readonly abcdef: true } | { readonly abcdef: false }
c.abcdef
if (c.abcdef) {
	c.abcdef
}
class D {
	get abcdef() {
		return 1
	}
}
declare const d: D
d.abcdef
🙁 Actual behavior

This is an IDE issue regarding code highlighting. When a property is readonly, but not explicitly so, it doesn't show up as a readonly property. TypeScript knows it's readonly, but the syntax highlighting doesn't always match it, which can be a bit confusing, just like if consts didn't always have the different highlighting. It's a lot nicer when you can always immediatly tell when something is readony, not by having to test it out and it makes it a lot more readable.

🙂 Expected behavior

All the properties should be registered as readonly, in the case of VSCode, the same colour as constants

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.

Hướng nghiên cứu

Tái hiện hành vi tô sáng ngữ nghĩa bằng ví dụ TypeScript Playground được liên kết và kiểm tra phần tô sáng tương ứng trong VSCode. So sánh bốn trường hợp thuộc tính readonly, bao gồm Readonly, các kiểu hợp và getter, đồng thời xem issue là hoàn tất khi mọi thuộc tính readonly đều được tô sáng nhất quán như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

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.