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

Listing properties on an object type does not work #23

Closed
fabien0102 opened this issue Mar 30, 2017 · 3 comments
Closed

Listing properties on an object type does not work #23

fabien0102 opened this issue Mar 30, 2017 · 3 comments
Labels

Comments

@fabien0102
Copy link

Hello,

I'm trying to generate types.d.ts for gitgraph.js

This is my problem:

/**
 * GitGraph
 * @constructor
 * @param {object} options - GitGraph options
 * @param {string} [options.elementId = "gitGraph"] - Id of the canvas container
 * @param {Template|string|object} [options.template] - Template of the graph
 * @param {string} [options.author = "Sergio Flores <saxo-guy@epic.com>"] - Default author for commits
 * @param {string} [options.mode = (null|"compact")]  - Display mode
 * @param {HTMLElement} [options.canvas] - DOM canvas (ex: document.getElementById("id"))
 * @param {string} [options.orientation = ("vertical-reverse"|"horizontal"|"horizontal-reverse")] - Graph orientation
 * @param {boolean} [options.reverseArrow = false] - Make arrows point to ancestors if true
 * @param {number} [options.initCommitOffsetX = 0] - Add custom offsetX to initial commit.
 * @param {number} [options.initCommitOffsetY = 0] - Add custom offsetY to initial commit.
 * @param {HTMLElement} [options.tooltipContainer = document.body] - HTML Element containing tooltips in compact mode.
 * @this GitGraph
 */
declare class GitGraph {
    constructor(options: any, options.elementId?: string, options.template?: Template | string | any, options.author?: string, options.mode?: string, options.canvas?: any, options.orientation?: string, options.reverseArrow?: boolean, options.initCommitOffsetX?: number, options.initCommitOffsetY?: number, options.tooltipContainer?: any);
}

My options is not correctly parsed, idealy I would like to export an interface of GitGraphOptions but I can't find any jsdoc notations for have the correct output…

If anyone have a simple solution, I take it, otherwise it can be a real issue

Thank you!

@englercj
Copy link
Owner

englercj commented Mar 30, 2017

Good catch, looks like this is broken right now!

As a workaround you can create a type to use as the param type:

/**
 * @typedef {object} GitGraphOptions
 * @property {string} [elementId = "gitGraph"] - Id of the canvas container
 * @property {Template|string|Object} [template] - Template of the graph
 * @property {string} [author = "Sergio Flores <saxo-guy@epic.com>"] - Default author for commits
 * @property {string} [mode = (null|"compact")]  - Display mode
 * @property {HTMLElement} [canvas] - DOM canvas (ex: document.getElementById("id"))
 * @property {string} [orientation = ("vertical-reverse"|"horizontal"|"horizontal-reverse")] - Graph orientation
 * @property {boolean} [reverseArrow = false] - Make arrows point to ancestors if true
 * @property {number} [initCommitOffsetX = 0] - Add custom offsetX to initial commit.
 * @property {number} [initCommitOffsetY = 0] - Add custom offsetY to initial commit.
 * @property {HTMLElement} [tooltipContainer = document.body] - HTML Element containing tooltips in compact mode.
 */
declare type GitGraphOptions = {
    elementId: string;
    template: any | string | any;
    author: string;
    mode: string;
    canvas: any;
    orientation: string;
    reverseArrow: boolean;
    initCommitOffsetX: number;
    initCommitOffsetY: number;
    tooltipContainer: any;
};


/**
 * @param {GitGraphOptions} options - GitGraph options
 */
objParam(options: GitGraphOptions): void;

I'll mark this as a bug and try to get it fixed this weekend.

@englercj englercj added the bug label Mar 30, 2017
@fabien0102
Copy link
Author

Thanks for your answer, but I think we have second issue => your example doesn't deal with optionnals properties ;)

@englercj
Copy link
Owner

This now works in the latest.

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

2 participants