microsoft / microsoft/TypeScript
Extend JSDoc @this to JavaScript class - apply @this to every non-static method
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
Let a node.js JavaScript (cjs) module:
// global .d.ts
declare class FooTS { tsProp: string; }
// xxx.js
// Goal: let intellisense treat class Foo's 'this' to fake class FooTS
// /** @this {FooTS} */ => currently this is invalid
class Foo {
/** @this {FooTS} */
constructor() { this.jsProp = 123; };
/** @this {FooTS} */
bar() { return this.tsProp; }
}
@this works for class methods, but it is verbose to add @this to every method.
It would be a QoL improvement to allow @this apply to JavaScript class with the effect that it apply @this to every non-static method.
This is probably invalid in original JSDoc, and doesn't make much sense.
But in vscode, it makes sense because user can use Typescript .d.ts for (more powerful and less verbose) type declaration for JavaScript implementation.
Alternatively, a more aggressive QoL could be that introduce a new tag to treat Foo type as FooTS type globally.
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
Das Issue nennt keine Implementierungsdatei, keinen Test und keinen Einstiegspunkt. Beginne damit, die bestehende JSDoc-@this-Verarbeitung von TypeScript und die Prüfungen für JavaScript-Klassenmethoden zu finden, und sieh dir anschließend verwandte Tests an. Als abgeschlossen gilt die Aufgabe, wenn ein @this auf Klassenebene den this-Typ für jede nicht statische Methode bereitstellen kann, ohne wiederholte Methodenannotationen zu erfordern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js, typescript
- Bereich
- compilers, developer-experience
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100