microsoft / microsoft/TypeScript
improvements for non-experimental decorator types
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 Search Terms
github typescript decorator value type
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- 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
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
This is a request to add a new utility type because TypeScript added one for decorator contexts but not for values
The DecoratorContext type is nice for catching all context types:
function decorator(value: unknown, context: DecoratorContext) { // optionally use a more specific type.
// ...
}
But for value, there is not a good catch-all type.
📃 Motivating Example
If we have a context catch all type, why not also have a value catch all type, f.e. something like :
export type DecoratedValue = Constructor | Function | ClassAccessorDecoratorTarget<object, unknown> | undefined
💻 Use Cases
- What do you want to use this for? decorators whose code handles any value type
- What shortcomings exist with current approaches? we have to make the catchall for value ourselves, but we don't have to do that for context
- What workarounds are you using in the meantime? I make my own catchall (not that big a deal, but neither would making
DecoratorContextmyself be
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es wird keine Datei oder kein Test genannt. Beginne damit, die vorhandene Deklaration von DecoratorContext und die von ihr abgedeckten Decorator-Typdefinitionen zu finden, und vergleiche dann die vorgeschlagenen DecoratedValue-Member mit dem aktuellen Typsystem. Als erledigt gilt die Aufgabe, wenn ein vereinbarter Catch-all-Wertetyp hinzugefügt wurde, ohne das erzeugte JavaScript oder das bestehende Verhalten zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100