ts-proto 1.167.9 → 1.168.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.markdown +1 -1
- package/build/main.js +1 -1
- package/package.json +1 -1
package/README.markdown
CHANGED
|
@@ -432,7 +432,7 @@ Generated code will be placed in the Gradle build directory.
|
|
|
432
432
|
|
|
433
433
|
- With `--ts_proto_opt=outputSchema=true`, meta typings will be generated that can later be used in other code generators.
|
|
434
434
|
|
|
435
|
-
- With `--ts_proto_opt=outputTypeAnnotations=true`, each message will be given a `$type` field containing its fully-qualified name. You can use `--ts_proto_opt=outputTypeAnnotations=static-only` to omit it from the `interface` declaration.
|
|
435
|
+
- With `--ts_proto_opt=outputTypeAnnotations=true`, each message will be given a `$type` field containing its fully-qualified name. You can use `--ts_proto_opt=outputTypeAnnotations=static-only` to omit it from the `interface` declaration, or `--ts_proto_opt=outputTypeAnnotations=optional` to make it an optional property on the `interface` definition. The latter option may be useful if you want to use the `$type` field for runtime type checking on responses from a server.
|
|
436
436
|
|
|
437
437
|
- With `--ts_proto_opt=outputTypeRegistry=true`, the type registry will be generated that can be used to resolve message types by fully-qualified name. Also, each message will be given a `$type` field containing its fully-qualified name.
|
|
438
438
|
|
package/build/main.js
CHANGED
|
@@ -678,7 +678,7 @@ function generateInterfaceDeclaration(ctx, fullName, messageDesc, sourceInfo, fu
|
|
|
678
678
|
// interface name should be defined to avoid import collisions
|
|
679
679
|
chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(fullName)} {`);
|
|
680
680
|
if ((0, options_1.addTypeToMessages)(options)) {
|
|
681
|
-
chunks.push((0, ts_poet_1.code) `$type: '${fullTypeName}',`);
|
|
681
|
+
chunks.push((0, ts_poet_1.code) `$type${options.outputTypeAnnotations === "optional" ? "?" : ""}: '${fullTypeName}',`);
|
|
682
682
|
}
|
|
683
683
|
// When oneof=unions, we generate a single property with an ADT per `oneof` clause.
|
|
684
684
|
const processedOneofs = new Set();
|