ts-proto 2.2.3 → 2.2.5

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.
@@ -188,8 +188,8 @@ function encodedOptionsToOptions(ctx, extendee, encodedOptions) {
188
188
  const resultOptions = [];
189
189
  for (const key in encodedOptions) {
190
190
  const value = encodedOptions[key];
191
- const extension = extensionCache[extendee][parseInt(key, 10) >>> 3];
192
- if (shouldAddOptionDefinition(ctx, extension)) {
191
+ const extension = extensionCache[extendee]?.[parseInt(key, 10) >>> 3];
192
+ if (extension && shouldAddOptionDefinition(ctx, extension)) {
193
193
  // todo: we should be able to create an option definition ALWAYS, however,
194
194
  // we currently cannot do that because the if the extension is a sub-message
195
195
  // (and thus, not just a straightforward value), we don't have an JSON object
@@ -12,7 +12,7 @@ function visit(proto, sourceInfo, messageFn, options, enumFn = () => { }, tsPref
12
12
  const protoFullName = protoPrefix + enumDesc.name;
13
13
  // I.e. FooBar_ZazInner
14
14
  const tsFullName = tsPrefix + (0, case_1.maybeSnakeToCamel)(enumDesc.name, options);
15
- const tsFullNameWithAffixes = `${options.typePrefix}${tsFullName}${options.typeSuffix}`;
15
+ const tsFullNameWithAffixes = messageName(`${options.typePrefix}${tsFullName}${options.typeSuffix}`);
16
16
  const nestedSourceInfo = sourceInfo.open(childEnumType, index);
17
17
  enumFn(tsFullNameWithAffixes, enumDesc, nestedSourceInfo, protoFullName);
18
18
  });
@@ -22,8 +22,8 @@ function visit(proto, sourceInfo, messageFn, options, enumFn = () => { }, tsPref
22
22
  // I.e. Foo_Bar.Zaz_Inner
23
23
  const protoFullName = protoPrefix + message.name;
24
24
  // I.e. FooBar_ZazInner
25
- const tsFullName = tsPrefix + (0, case_1.maybeSnakeToCamel)(messageName(message), options);
26
- const tsFullNameWithAffixes = `${options.typePrefix}${tsFullName}${options.typeSuffix}`;
25
+ const tsFullName = tsPrefix + (0, case_1.maybeSnakeToCamel)(message.name, options);
26
+ const tsFullNameWithAffixes = messageName(`${options.typePrefix}${tsFullName}${options.typeSuffix}`);
27
27
  const nestedSourceInfo = sourceInfo.open(childType, index);
28
28
  messageFn(tsFullNameWithAffixes, message, nestedSourceInfo, protoFullName);
29
29
  const delim = options.useSnakeTypeName ? "_" : "";
@@ -32,8 +32,7 @@ function visit(proto, sourceInfo, messageFn, options, enumFn = () => { }, tsPref
32
32
  }
33
33
  const builtInNames = ["Date", "Function"];
34
34
  /** Potentially suffixes `Message` to names to avoid conflicts, i.e. with `Date`. */
35
- function messageName(message) {
36
- const { name } = message;
35
+ function messageName(name) {
37
36
  return builtInNames.includes(name) ? `${name}Message` : name;
38
37
  }
39
38
  function visitServices(proto, sourceInfo, serviceFn) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "",
5
5
  "main": "build/src/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",