microsoft / microsoft/TypeScript

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

オープン
#56,563 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

🔎 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた TypeScript Playground の例を使用してセマンティックハイライトの動作を再現し、対応する VSCode のハイライトを調査してください。Readonly、ユニオン、getter を含む4つの readonly プロパティのケースを比較し、すべての readonly プロパティが期待どおり一貫してハイライトされれば issue は完了とみなします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。