microsoft / microsoft/TypeScript
Checking JS types does not accept @implements or @augments on constructor functions
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
TypeScript Version: 3.9.5 (also tested on 3.9.3 initially)
Search Terms: @implements, jsdoc
Code
/**
* @param {string} name
* @implements {EventTarget}
* @constructor
*/
function Foo (name) {
this.name = name
}
/**
* @param {string} type
* @param {EventListenerOrEventListenerObject} listener
* @param {boolean | AddEventListenerOptions} [options]
*/
Foo.prototype.addEventListener = function (type, listener, options) {}
Then run tsc --noEmit --checkJS --allowJS reproducer.js
Expected behavior:
According to https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#constructor-functions-are-equivalent-to-classes, constructor functions are treated like classes. So using @implements or @augments on them should be possible. It used to work in the past.
Actual behavior:
reproducer.js:6:10 - error TS8022: JSDoc '@implements' is not attached to a class.
6 function Foo (name) {
~~~
Found 1 error.
Playground Link: I was not able to reproduce this in the playground (but it does not have the latest 3.9 versions available)
Related Issues:
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 mit dem reproducer.js-Beispiel und führe tsc --noEmit --checkJS --allowJS reproducer.js mit der betroffenen TypeScript-Version aus. Verfolge die Verarbeitung von JSDoc @implements und @augments bei Konstruktorfunktionen; abgeschlossen ist die Aufgabe, wenn die Annotationen ohne TS8022 akzeptiert werden und die bestehenden JavaScript-Prüfungen weiterhin gültig sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100