microsoft / microsoft/TypeScript
Add Support for design-time decorators
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Now that decorators are supported in TypeScript (#2249), consider adding support for ambient/design-time-only decorators:
Ambient decorators can be an extensible way to declare properties on or associate special behavior to declarations; design time tools can leverage these associations to produce errors or produce documentation. For example:
Use cases:
- Deprecated/Obsolete, to support warning on use of specific API’s:
interface JQuery {
/**
* A selector representing selector passed to jQuery(), if any, when creating the original set.
* version deprecated: 1.7, removed: 1.9
*/
@@deprecated("Property is only maintained to the extent needed for supporting .live() in the jQuery Migrate plugin. It may be removed without notice in a future version.", false)
selector: string;
}
- Suppress linter warning:
@@suppressWarning("disallow-leading-underscore")
function __init() {
}
Proposal
Design-time (Ambient) decorators are:
- ambient functions
- have a special name starting with "@"
- are not emitted in output JS code, but persisted in .d.ts outputs.
Application
- Applying a design-time can only accept constant values. Variables would not be observable by the compiler at compile time. Here is the set of possible values:
- string literal,
- number literal,
- regexp literal,
- true keyword,
- false keyword,
- null keyword,
- undefined symbol,
- const enum members,
- array literals of one of the previous kinds,
- object literal with only properties with values of one of the previous kinds
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
Beginne damit, diesen Vorschlag zusammen mit TypeScript issue #2249 und der bestehenden Decorator-Unterstützung zu lesen. Bestimme das Design für Ambient-Funktionen, Argumente, die nur Konstanten enthalten, und die Bewahrung von .d.ts; die Arbeit ist abgeschlossen, wenn Decorators zur Designzeit akzeptiert, aus der JavaScript-Ausgabe weggelassen und in der Deklarationsausgabe beibehalten werden.
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
- 25/100