microsoft / microsoft/TypeScript

improvements for non-experimental decorator types

Offen
#56,426 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Domain: Decorators Suggestion
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
⭐ 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
  1. What do you want to use this for? decorators whose code handles any value type
  2. 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
  3. What workarounds are you using in the meantime? I make my own catchall (not that big a deal, but neither would making DecoratorContext myself be

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Ö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

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.