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

TS definitions missing for Root.fromDescriptor and Root.toDescriptor #1499

Open
tatemz opened this issue Oct 15, 2020 · 1 comment
Open

TS definitions missing for Root.fromDescriptor and Root.toDescriptor #1499

tatemz opened this issue Oct 15, 2020 · 1 comment

Comments

@tatemz
Copy link

tatemz commented Oct 15, 2020

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;
    }
}
@ThePlenkov
Copy link
Contributor

just got into the same issue working on creating a test case for #1784

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

2 participants