microsoft / microsoft/TypeScript
Support `@extends` tag for ES5-style classes
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
TypeScript Version: 3.7.5 and 3.8.0-dev.20200123
Search Terms: extends not attached to a class
I'm currently evaluating if TypeScript can be used to type-check old closure compiler projects which use JSDoc annotations for typing and to generate *.d.ts files for it so the old projects can be easily used within new typescript projects. But unfortunately the @extends annotation is not working as expected. I would understand if TypeScript simply didn't support it (Then this would be a feature request) but the error message error TS8022: JSDoc '@extends' is not attached to a class thrown by the compiler suggests that there is some support for but it doesn't work as expected.
Please note that the real class inheritance code which actually extends class Sub from Base is omitted in the code example below because it is irrelevant to the compiler.
Code
// Compile with: tsc --checkJS --allowJS --outDir out test.js
/**
* @constructor
* @class
*/
function Base() {}
Base.prototype.foo = function() {}
/**
* @constructor
* @class
* @extends {Base}
*/
function Sub() {}
Sub.prototype.bar = function() {}
Expected behavior:
Typescript should recognize type Sub to be a class which extends class Base.
Actual behavior:
Compilation fails with this error:
$ tsc --checkJS --allowJS --outDir out test.js
test.js:14:10 - error TS8022: JSDoc '@extends' is not attached to a class.
14 function Sub() {}
~~~
Found 1 error.
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, den gemeldeten tsc --checkJS --allowJS-Befehl für test.js nachzustellen und die Verarbeitung von JSDoc @extends für den Konstruktor im ES5-Stil durch den Compiler nachzuverfolgen. Als abgeschlossen gilt die Aufgabe, wenn das Beispiel ohne TS8022 kompiliert und TypeScript erkennt, dass Sub von Base erbt, mit Testabdeckung für diesen Fall.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100