timostamm / protobuf-ts

Protobuf and RPC for TypeScript
Apache License 2.0
1.1k stars 131 forks source link

Invalid typescript in descriptor.ts #634

Closed cirvladimir closed 8 months ago

cirvladimir commented 8 months ago

I'm generating proto for a file that uses descriptor.proto, which causes google/descriptor.ts to be generated. However, that file contains invalid typescript, which results in compilation issues.

There are about 10-20 errors in this fashion:

static fromObject(data: {
    file?: ReturnType<typeof FileDescriptorProto.prototype.toObject>[];
}): FileDescriptorSet {
    const message = new FileDescriptorSet({
        file: data.file.map(item => FileDescriptorProto.fromObject(item))
    });
    return message;
}

Note how the file field is nullable, however there is no null check in the function.

jcready commented 8 months ago

This library/code-generator doesn't use .fromObject() or .toObject() so I'm guessing you've filed an issue with the wrong repo.

timostamm commented 8 months ago

You can identify code generated by us by this line at the top of the file:

// @generated by protobuf-ts ...