From e2323b60028ef93f5b84d07544a66272c1bf35f6 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Fri, 1 Jul 2022 14:23:56 -0700 Subject: [PATCH] refactor: update to typescript 4.7.4 (#603) Updates to TypeScript 4.7.x (latest). This requires an update to ts-proto-descriptors, to release: 1. Release ts-proto-descriptors version 1.7.0. 2. Update package.json with ts-proto-descriptors version. 3. Publish ts-proto update. Additionally, some other minor fixes: - Cast _unknownFields to any to fix build errors. - Update docker-compose to v2: uses plugin: "docker compose" Fixes #607 Signed-off-by: Christian Stewart --- .../simple-esmodule-interop/package.json | 2 +- integration/simple-esmodule-interop/yarn.lock | 8 +- .../google/protobuf/compiler/plugin.ts | 20 +-- .../google/protobuf/descriptor.ts | 135 +++++++++++------- integration/unknown-fields/options.ts | 15 +- .../unknown-fields/something/something.ts | 5 +- package.json | 16 +-- src/main.ts | 5 +- yarn.lock | 97 +++++++++++-- 9 files changed, 203 insertions(+), 100 deletions(-) diff --git a/integration/simple-esmodule-interop/package.json b/integration/simple-esmodule-interop/package.json index 037b015f5..78ee41290 100644 --- a/integration/simple-esmodule-interop/package.json +++ b/integration/simple-esmodule-interop/package.json @@ -5,7 +5,7 @@ "author": "", "license": "ISC", "dependencies": { - "typescript": "^4.2.3", + "typescript": "^4.7.4", "jest": "^26.6.3" } } diff --git a/integration/simple-esmodule-interop/yarn.lock b/integration/simple-esmodule-interop/yarn.lock index e6f6af0df..2757865f9 100644 --- a/integration/simple-esmodule-interop/yarn.lock +++ b/integration/simple-esmodule-interop/yarn.lock @@ -3211,10 +3211,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^4.2.3: - version "4.6.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c" - integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw== +typescript@^4.7.4: + version "4.7.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" + integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== union-value@^1.0.0: version "1.0.1" diff --git a/integration/unknown-fields/google/protobuf/compiler/plugin.ts b/integration/unknown-fields/google/protobuf/compiler/plugin.ts index f3353c89e..e7c7e6e5e 100644 --- a/integration/unknown-fields/google/protobuf/compiler/plugin.ts +++ b/integration/unknown-fields/google/protobuf/compiler/plugin.ts @@ -161,8 +161,9 @@ export const Version = { writer.uint32(34).string(message.suffix); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -229,8 +230,9 @@ export const CodeGeneratorRequest = { Version.encode(message.compilerVersion, writer.uint32(26).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -294,8 +296,9 @@ export const CodeGeneratorResponse = { CodeGeneratorResponse_File.encode(v!, writer.uint32(122).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -359,8 +362,9 @@ export const CodeGeneratorResponse_File = { GeneratedCodeInfo.encode(message.generatedCodeInfo, writer.uint32(130).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( diff --git a/integration/unknown-fields/google/protobuf/descriptor.ts b/integration/unknown-fields/google/protobuf/descriptor.ts index 6f2e5c48d..43f507660 100644 --- a/integration/unknown-fields/google/protobuf/descriptor.ts +++ b/integration/unknown-fields/google/protobuf/descriptor.ts @@ -861,8 +861,9 @@ export const FileDescriptorSet = { FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -961,8 +962,9 @@ export const FileDescriptorProto = { writer.uint32(98).string(message.syntax); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1096,8 +1098,9 @@ export const DescriptorProto = { writer.uint32(82).string(v!); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1179,8 +1182,9 @@ export const DescriptorProto_ExtensionRange = { ExtensionRangeOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1238,8 +1242,9 @@ export const DescriptorProto_ReservedRange = { writer.uint32(16).int32(message.end); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1291,8 +1296,9 @@ export const ExtensionRangeOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1383,8 +1389,9 @@ export const FieldDescriptorProto = { writer.uint32(136).bool(message.proto3Optional); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1466,8 +1473,9 @@ export const OneofDescriptorProto = { OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1531,8 +1539,9 @@ export const EnumDescriptorProto = { writer.uint32(42).string(v!); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1596,8 +1605,9 @@ export const EnumDescriptorProto_EnumReservedRange = { writer.uint32(16).int32(message.end); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1655,8 +1665,9 @@ export const EnumValueDescriptorProto = { EnumValueOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1717,8 +1728,9 @@ export const ServiceDescriptorProto = { ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1795,8 +1807,9 @@ export const MethodDescriptorProto = { writer.uint32(48).bool(message.serverStreaming); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -1942,8 +1955,9 @@ export const FileOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2070,8 +2084,9 @@ export const MessageOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2150,8 +2165,9 @@ export const FieldOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2218,8 +2234,9 @@ export const OneofOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2274,8 +2291,9 @@ export const EnumOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2333,8 +2351,9 @@ export const EnumValueOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2389,8 +2408,9 @@ export const ServiceOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2448,8 +2468,9 @@ export const MethodOptions = { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2530,8 +2551,9 @@ export const UninterpretedOption = { writer.uint32(66).string(message.aggregateValue); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2601,8 +2623,9 @@ export const UninterpretedOption_NamePart = { writer.uint32(16).bool(message.isExtension); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2654,8 +2677,9 @@ export const SourceCodeInfo = { SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2720,8 +2744,9 @@ export const SourceCodeInfo_Location = { writer.uint32(50).string(v!); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2796,8 +2821,9 @@ export const GeneratedCodeInfo = { GeneratedCodeInfo_Annotation.encode(v!, writer.uint32(10).fork()).ldelim(); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -2857,8 +2883,9 @@ export const GeneratedCodeInfo_Annotation = { writer.uint32(32).int32(message.end); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( diff --git a/integration/unknown-fields/options.ts b/integration/unknown-fields/options.ts index e8ed01194..0a2448879 100644 --- a/integration/unknown-fields/options.ts +++ b/integration/unknown-fields/options.ts @@ -39,8 +39,9 @@ export const MyMessage = { writer.uint32(34).string(message.quux); } if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -95,8 +96,9 @@ function createBaseRequestType(): RequestType { export const RequestType = { encode(message: RequestType, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( @@ -139,8 +141,9 @@ function createBaseResponseType(): ResponseType { export const ResponseType = { encode(message: ResponseType, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( diff --git a/integration/unknown-fields/something/something.ts b/integration/unknown-fields/something/something.ts index 4fbd49f16..95840185f 100644 --- a/integration/unknown-fields/something/something.ts +++ b/integration/unknown-fields/something/something.ts @@ -23,8 +23,9 @@ export const Something = { } writer.ldelim(); if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields']; + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( diff --git a/package.json b/package.json index 325cd6980..99c73f6eb 100644 --- a/package.json +++ b/package.json @@ -12,17 +12,17 @@ "build:test": "yarn proto2bin && yarn proto2pbjs && yarn bin2ts", "build:test:local": "yarn proto2bin:local && yarn proto2pbjs:local && yarn bin2ts:local", "prepare": "yarn build", - "proto2bin": "docker-compose run --rm protoc update-bins.sh", - "proto2bin-node": "docker-compose run --rm node update-bins.sh", - "proto2pbjs": "docker-compose run --rm protoc pbjs.sh", - "bin2ts": "docker-compose run --rm protoc codegen.sh", + "proto2bin": "docker compose run --rm protoc update-bins.sh", + "proto2bin-node": "docker compose run --rm node update-bins.sh", + "proto2pbjs": "docker compose run --rm protoc pbjs.sh", + "bin2ts": "docker compose run --rm protoc codegen.sh", "proto2bin:local": "integration/update-bins.sh", "proto2pbjs:local": "integration/pbjs.sh", "bin2ts:local": "integration/codegen.sh", "test": "yarn jest -c jest.config.js --maxWorkers=2", "prettier": "prettier --write {src,tests}/**/*.ts integration/*.ts", "prettier:check": "prettier --list-different {src,tests}/**/*.ts", - "setup:docker": "docker-compose build", + "setup:docker": "docker compose build", "watch": "ts-node integration/watch.ts" }, "files": [ @@ -57,8 +57,8 @@ "rxjs": "^7.4.0", "semantic-release": "^17.4.2", "ts-jest": "^26.5.4", - "ts-node": "^9.1.1", - "typescript": "^4.2.3", + "ts-node": "^10.8.1", + "typescript": "^4.7.4", "uglify-js": "^3.13.3" }, "dependencies": { @@ -67,6 +67,6 @@ "object-hash": "^1.3.1", "protobufjs": "^6.11.3", "ts-poet": "^4.11.0", - "ts-proto-descriptors": "1.6.0" + "ts-proto-descriptors": "1.7.0" } } diff --git a/src/main.ts b/src/main.ts index 111206010..2ba1ed230 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1107,8 +1107,9 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP if (options.unknownFields) { chunks.push(code`if ('_unknownFields' in message) { - for (const key of Object.keys(message['_unknownFields'])) { - const values = message['_unknownFields'][key] as Uint8Array[]; + const msgUnknownFields: any = (message as any)['_unknownFields'] + for (const key of Object.keys(msgUnknownFields)) { + const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); (writer as any)['_push']( diff --git a/yarn.lock b/yarn.lock index 9060374ce..49096729a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -279,6 +279,13 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + "@grpc/grpc-js@^1.2.12": version "1.2.12" resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.2.12.tgz" @@ -514,6 +521,24 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@jridgewell/resolve-uri@^3.0.3": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.8.tgz#687cc2bbf243f4e9a868ecf2262318e2658873a1" + integrity sha512-YK5G9LaddzGbcucK4c8h5tWFmMPBvRZ/uyWmN1/SbBdIvqGUdWGkJ5BAaccgs6XbzVLsqbPJrBSFwKv3kT9i7w== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@nestjs/common@^8.2.2": version "8.2.2" resolved "https://registry.npmjs.org/@nestjs/common/-/common-8.2.2.tgz" @@ -1001,6 +1026,26 @@ resolved "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e" + integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ== + "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7": version "7.1.7" resolved "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.7.tgz" @@ -1198,6 +1243,11 @@ acorn-walk@^7.1.1: resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== +acorn-walk@^8.1.1: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + acorn@^7.1.1: version "7.4.1" resolved "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz" @@ -1208,6 +1258,11 @@ acorn@^8.1.0: resolved "https://registry.npmjs.org/acorn/-/acorn-8.1.0.tgz" integrity sha512-LWCF/Wn0nfHOmJ9rzQApGnxnvgfROzGilS8936rqN/lfcYkY9MYZzdMqN+2NJ4SlTc+m5HiSa+kNfDtI64dwUA== +acorn@^8.4.1: + version "8.7.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" + integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== + agent-base@6: version "6.0.2" resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz" @@ -5901,7 +5956,7 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.17, source-map-support@^0.5.6: +source-map-support@^0.5.6: version "0.5.19" resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -6380,16 +6435,23 @@ ts-jest@^26.5.4: semver "7.x" yargs-parser "20.x" -ts-node@^9.1.1: - version "9.1.1" - resolved "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz" - integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg== - dependencies: +ts-node@^10.8.1: + version "10.8.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.1.tgz#ea2bd3459011b52699d7e88daa55a45a1af4f066" + integrity sha512-Wwsnao4DQoJsN034wePSg5nZiw4YKXf56mPIAeD6wVmiv+RytNSWqc2f3fKvcUoV+Yn2+yocD71VOfQHbmVX4g== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" arg "^4.1.0" create-require "^1.1.0" diff "^4.0.1" make-error "^1.1.1" - source-map-support "^0.5.17" + v8-compile-cache-lib "^3.0.1" yn "3.1.1" ts-poet@^4.11.0: @@ -6400,10 +6462,10 @@ ts-poet@^4.11.0: lodash "^4.17.15" prettier "^2.5.1" -ts-proto-descriptors@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/ts-proto-descriptors/-/ts-proto-descriptors-1.6.0.tgz#ca6eafc882495a2e920da5b981d7b181b4e49c38" - integrity sha512-Vrhue2Ti99us/o76mGy28nF3W/Uanl1/8detyJw2yyRwiBC5yxy+hEZqQ/ZX2PbZ1vyCpJ51A9L4PnCCnkBMTQ== +ts-proto-descriptors@1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/ts-proto-descriptors/-/ts-proto-descriptors-1.7.0.tgz#bd465a17642b23747c21a2442a2ec379446cd18b" + integrity sha512-FydY8jv+V/y48LNGy/UX1H5p2z6mV/dP8kgn+4VqZ6VI7pw/JTgWaxF3SRuCPxEhzDFB5WaLVLlnbDXrPzyHWQ== dependencies: long "^4.0.0" protobufjs "^6.8.8" @@ -6474,10 +6536,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^4.2.3: - version "4.2.3" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz" - integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw== +typescript@^4.7.4: + version "4.7.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" + integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== uglify-js@^3.1.4, uglify-js@^3.13.3: version "3.13.3" @@ -6575,6 +6637,11 @@ uuid@^3.3.2: resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + v8-to-istanbul@^7.0.0: version "7.1.1" resolved "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-7.1.1.tgz"