microsoft / microsoft/TypeScript
Checking JS types does not accept @implements or @augments on constructor functions
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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:
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l’esempio reproducer.js ed esegui tsc --noEmit --checkJS --allowJS reproducer.js usando la versione interessata di TypeScript. Traccia la gestione di JSDoc @implements e @augments sulle funzioni costruttore; il lavoro è completato quando le annotazioni vengono accettate senza TS8022 e i controlli JavaScript esistenti rimangono validi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100