Skip to content

Commit

Permalink
fix(well-known-types): create non-optional versions of wkt
Browse files Browse the repository at this point in the history
  • Loading branch information
smnbbrv committed Nov 28, 2022
1 parent 635386f commit 154190e
Show file tree
Hide file tree
Showing 13 changed files with 284 additions and 261 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ To create a new message just pass its initial values to the constructor: `new Me
- `toJSON()` - convenience method to be able to pass message to `JSON.stringify(msg)`
- `toProtobufJSON()` - constructs a [protobuf-defined JSON](https://developers.google.com/protocol-buffers/docs/proto3#json). Accepts an optional `GrpcMessagePool` (see `google.protobuf.Any` section) which is required only if the message or some of its descendants embeds `google.protobuf.Any`

#### Int64

JavaScript does not support `int64`, out of the box, that's why all of its kinds are generated as string by default.

You can however override this behavior by passing `JS_NUMBER` or `JS_STRING` option to the appropriate field. Example:

```protobuf
message Message {
int64 bigInt = 1; [jstype = JS_NUMBER]
uint64 bigUint = 2; [jstype = JS_NUMBER]
}
```


### Well-known types

The well-known types are served as a separate package. You can also configure generation of the well-known types together with your proto definitions (like older versions did).
Expand Down Expand Up @@ -459,7 +473,7 @@ That's it. All your requests are served by worker.

## Contributing

- to run tests on Apple m1 chips use `npm ci --target_arch=x64 --no-optional` and `brew install protoc-gen-grpc-web`
- to run tests on Apple m1 chips use `npm ci --no-optional` and `brew install protoc-gen-grpc-web`

## License

Expand Down
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jsdoc": "latest",
"eslint-plugin-prefer-arrow": "latest",
"grpc-tools": "^1.11.1",
"grpc-tools": "^1.11.3",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"jest": "^27.2.5",
Expand Down
17 changes: 9 additions & 8 deletions packages/well-known-types/src/lib/google/protobuf/any.pb.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
//
// THIS IS A GENERATED FILE
// DO NOT MODIFY IT! YOUR CHANGES WILL BE LOST
Expand Down Expand Up @@ -88,8 +89,8 @@ export class Any implements GrpcMessage {
}
}

private _typeUrl?: string;
private _value?: Uint8Array;
private _typeUrl: string;
private _value: Uint8Array;

/**
* Message constructor. Initializes the properties and applies default Protobuf values if necessary
Expand All @@ -101,16 +102,16 @@ export class Any implements GrpcMessage {
this.value = _value.value;
Any.refineValues(this);
}
get typeUrl(): string | undefined {
get typeUrl(): string {
return this._typeUrl;
}
set typeUrl(value: string | undefined) {
set typeUrl(value: string) {
this._typeUrl = value;
}
get value(): Uint8Array | undefined {
get value(): Uint8Array {
return this._value;
}
set value(value: Uint8Array | undefined) {
set value(value: Uint8Array) {
this._value = value;
}

Expand Down Expand Up @@ -253,8 +254,8 @@ export module Any {
* Standard JavaScript object representation for Any
*/
export interface AsObject {
typeUrl?: string;
value?: Uint8Array;
typeUrl: string;
value: Uint8Array;
}

/**
Expand Down

0 comments on commit 154190e

Please sign in to comment.