ts-proto 1.174.0 → 1.175.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 CHANGED
@@ -432,6 +432,8 @@ Generated code will be placed in the Gradle build directory.
432
432
 
433
433
  - With `--ts_proto_opt=useMongoObjectId=true`, fields of a type called ObjectId where the message is constructed to have on field called value that is a string will be mapped to type `mongodb.ObjectId` in the generated types. This will require your project to install the mongodb npm package. See [ObjectId](#objectid) for more details.
434
434
 
435
+ - With `--ts_proto_opt=annotateFilesWithVersion=false`, the generated files will not contain the versions of `protoc` and `ts-proto` used to generate the file. This option is normally set to `true`, such that files list the versions used.
436
+
435
437
  - With `--ts_proto_opt=outputSchema=true`, meta typings will be generated that can later be used in other code generators.
436
438
 
437
439
  - 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.
@@ -787,9 +789,7 @@ The following helper types may make it easier to work with the types generated f
787
789
  type OneOfCases<T> = T extends { $case: infer U extends string } ? U : never;
788
790
 
789
791
  /** Extracts a union of all the value types from a oneOf field */
790
- type OneOfValues<T> = T extends { $case: infer U extends string; [key: string]: unknown }
791
- ? T[U]
792
- : never;
792
+ type OneOfValues<T> = T extends { $case: infer U extends string; [key: string]: unknown } ? T[U] : never;
793
793
 
794
794
  /** Extracts the specific type of a oneOf case based on its field name */
795
795
  type OneOfCase<T, K extends OneOfCases<T>> = T extends {
@@ -95,6 +95,7 @@ export type Options = {
95
95
  disableProto2Optionals: boolean;
96
96
  disableProto2DefaultValues: boolean;
97
97
  useNullAsOptional: boolean;
98
+ annotateFilesWithVersion: boolean;
98
99
  };
99
100
  export declare function defaultOptions(): Options;
100
101
  export declare function optionsFromParameter(parameter: string | undefined): Options;
package/build/options.js CHANGED
@@ -102,6 +102,7 @@ function defaultOptions() {
102
102
  disableProto2Optionals: false,
103
103
  disableProto2DefaultValues: false,
104
104
  useNullAsOptional: false,
105
+ annotateFilesWithVersion: true,
105
106
  };
106
107
  }
107
108
  exports.defaultOptions = defaultOptions;
@@ -252,10 +253,12 @@ function getTsPoetOpts(options, tsProtoVersion, protocVersion, fileName) {
252
253
  // Comment block at the top of every source file, since these comments require specific
253
254
  // syntax incompatible with ts-poet, we will hard-code the string and prepend to the
254
255
  // generator output.
255
- prefix: `// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
256
+ prefix: `// Code generated by protoc-gen-ts_proto. DO NOT EDIT.${options.annotateFilesWithVersion
257
+ ? `
256
258
  // versions:
257
259
  // protoc-gen-ts_proto ${tsProtoVersion}
258
- // protoc ${protocVersion}
260
+ // protoc ${protocVersion}`
261
+ : ""}
259
262
  ${fileName ? `// source: ${fileName}` : ""}
260
263
 
261
264
  /* eslint-disable */`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.174.0",
3
+ "version": "1.175.0",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",