Open fengpeng opened 1 year ago
oh, I made a mistake. It's better to start with fromObject
const canonicalFromJson: { [key: string]: { [field: string]: (from: string) => Code } } = {
["google.protobuf.FieldMask"]: {
paths: (from: string) => code`typeof(${from}) === 'string'
? ${from}.split(",").filter(Boolean)
: Array.isArray(${from})
? ${from}
: Array.isArray(${from}?.paths)
? ${from}.paths.map(String)
: []`,
},
};
Hi @fengpeng ! Thanks for digging into the source... Fwiw I can't tell if someone is still wrong, or you figured it out. We have a unit test that shows FieldMask
is working for our current set of tests:
https://github.com/stephenh/ts-proto/blob/main/integration/fieldmask/fieldmask-test.ts#L8
If you've found a bug, could you work on a reproduction, using that test as a starting point?
Thanks!
Hi @fengpeng ! Thanks for digging into the source... Fwiw I can't tell if someone is still wrong, or you figured it out. We have a unit test that shows
FieldMask
is working for our current set of tests:https://github.com/stephenh/ts-proto/blob/main/integration/fieldmask/fieldmask-test.ts#L8
If you've found a bug, could you work on a reproduction, using that test as a starting point?
Thanks!
I have a similar problem.
syntax = "proto3";
import "google/protobuf/field_mask.proto";
message UpdateRequest {
google.protobuf.FieldMask update_mask = 1;
}
then
protoc --plugin=node_modules/.bin/protoc-gen-ts_proto \
-I=./proto/ \
-I=./node_modules/google-proto-files/ \
./proto/test.proto \
--ts_proto_out=src/test/
result
export interface UpdateRequest {
updateMask: string[] | undefined;
}
but it was expected
export interface UpdateRequest {
updateMask: FieldMask | undefined;
}
I want to clarify that the type for FieldMask
was generated successfully, so the tests pass. However, this type is not being applied to the original message
.
export interface FieldMask {
/** The set of field mask paths. */
paths: string[];
}
Hi~ I am using FieldMask to encounter some problems
generated typeScript code:
This request will call its own fromJson:
But FieldMask.fromJSON doesn't support string[]
So, I read the source code, maybe that's the problem?
Thanks!