protobuf.js
protobuf.js copied to clipboard
TS definitions missing for Root.fromDescriptor and Root.toDescriptor
protobuf.js version: 6.10.1
After importing protobufjs/ext/descriptor
, I should be able to call the fromDescriptor
and toDescriptor
methods without Typescript complaining
import { Message, Root } from 'protobufjs';
import * as descriptor from "protobufjs/ext/descriptor";
const root = new Root();
root.fromDescriptor({} as Message<descriptor.IFileDescriptorSet>);
Property 'fromDescriptor' does not exist on type 'typeof Root'.ts
Workaround (inspired by proto-loader
):
declare module 'protobufjs' {
interface Root {
toDescriptor(protoVersion: string): Protobuf.Message<descriptor.IFileDescriptorSet> & descriptor.IFileDescriptorSet;
fromDescriptor(descriptor: IFileDescriptorSet | $protobuf.Reader | Uint8Array): Root;
}
}
just got into the same issue working on creating a test case for #1784