microsoft / microsoft/TypeScript
Combining jsdoc `@this` and `@param` yields invalid `.d.ts` file
Offen
@sandersn arbeitet bereits daran.
Seit 02.8.2023.
Needs Investigation
Rescheduled
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Bug Report
When combining the JSDoc tags @this and @param, TypeScript yields invalid type definitions.
🔎 Search Terms
jsdoc this constructor
🕗 Version & Regression Information
- Behaviour was wrong in 4.5.
- Behaviour changed in 4.6, but is also wrong. This behaviour still exists in 5.2.0-dev.20230729.
⏯ Playground Link
Playground link with relevant code
💻 Code
/**
* @typedef Person
* @property {string} name
*/
/**
* @this {Person}
* @param {string} name
*/
export default function fn(name) {
this.name = name
}
🙁 Actual behavior
/**
* @typedef Person
* @property {string} name
*/
/**
* @this {Person}
* @param {string} name
*/
export default function fn(this: Person, name: string): void;
export default class fn {
/**
* @typedef Person
* @property {string} name
*/
/**
* @this {Person}
* @param {string} name
*/
constructor(this: Person, name: string);
// ^^^^^^^^^^^^ This is not valid TypeScript
name: string;
}
export type Person = {
name: string;
};
TypeScript 4.5 and before (also wrong):
/**
* @typedef Person
* @property {string} name
*/
/**
* @this {Person}
* @param {string} name
*/
export default function fn(name: string): void;
// ^^ Missing this
export default class fn {
/**
* @typedef Person
* @property {string} name
*/
/**
* @this {Person}
* @param {string} name
*/
constructor(name: string);
name: string;
}
export type Person = {
name: string;
};
🙂 Expected behavior
I would expect the class to not be generated. The generated class definition is the part that is invalid, and also if this function was written in TypeScript, the class would not be generated.
/**
* @typedef Person
* @property {string} name
*/
/**
* @this {Person}
* @param {string} name
*/
export default function fn(this: Person, name: string): void;
export type Person = {
name: string;
};
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.
Bewertung
Dieses Issue wurde noch nicht bewertet.