microsoft / microsoft/TypeScript
No error when accessing setter-only properties
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
"setter only", "setter-only"
🕗 Version & Regression Information
- This behavior is present in the current version of TypeScript, 5.4.4
⏯ Playground Link
💻 Code
class Foo {
set bar(baz: string) { }
}
const foo = new Foo();
const value: string = foo.bar; // This assignment should not be allowed, foo.bar will always be undefined!
🙁 Actual behavior
There is no error reported during type-checking.
🙂 Expected behavior
The type-checking should report an error for the assignment in the last line as foo.bar will always be undefined.
Additional information about the issue
#21759 is related, but that issue proposes a whole new language feature, this issue is solely about the lack of a type error.
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
Inizia con il TypeScript Playground collegato e riproduci l’assegnazione a una proprietà che dispone solo di un setter per confermare il comportamento attuale del controllo dei tipi. Segui il percorso del type-checker coinvolto nella lettura di foo.bar, quindi aggiungi una copertura che mostri che assegnare il risultato della lettura a string segnala un errore senza implementare la funzionalità separata discussa in #21759.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100