futurGH/ts-to-jsdoc

Bug: Invalid comma between two @typedef's

Closed this issue · 1 comments

Version: 1.2.0

I have multiple interfaces and functions to export from one file.

As I do that I find that the generated .js file has lines that contain invalid comma _betweeen two @typedefs.

A minimal example:

Input: tests.ts

export interface One {
    foo1: string;
    bar1: string;
    baz1: number;
}

export interface Two {
    foo2: string;
    bar2: string;
    baz2: string;
}

export function test(one: One, two: Two) {
    console.log(
        one.foo1 + two.foo2,
        one.bar1 + two.bar2,
        one.baz1 + two.baz2
    );
}

Use these commands to generate a test.js output file:

#!/bin/bash

CURDIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"

INPUT_FILE="$CURDIR/test.ts"
OUTPUT_DIR="$CURDIR/output"

npx ts-to-jsdoc -f "$INPUT_FILE" -o "$OUTPUT_DIR"

What I got as output:

Output: test.js

/** @param {One} one
 * @param {Two} two
 * @returns {void}
 */
export function test(one, two) {
    console.log(one.foo1 + two.foo2, one.bar1 + two.bar2, one.baz1 + two.baz2);
}




/** @typedef {Object} One
 * @property {string} foo1
 * @property {string} bar1
 * @property {number} baz1 
 */,/** @typedef {Object} Two
 * @property {string} foo2
 * @property {string} bar2
 * @property {string} baz2 
 */

You can see that between the two @typedefs, a weird comma shows up, which is invalid JavaScript syntax.

Strange, thanks for filing an issue! Will look into this as soon as I can, which might not be very soon unfortunately.