marko-js / language-server

Marko autocomplete, intellisense and editor support.
MIT License
38 stars 8 forks source link

[type-check] `mtc` removes JSDoc property comments during compilation for types/interfaces in `*.marko` components #269

Closed opes closed 2 months ago

opes commented 3 months ago

@marko/type-check@1.1.7

Details

Transpiling interfaces for *.marko files have JSDoc property comments stripped in the transpiled output.

Expected Behavior

Running mtc for an index.marko file with the following interface:

export interface Input {
  /** The text to display as the hero's heading. */
  text: string;
  /** An optional subtitle to display below the heading. */
  subtitle?: string;
  /** The URL to navigate to when the subtitle is clicked. When specified, this changes the subtitle from plain text to a link. */
  subtitleHref?: string;
  /** The URL of the image to display in the hero. */
  imageUrl: string;
  /** The text to be read by screen readers for the image. */
  imageDescription?: string;
}

Should result in the JSDoc property comments being preserved in the transpiled index.d.marko type declaration file:

export interface Input {
  /** The text to display as the hero's heading. */
  text: string;
  /** An optional subtitle to display below the heading. */
  subtitle?: string;
  /** The URL to navigate to when the subtitle is clicked. When specified, this changes the subtitle from plain text to a link. */
  subtitleHref?: string;
  /** The URL of the image to display in the hero. */
  imageUrl: string;
  /** The text to be read by screen readers for the image. */
  imageDescription?: string;
}

Actual Behavior

The transpiled type declaration file index.d.marko has its JSDoc property comments stripped:

export interface Input {
    text: string;
    subtitle?: string;
    subtitleHref?: string;
    imageUrl: string;
    imageDescription?: string;
}

Possible Fix

Switching removeComments from true to false in mtc preserves the comments in the output: https://github.com/marko-js/language-server/blob/99c5f67a66a241139fa7acea56be1de50ba2c64b/packages/type-check/src/run.ts#L354

Possible fixes:

Additional Info ### Your Environment - Environment name and version (e.g. Chrome 39, node.js 5.4): Node.js v20.12.2 - Operating System and version (desktop or mobile): Mac Sonoma 14.5 - Link to your project: https://github.corp.ebay.com/Sonata/ui ### Steps to Reproduce 1. Clone [library-ts](https://github.com/marko-js/examples/tree/master/examples/library-ts) 2. Create a `src/components/demo/index.marko` file that exports the interface in the description above (with JSDoc property comments) 3. Run `npm run build` 4. View the transpiled `dist/components/demo/index.d.marko` output and see how the inline comments were removed ### Stack Trace