microsoft / microsoft/TypeScript
Object literal getters and setters doesn't work after spread syntax (ES2017 and below)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
The getters/setters will become normal/plain properties if a spread assignment is used before them.
🔎 Search Terms
Getter, setter, spread
🕗 Version & Regression Information
4.3.5
⏯ Playground Link
Playground link with relevant code
💻 Code
var Foo = {
key: 'value'
}
var Bar = {
... Foo, // this breaks the getters/setters after it.
get name() { console.log(9); return this._name },
set name(name) { this._name = `1${name}`},
_name: '',
}
🙁 Actual behavior
name setter and getter on the Bar object are “removed” and replaced with a plain name property, given that after compilation, the method used is Object.assign to piece the objects together.
🙂 Expected behavior
Getters and setters on Bar should still remain.
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 Playground collegato e l'esempio di spread di un object literal, quindi esamina l'emit ES2017-and-below che usa Object.assign. Confronta il comportamento generato con il comportamento previsto di getter e setter; il lavoro è completo quando gli accessors su Bar restano funzionanti dopo la compilazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, 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
- 35/100