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

generated .d.ts syntax error #1306

Open
wildfire810 opened this issue Oct 3, 2019 · 5 comments
Open

generated .d.ts syntax error #1306

wildfire810 opened this issue Oct 3, 2019 · 5 comments

Comments

@wildfire810
Copy link

protobuf.js version: 6.8.8

D:\Project\skybox\Engine\Monju\Protocol\ProtoBuf\Protocol.d.ts
Error:Error:line (74)TS2693: 'string' only refers to a type, but is being used as a value here.
Error:Error:line (74)TS2531: Object is possibly 'null'.
Error:Error:line (81)TS2304: Cannot find name 'fromObject'.
Error:Error:line (81)TS2552: Cannot find name 'object'. Did you mean 'Object'?
Error:Error:line (89)TS2552: Cannot find name 'toObject'. Did you mean 'Object'?
Error:Error:line (89)TS2552: Cannot find name 'message'. Did you mean 'Message'?
Error:Error:line (89)TS2552: Cannot find name 'options'. Did you mean 'Option'?
Error:Error:line (89)TS2339: Property 'IConversionOptions' does not exist on type 'typeof import("D:/Project/skybox/Engine/Monju/node_modules/protobufjs/index")'.
Error:Error:line (95)TS2552: Cannot find name 'toJSON'. Did you mean 'JSON'?
Error:Error:line (164)TS2693: 'string' only refers to a type, but is being used as a value here.
Error:Error:line (164)TS2531: Object is possibly 'null'.
Error:Error:line (171)TS2304: Cannot find name 'fromObject'.
Error:Error:line (171)TS2552: Cannot find name 'object'. Did you mean 'Object'?
Error:Error:line (179)TS2552: Cannot find name 'toObject'. Did you mean 'Object'?
Error:Error:line (179)TS2552: Cannot find name 'message'. Did you mean 'Message'?
Error:Error:line (179)TS2304: Cannot find name 'options'.
Error:Error:line (179)TS2339: Property 'IConversionOptions' does not exist on type 'typeof import("D:/Project/skybox/Engine/Monju/node_modules/protobufjs/index")'.
Error:Error:line (185)TS2304: Cannot find name 'toJSON'.
Error:Error:line (254)TS2693: 'string' only refers to a type, but is being used as a value here.
Error:Error:line (254)TS2531: Object is possibly 'null'.
Error:Error:line (261)TS2304: Cannot find name 'fromObject'.
Error:Error:line (261)TS2304: Cannot find name 'object'.
Error:Error:line (269)TS2304: Cannot find name 'toObject'.
Error:Error:line (269)TS2304: Cannot find name 'message'.
Error:Error:line (269)TS2304: Cannot find name 'options'.
Error:Error:line (269)TS2339: Property 'IConversionOptions' does not exist on type 'typeof import("D:/Project/skybox/Engine/Monju/node_modules/protobufjs/index")'.
Error:Error:line (275)TS2304: Cannot find name 'toJSON'.
Error:Error:line (74)TS1005: ',' expected.
Error:Error:line (74)TS1003: Identifier expected.
Error:Error:line (74)TS1005: ',' expected.
Error:Error:line (74)TS1109: Expression expected.
Error:Error:line (74)TS1128: Declaration or statement expected.
Error:Error:line (81)TS1128: Declaration or statement expected.
Error:Error:line (81)TS1128: Declaration or statement expected.
Error:Error:line (81)TS1005: ',' expected.
Error:Error:line (81)TS1003: Identifier expected.
Error:Error:line (81)TS1005: '(' expected.
Error:Error:line (81)TS1005: ',' expected.
Error:Error:line (81)TS1005: ')' expected.
Error:Error:line (89)TS1128: Declaration or statement expected.
Error:Error:line (89)TS1128: Declaration or statement expected.
Error:Error:line (89)TS1005: ',' expected.
Error:Error:line (89)TS1109: Expression expected.
Error:Error:line (89)TS1005: ';' expected.
Error:Error:line (89)TS1003: Identifier expected.
Error:Error:line (89)TS1005: '(' expected.
Error:Error:line (95)TS1128: Declaration or statement expected.
Error:Error:line (95)TS1005: ';' expected.
Error:Error:line (95)TS1003: Identifier expected.
Error:Error:line (95)TS1005: '(' expected.
Error:Error:line (96)TS1128: Declaration or statement expected.
Error:Error:line (164)TS1005: ',' expected.
Error:Error:line (164)TS1003: Identifier expected.
Error:Error:line (164)TS1005: ',' expected.
Error:Error:line (164)TS1109: Expression expected.
Error:Error:line (164)TS1128: Declaration or statement expected.
Error:Error:line (171)TS1128: Declaration or statement expected.
Error:Error:line (171)TS1128: Declaration or statement expected.
Error:Error:line (171)TS1005: ',' expected.
Error:Error:line (171)TS1003: Identifier expected.
Error:Error:line (171)TS1005: '(' expected.
Error:Error:line (171)TS1005: ',' expected.
Error:Error:line (171)TS1005: ')' expected.
Error:Error:line (179)TS1128: Declaration or statement expected.
Error:Error:line (179)TS1128: Declaration or statement expected.
Error:Error:line (179)TS1005: ',' expected.
Error:Error:line (179)TS1109: Expression expected.
Error:Error:line (179)TS1005: ';' expected.
Error:Error:line (179)TS1003: Identifier expected.
Error:Error:line (179)TS1005: '(' expected.
Error:Error:line (185)TS1128: Declaration or statement expected.
Error:Error:line (185)TS1005: ';' expected.
Error:Error:line (185)TS1003: Identifier expected.
Error:Error:line (185)TS1005: '(' expected.
Error:Error:line (186)TS1128: Declaration or statement expected.
Error:Error:line (254)TS1005: ',' expected.
Error:Error:line (254)TS1003: Identifier expected.
Error:Error:line (254)TS1005: ',' expected.
Error:Error:line (254)TS1109: Expression expected.
Error:Error:line (254)TS1128: Declaration or statement expected.
Error:Error:line (261)TS1128: Declaration or statement expected.
Error:Error:line (261)TS1128: Declaration or statement expected.
Error:Error:line (261)TS1005: ',' expected.
Error:Error:line (261)TS1003: Identifier expected.
Error:Error:line (261)TS1005: '(' expected.
Error:Error:line (261)TS1005: ',' expected.
Error:Error:line (261)TS1005: ')' expected.
Error:Error:line (269)TS1128: Declaration or statement expected.
Error:Error:line (269)TS1128: Declaration or statement expected.
Error:Error:line (269)TS1005: ',' expected.
Error:Error:line (269)TS1109: Expression expected.
Error:Error:line (269)TS1005: ';' expected.
Error:Error:line (269)TS1003: Identifier expected.
Error:Error:line (269)TS1005: '(' expected.
Error:Error:line (275)TS1128: Declaration or statement expected.
Error:Error:line (275)TS1005: ';' expected.
Error:Error:line (275)TS1003: Identifier expected.
Error:Error:line (275)TS1005: '(' expected.
Error:Error:line (276)TS1128: Declaration or statement expected.

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

    /**
     * Creates a Message message from a plain object. Also converts values to their respective internal types.
     * @param object Plain object
     * @returns Message
     */
    public static fromObject(object: [ 'object' ].<string, any>): Message;

    /**
     * Creates a plain object from a Message message. Also converts values to other types if specified.
     * @param message Message
     * @param [options] Conversion options
     * @returns Plain object
     */
    public static toObject(message: Message, options?: $protobuf.IConversionOptions): [ 'object' ].<string, any>;

    /**
     * Converts this Message to JSON.
     * @returns JSON object
     */
    public toJSON(): [ 'object' ].<string, any>;
