microsoft / microsoft/TypeScript
Semantic highlighting: Non-explicit readonly properties not shown as such
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il comportamento dell’evidenziazione semantica utilizzando l’esempio collegato di TypeScript Playground e analizza l’evidenziazione corrispondente in VSCode. Confronta i quattro casi di proprietà readonly, inclusi Readonly, le unioni e il getter, e considera l’issue completata quando ogni proprietà readonly viene evidenziata in modo coerente come previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100