protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

Can't generate TypeScript definitions if message starts with "true"

Open j2ghz opened this issue 3 years ago • 0 comments

protobuf.js version: 6.11.2

Trying to generate TypeScript definitions for this minimal reproducible example fails:

syntax = "proto3";
message trueWireless {}

Running this succeeds:

node .\node_modules\protobufjs\bin\pbjs -o sample.js -w es6 -t static-module  .\sample.proto

But this fails:

node .\node_modules\protobufjs\bin\pbts -o sample.d.ts .\sample.js

Error message:

ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 33 with tag title "returns" and text "{trueWireless} trueWireless instance": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 41 with tag title "returns" and text "{trueWireless} trueWireless instance": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 73 with tag title "returns" and text "{trueWireless} trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 84 with tag title "returns" and text "{trueWireless} trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 99 with tag title "returns" and text "{trueWireless} trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 109 with tag title "returns" and text "{trueWireless} trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 129 with tag title "returns" and text "{trueWireless} trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 137 with tag title "returns" and text "{trueWireless} trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 143 with tag title "param" and text "{trueWireless} message trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
ERROR: Unable to parse a tag's type expression for source file C:\<project>\sample.js in line 152 with tag title "param" and text "{trueWireless} message trueWireless": Invalid type expression "trueWireless": Expected "!", "=", "?", "[]", "|", or end of input but "W" found.
C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:345
            var path = param.name.split(/\./g);
                                  ^

TypeError: Cannot read property 'split' of undefined
    at C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:345:35
    at Array.forEach (<anonymous>)
    at writeFunctionSignature (C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:344:24)
    at handleFunction (C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:669:5)
    at handleElement (C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:451:13)
    at C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:559:9
    at Array.forEach (<anonymous>)
    at handleClass (C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:554:28)
    at handleElement (C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:435:9)
    at C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:83:13
    at Array.forEach (<anonymous>)
    at Object.publish (C:\<project>\node_modules\protobufjs\cli\lib\tsd-jsdoc\publish.js:82:34)
    at Object.module.exports.cli.generateDocs (C:\<project>\node_modules\protobufjs\cli\node_modules\jsdoc\cli.js:441:39)
    at Object.module.exports.cli.processParseResults (C:\<project>\node_modules\protobufjs\cli\node_modules\jsdoc\cli.js:392:24)
    at module.exports.cli.main (C:\<project>\node_modules\protobufjs\cli\node_modules\jsdoc\cli.js:235:18)
    at Object.module.exports.cli.runCommand (C:\<project>\node_modules\protobufjs\cli\node_modules\jsdoc\cli.js:186:9)
/** Properties of a trueWireless. */
export interface ItrueWireless {
}

/** Represents a trueWireless. */
export class trueWireless implements ItrueWireless {

    /**
     * Constructs a new trueWireless.
     * @param [properties] Properties to set
     */
    constructor(properties?: ItrueWireless);

    /**
     * Creates a new trueWireless instance using the specified properties.
     * @param [properties] Properties to set
     * @returns trueWireless instance
     */
    public static create(properties?: ItrueWireless): any;

    /**
     * Encodes the specified trueWireless message. Does not implicitly {@link trueWireless.verify|verify} messages.
     * @param message trueWireless message or plain object to encode
     * @param [writer] Writer to encode to
     * @returns Writer
     */
    public static encode(message: ItrueWireless, writer?: $protobuf.Writer): $protobuf.Writer;

    /**
     * Encodes the specified trueWireless message, length delimited. Does not implicitly {@link trueWireless.verify|verify} messages.
     * @param message trueWireless message or plain object to encode
     * @param [writer] Writer to encode to
     * @returns Writer
     */
    public static encodeDelimited(message: ItrueWireless, writer?: $protobuf.Writer): $protobuf.Writer;

    /**
     * Decodes a trueWireless message from the specified reader or buffer.
     * @param reader Reader or buffer to decode from
     * @param [length] Message length if known beforehand
     * @returns trueWireless
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): any;

    /**
     * Decodes a trueWireless message from the specified reader or buffer, length delimited.
     * @param reader Reader or buffer to decode from
     * @returns trueWireless
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): any;

    /**
     * Verifies a trueWireless message.
     * @param message Plain object to verify
     * @returns `null` if valid, otherwise the reason why it is not
     */
    public static verify(message: { [k: string]: any }): (string|null);

    /**
     * Creates a trueWireless message from a plain object. Also converts values to their respective internal types.
     * @param object Plain object
     * @returns trueWireless
     */
    public static fromObject(object: { [k: string]: any }): any;

    /**
     * Creates a plain object from a trueWireless message. Also converts values to other types if specified.
     * @param message trueWireless
     * @param [options] Conversion options
     * @returns Plain object
     */
    public static toObject(C:\<project>\node_modules\protobufjs\cli\pbts.js:133
                throw err;
                ^

Error: code 1
    at ChildProcess.<anonymous> (C:\<project>\node_modules\protobufjs\cli\pbts.js:130:27)
    at ChildProcess.emit (events.js:412:35)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)

j2ghz avatar Mar 29 '22 11:03 j2ghz