Skip to content

Commit

Permalink
Revert "Support proto2 default values and field presence (#716)"
Browse files Browse the repository at this point in the history
This reverts commit 0b0f084.
  • Loading branch information
timostamm committed Feb 20, 2024
1 parent 4dd82a2 commit b63f59e
Show file tree
Hide file tree
Showing 64 changed files with 3,908 additions and 6,282 deletions.
4 changes: 2 additions & 2 deletions docs/generated_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ foo = "";
bar?: string;
```

Note that all scalar fields have a zero-value in proto3 syntax, unless they are
marked as `optional`. Protobuf types map to ECMAScript types as follows:
Note that all scalar fields have an intrinsic default value in proto3 syntax, unless they are marked
as `optional`. Protobuf types map to ECMAScript types as follows:

| protobuf type | ECMAScript type | default value |
|---------------|-----------------|----------------------|
Expand Down
12 changes: 9 additions & 3 deletions docs/runtime_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ You can create an instance with the `new` keyword:
const user = new User();
```


For convenience, constructors accept an initializer object. All fields in the
initializer object are optional, and if not provided, the field keeps its
default value.
initializer object are optional, and if not provided, the default value for the
field is used.

```typescript
const user = new User({
Expand Down Expand Up @@ -1162,7 +1163,12 @@ let plain: PlainMessage<User> = {
};
```
You can convert any message to a plain message with the function [`toPlainMessage`][src-toPlainMessage].
As such, [`PlainMessage<T>`][src-PlainMessage] can be a great fit to use
throughout your business logic, if that business logic is never concerned with
serialization, and does not need `instanceof`.
Note that any `T` (assuming `T` extends `Message`) is assignable to a variable
of type [`PlainMessage<T>`][src-PlainMessage].
### AnyMessage
Expand Down
2 changes: 1 addition & 1 deletion packages/protobuf-bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ server would usually do.

| code generator | bundle size | minified | compressed |
|---------------------|------------------------:|-----------------------:|-------------------:|
| protobuf-es | 98,372 b | 41,985 b | 10,933 b |
| protobuf-es | 97,378 b | 41,628 b | 10,766 b |
| protobuf-javascript | 394,384 b | 288,654 b | 45,122 b |

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

Loading

0 comments on commit b63f59e

Please sign in to comment.