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

Typescript declarations are missing interfaces

Open GithubUser8080 opened this issue 2 years ago • 4 comments

protobuf.js version: protobufjs-cli 1.1.2

When generating static code from a proto3 file, and subsequently generating the typescript definitions, each message ends up as

export class MyMessage implements IMyMessage{
...
}

The interface IMyMessage is not declared anywhere

GithubUser8080 avatar Jan 26 '24 08:01 GithubUser8080

@GithubUser8080 I had the same issue. I fixed it by adding a "package" into my proto files. Hope this helps

gburatti avatar Feb 05 '24 10:02 gburatti

Thank you @gburatti this also caused an issue where I could do:

sender: (IPerson|null); // IPerson was coming up unresolved *any*
// which allowed you to do:
MyMessage.sender = 'someName'; 

(vs MyMessage.sender = { name: 'someName' })

There is another solution for this: we could set person: Person instead of IPerson within d.ts but who knows when that'll happen.

zargold avatar May 08 '24 20:05 zargold

Same issue. Found interface for first file, but second file had enum declaration. After enum there were no more interfaces. If I remove enum, interface appears.

a-gorbunov avatar Jun 18 '24 12:06 a-gorbunov