microsoft / microsoft/TypeScript
Semantic highlighting: Non-explicit readonly properties not shown as such
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 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
💻 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Verhalten der semantischen Hervorhebung anhand des verlinkten TypeScript Playground-Beispiels und untersuche die entsprechende VSCode-Hervorhebung. Vergleiche die vier Fälle mit readonly-Eigenschaften, einschließlich Readonly, Unions und des Getters, und betrachte das Issue als abgeschlossen, wenn jede readonly-Eigenschaft erwartungsgemäß konsistent hervorgehoben wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100