-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Using the following protobuf definition:
message HistoryResponse {
enum Error {
ERROR_NONE_UNSPECIFIED = 0;
ERROR_INVALID_CURSOR = 1;
}
optional Error error = 4;
}
The TypeScript generated has the following typescript error:
src/proto/store_v2beta3.ts:364:21 - error TS2351: This expression is not constructable.
Type 'typeof Error' has no construct signatures.
364 throw new Error('Protocol error: required field "messages" was not found in object')
~~~~~
src/proto/store_v2beta4.ts:373:21 - error TS2351: This expression is not constructable.
Type 'typeof Error' has no construct signatures.
373 throw new Error('Protocol error: required field "messages" was not found in object')
This is because typescript thinks that Error refers to the enum and not to the native type Error:
export namespace HistoryResponse {
export enum Error {
ERROR_NONE_UNSPECIFIED = 'ERROR_NONE_UNSPECIFIED',
ERROR_INVALID_CURSOR = 'ERROR_INVALID_CURSOR'
}
enum __ErrorValues {
ERROR_NONE_UNSPECIFIED = 0,
ERROR_INVALID_CURSOR = 1
}
export namespace Error {
export const codec = () => {
return enumeration<Error>(__ErrorValues)
}
}
let _codec: Codec<HistoryResponse>
export const codec = (): Codec<HistoryResponse> => {
if (_codec == null) {
_codec = message<HistoryResponse>((obj, writer, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
}
if (obj.messages != null) {
for (const value of obj.messages) {
writer.uint32(18)
WakuMessage.codec().encode(value, writer)
}
} else {
throw new Error('Protocol error: required field "messages" was not found in object')
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels