Skip to content

Commit

Permalink
Add support for BoolValue
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilVerma committed Mar 21, 2024
1 parent fa05ee7 commit f551a24
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/basic/basic.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import "google/protobuf/empty.proto";
import "google/protobuf/descriptor.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/any.proto";
import "google/protobuf/wrappers.proto";

package basic;

Expand Down Expand Up @@ -83,6 +84,7 @@ message OptionalFields {
repeated Nested a_repeated_message = 4;
repeated string a_repeated_string = 5;
optional google.protobuf.Any anyValue = 13;
optional google.protobuf.BoolValue boolValue = 14;
}

message HasExtensions {
Expand Down
1 change: 1 addition & 0 deletions examples/basic/protocol/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface OptionalFields {
aRepeatedMessage?: OptionalFields_Nested[];
aRepeatedString?: string[];
anyValue?: unknown;
boolValue?: boolean;
}

export interface HasExtensions {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ollion/protobufjs-typescript-gen",
"version": "2.0.6",
"version": "2.0.7",
"main": "dist/index.js",
"author": "Nikhil Verma <nikhilgotmail@gmail.com>",
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ function getServiceTypeInfo(
case '.google.protobuf.ListValue':
return { code: 'any[]', import: null };

case '.google.protobuf.BoolValue':
return { code: 'boolean', import: null };

case '.google.protobuf.Struct':
return { code: 'Record<string, any>', import: null };

Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getCommentBlock(object: ReflectionObject) {
export function getImport(
object: ReflectionObject,
targetObject: ReflectionObject | null,
options: ProtoGenOptions
options: ProtoGenOptions,
) {
if (!targetObject) {
return null;
Expand Down Expand Up @@ -126,6 +126,7 @@ export function fieldToTypescriptType(field: FieldBase, options: ProtoGenOptions
break;

case 'bool':
case 'google.protobuf.BoolValue':
type = 'boolean';
break;

Expand Down

0 comments on commit f551a24

Please sign in to comment.