@buu700
Copy link

buu700 commented Nov 4, 2019

I can't imagine why, but it looks like this only happens with Node 12.x (current LTS). Downgrading to 10.x causes it to emit the correct { [k: string]: any } instead of [ 'object' ].<string, any>.

That said, as far as I can tell, replacing all instances of [ 'object' ]. with Record and [ 'Array' ]. with Array seems to be an effective workaround.

@mrozekma
Copy link

It looks like this is caused by jsdoc/jsdoc#1643; the behavior of util.format changed in Node 12. This is fixed in jsdoc 3.6.1, so upgrading to that or later fixes protobufjs.

@wildfire810
Copy link
Author

It looks like this is caused by jsdoc/jsdoc#1643; the behavior of util.format changed in Node 12. This is fixed in jsdoc 3.6.1, so upgrading to that or later fixes protobufjs.

thanks a lot a lot a lot very very much!

@w4454962
Copy link

w4454962 commented Jan 3, 2020

npm install protobufjs

This bug also exists after installation
This latest version of the package is 6.88. Please update the installation package

@wildfire810
Copy link
Author

wildfire810 commented Jan 4, 2020

My way
npm install protobuf-typescript -g
pbjs --target static-module ...
pbts --out ...

https://www.npmjs.com/package/protobuf-typescript
https://github.com/wildfire810/protobuf.js
Forked from protobufjs/protobuf.js

buu700 added a commit to buu700/protobuf.js that referenced this issue Jul 19, 2022
buu700 added a commit to buu700/protobuf.js that referenced this issue Jul 19, 2022
this can be reverted after jsdoc is upgraded, which is blocked on jsdoc/jsdoc#1644
buu700 added a commit to buu700/protobuf.js that referenced this issue Jul 19, 2022
this can be reverted after jsdoc is upgraded, which is blocked on jsdoc/jsdoc#1644
buu700 added a commit to buu700/protobuf.js that referenced this issue Aug 4, 2022
this can be reverted after jsdoc is upgraded, which is blocked on jsdoc/jsdoc#1644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants