Skip to content

The generated. d.ts file is missing jsdoc commentsΒ #60404

Closed
@yamiwamiyu

Description

@yamiwamiyu

πŸ” Search Terms

".d.ts","jsdoc"

βœ… Viability Checklist

⭐ Suggestion

When generating .d.ts, if the referenced type is not exported, take one of the following actions:

  • Compile error, indicating that necessary types have not been exported
  • Automatically generate non exported types into .d.ts
  • Maintain the existing implementation and only add jsdoc comments(prefered)

Here is a simple example

  1. I wrote a simple library 1
// myLib/index.d.ts
type FilterString<T> = {
    [K in keyof T as T[K] extends string ? never : K]: T[K];
}

export function define<T>(p: T): FilterString<T>;
  1. Reference library 1 in library 2
import { define } from 'myLib'

export const test = define({
  /** jsdoc 1 */
  a: 5,
  /** jsdoc 2 */
  b: '',
})
  1. Compile library 2 to generate .d.ts
// without jsdoc: type FilterString without export
export declare const test: {
     a: number; // Don't let jsdoc be lost (prefered)
};
// with jsdoc: type FilterString with export
// Alternatively, generate the FilterString type into .d.ts as well
export declare const test: import("myLib").FilterString<{
     /** jsdoc 1 */
    a: number;
    /** jsdoc 2 */
    b: string;
}>;

πŸ“ƒ Motivating Example

When writing libraries, maintain consistent JSDoc annotations between the development and release environments

πŸ’» Use Cases

  1. When writing libraries, maintain consistent JSDoc annotations between the development and release environments
  2. I only discovered that JSDoc was missing when it was released
  3. Manually find the type that has not been exported and add it to the export

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions