protobufjs / protobuf.js

Protocol Buffers for JavaScript & TypeScript.
Other
9.91k stars 1.41k forks source link

Typescript declarations are missing interfaces #1965

Open GithubUser8080 opened 9 months ago

GithubUser8080 commented 9 months ago

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

gburatti commented 9 months ago

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

zargold commented 6 months ago

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.

a-gorbunov commented 4 months ago

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.