Skip to content
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

Conversion of typescript declarations at beginning of files incorrectly parses. #224

Open
DevAndrewGeorge opened this issue Aug 29, 2022 · 0 comments

Comments

@DevAndrewGeorge
Copy link

Consider the following typescript file before it is parsed by this tool:

// example.ts
/** @module example */

/** */
export type HelloWorld = {
  hello: string;
  world: string;
}

It should be converted in such a way that it is equivalent to the following javascript file:

// example.js - expected
/** @module example */

/**
 * @typedef {object} HelloWorld
 * @property {string} hello
 * @property {string} world
 */

However, it incorrectly merges the module tag into the generated typedef tag:

// example.js - actual
/** @module example
 * @typedef {object} HelloWorld
 * @property {string} hello
 * @property {string} world
 */

I can only theorize the particulars, but adding a dummy semicolon after the module tag works as a valid workaround:

// example-workaround.ts
/** @module example */
;

/** */
export type HelloWorld = {
  hello: string;
  world: string;
}

And even with the workaround, the HelloWorld typedef becomes a member of global scope, and only by explicitly providing the @memberof module:example tag does it become a member of the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant