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

wrong types - module:modulename/typename turned into just module #89

Open
greggman opened this issue Jul 11, 2019 · 4 comments
Open

wrong types - module:modulename/typename turned into just module #89

greggman opened this issue Jul 11, 2019 · 4 comments
Labels

Comments

@greggman
Copy link

greggman commented Jul 11, 2019

I have jsdocs that look like

    /**
     * Creates a framebuffer and attachments.
     *
     * @param {WebGLRenderingContext} gl the WebGLRenderingContext
     * @param {module:twgl.AttachmentOptions[]} [attachments] which attachments to create.
     * @param {number} [width] the width for the attachments. 
     * @param {number} [height] the height for the attachments.r
     * @return {module:twgl.FramebufferInfo} the framebuffer and attachments.
     * @memberOf module:twgl/framebuffers
     */

tsd-jsdoc 2.1.3 generated the correct (or at least useful for me) signature

    function createFramebufferInfo(
        gl: WebGLRenderingContext,
        attachments?: module:twgl.AttachmentOptions[],
        width?: number,
        height?: number): module:twgl.FramebufferInfo;

tsd-jsdoc 2.2.0+ generates an incorrect signature

    function createFramebufferInfo(
        gl: WebGLRenderingContext,
        attachments?: module[],
        width?: number,
        height?: number): module;
@greggman greggman changed the title wrong types - model:typename turned into just module wrong types - module:modulename/typename turned into just module Jul 11, 2019
@englercj
Copy link
Owner

attachments?: module:twgl.AttachmentOptions[],

I don't think that is valid Typescript, is it? I definitely get errors on the playground trying to use it.

I agree the new one is incorrect as well. Assuming twgl is a module you have somewhere else in code I'd expect the output to just be twgl.FramebufferInfo. PR welcome!

@greggman
Copy link
Author

Yea, I agree the old output was wrong but I had some post process to fix it. Now the output is unusable though.

@greggman
Copy link
Author

Well look into PR if someone doesn't beat me to it. For now just moved my deps back to 2.1.2

@englercj englercj added the bug label Jan 17, 2020
@bkuster
Copy link

bkuster commented Oct 29, 2020

So, I've been having the same issue and decided to try changing modules to imports, e.g. something like this:

if (/^module:/.test(name)) {
  const [mod, imp] = name.replace(/^module:/, '').split('~');
  return ts.createImportTypeNode(ts.createStringLiteral(mod), ts.createTypeReferenceNode(imp || 'default'));
}

This turns:

/**
 * @typedef {Object} Options
 * @property {module:ol/coordinate~Coordinate} coords
 * @property {module:cesium~CesiumTerrainProvider} terrain
 */

into

declare type Options = {
    coords: import("ol/coordinate").Coordinate;
    terrain: import("cesium").CesiumTerrainProvider;
};

Thoughts?

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

No branches or pull requests

3 participants