futurGH/ts-to-jsdoc

Missing type definition for variable declaration

Closed this issue · 3 comments

Type definition are not keeped for exported variable, for example:

export const type: string = null;

/**
 * Size.
 */
export let size: "small"|"medium" = null;

should be transpiled to :

/** @type {string} */
export const type = null;

/**
 * Size.
 * @type {"small"|"medium"}
 */
export let size = null;

Context: I'm trying to integrate this lib to transpile a svelte component!

Hmm, I seem to be missing something here..

var transpile = require("ts-to-jsdoc")
transpile(`
const groups: Record<string, string[]> = {
  test: ['a', 'b']
} as const;
`);

results in

const groups = {
    test: ['a', 'b']
};

Is there something else I am meant to be setting up?

@WORMSS To avoid cluttering your code with comments on every variable, ts-to-jsdoc will only document top-level variables that have an existing JSDoc-style comment.

var transpile = require("ts-to-jsdoc")
transpile(`
/***/
const groups: Record<string, string[]> = {
  test: ['a', 'b']
} as const;
`);
/** @type {Record<string, string[]>} */
const groups = {
    test: ['a', 'b']
};

Perfect, thank you @futurGH