microsoft / microsoft/TypeScript
Diagnostic code 8030 being incorrectly generated using JSDoc `@type` on a function.
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
### 🔎 Search Terms
Diagnostic 8030 is being generated incorrectly when using JSDoc `@type` on a method when the type is being referred to from an interface. This is using the new `tsc` LSP - version 7.0.2.
### 🕗 Version & Regression Information
- This changed between versions 7.0.0-dev.260707.2 and 7.0.2.
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about new native issues being transferred into the main typescript repo.
### ⏯ Playground Link
_No response_
### 💻 Code
```ts
// types.ts
interface Example {
method (): number;
}
export {};
// code.js
const exampleFns = {
/**
* @type {Example['method']} // A JSDoc `@type` tag on a function must have a signature with the correct number of arguments.
*/
method () {
return Math.random();
}
};
```
### 🙁 Actual behavior
in this example, the diagnostic and LSP info does not tell the user that typescript is internally suffixing `| undefined` to the type. As such wrapping the type in `NonNullable` removes the error diagnostic, I do not believe this to be intended behaviour as previous iterations the golang native LSP `tsgo` (7.0.0-dev.260707.2) did not produce this diagnostic, nor did previous versions of typescript.
### 🙂 Expected behavior
The type should be properly referenced with no additional suffixing of types, as it used to.
### Additional information about the issue
_No response_
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, die Diagnose mit types.ts und code.js unter Verwendung der gemeldeten TypeScript-Version 7.0.2 und der früheren Version 7.0.0-dev.260707.2 zu reproduzieren. Verfolge, wie die JSDoc-Referenz @type auf Example['method'] aufgelöst wird und warum | undefined hinzugefügt wird. Als erledigt gilt die Aufgabe, wenn der gültige Methodentyp nicht mehr die Diagnose 8030 erzeugt und eine Regressionstestabdeckung für dieses Beispiel vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100