microsoft / microsoft/TypeScript
Diagnostic code 8030 being incorrectly generated using JSDoc `@type` on a function.
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
Description
### 🔎 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_
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire le diagnostic avec types.ts et code.js en utilisant la version de TypeScript 7.0.2 signalée ainsi que la version antérieure 7.0.0-dev.260707.2. Suivez la manière dont la référence JSDoc @type vers Example['method'] est résolue et pourquoi | undefined est ajouté. Le travail est terminé lorsque le type de méthode valide ne produit plus le diagnostic 8030 et qu’une couverture de régression existe pour cet exemple.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, typescript
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 48/100