microsoft / microsoft/TypeScript
Semantic highlighting: Non-explicit readonly properties not shown as such
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the semantic-highlighting behavior using the linked TypeScript Playground example and inspect the corresponding VSCode highlighting. Compare the four readonly-property cases, including Readonly, unions, and the getter, and consider the issue done when every readonly property is highlighted consistently as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100