microsoft / microsoft/TypeScript
Suggestion: Add built-in vanilla constructor interface
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Search Terms
- built-in constructor interface
Suggestion
Consider the below from the official TS docs on decorators:
function classDecorator<T extends {new(...args:any[]):{}}>(constructor:T) {
return class extends constructor {
newProperty = "new property";
hello = "override";
}
}
vs:
function classDecorator<T extends Constructor>(constructor:T) {
return class extends constructor {
newProperty = "new property";
hello = "override";
}
}
I suggest we have a built-in Constructor interface so we can save typing.
Use Cases
See above.
Examples
See above.
Checklist
My suggestion meets these guidelines:
- [x ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x ] This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- [ x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- [x ] This feature would agree with the rest of TypeScript's Design Goals.
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 leggendo la documentazione collegata di TypeScript sui decorators e gli esempi della issue relativi all'interfaccia Constructor proposta. Individua quindi la gestione da parte del compilatore delle dichiarazioni dei tipi integrati e i test correlati; il lavoro è completato quando l'interfaccia è disponibile come proposto, senza modificare il JavaScript emesso né il comportamento di runtime esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100