Skip to content

Preserve the jsdoc comments for interface while compiling. #42547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
liukeyi300 opened this issue Jan 29, 2021 · 2 comments
Open

Preserve the jsdoc comments for interface while compiling. #42547

liukeyi300 opened this issue Jan 29, 2021 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@liukeyi300
Copy link

Suggestion

πŸ” Search Terms

tsc jsdoc

βœ… Viability Checklist

My suggestion meets these guidelines:

  • βœ… This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • βœ… This wouldn't change the runtime behavior of existing JavaScript code
  • βœ… This could be implemented without emitting different JS based on the types of the expressions
  • βœ… This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • βœ… This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Add a configuraion for preserving the jsdoc comments for interface while compiling.

πŸ“ƒ Motivating Example

Example

My .ts file like this:

// test.ts
/**
 * @typedef {Object} ITest - For test
 * @property {string} a
 */
export interface ITest {
  a: string
}

/**
 * @function print - print ITest
 * @params {ITest} d
 */
export function print (d: ITest): void {
  console.log(d.a)
}

while tsc compiling, the .js like this:

// test.js
/**
 * @typedef {Object} ITest - For test
 * @property {string} a
 */
/**
 * @function print - print ITest
 * @params {ITest} d
 */
export function print(d) {
    console.log(d.a);
}

πŸ’» Use Cases

There are two case as I can see.

  • Preverse comments for files.
  • Use jsdoc comments to mark interfaces or types on .ts and generate doc through jsdoc comments on .js
@MartinJohns
Copy link
Contributor

Duplicate of #33207. Used search term: jsdoc interface d.ts

@liukeyi300
Copy link
Author

liukeyi300 commented Jan 29, 2021

Duplicate of #33207. Used search term: jsdoc interface d.ts

Emm, looks similar but not exactly the same thing. #33207 preserve comments in .d.ts finally, but this is, preserve comments in .js.

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants