Skip to content

Commit

Permalink
Update info about proto2 support for #35
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed May 13, 2021
1 parent 1a7a630 commit a56901b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,28 +704,30 @@ interface Proto3Optionals {
## proto2 support

`protobuf-ts` has partial support for the older proto2 syntax. The support
is sufficient to write protoc plugins. When a proto2 messages passes through
`protobuf-ts`, no data is lost, but there are several limitations in the
generated code:
is just sufficient to write protoc plugins.

1. Extensions
Extensions (see [language guide](https://developers.google.com/protocol-buffers/docs/proto#extensions))
are basically ignored. No code will be generated.
Note the following restrictions:

1. Extensions (see [language guide](https://developers.google.com/protocol-buffers/docs/proto#extensions))
are ignored. No code will be generated.

Extension fields can be read like unknown fields. See [unknown field handling](#unknown-field-handling).

2. Default field values are unsupported
2. Groups (see [language guide](https://developers.google.com/protocol-buffers/docs/proto#groups))
are ignored by the plugin.
No code will be generated. Group fields are treated as unknown fields,
see [unknown field handling](#unknown-field-handling).

2. Default field values are not supported
A field with the `optional` label and a default option will have the type
`myField?: bool` and default value `undefined`.

If the field has the `required` label, the type will be `myField: bool`
with the default value `false`.
3. `required` label is not supported
If a field has the `required` label, the type will be `myField: bool`
with the default value `false`.

3. Enums without a 0 value

`protobuf-ts` will add the `UNSPECIFIED$ = 0` enum value if no
3. Enums without a `0` value
The plugin will add the `UNSPECIFIED$ = 0` enum value if no
value for 0 is defined.


Expand Down

0 comments on commit a56901b

Please sign in to comment.