From 9a8978b55c9b6566901e0b25b984ff03389e6de2 Mon Sep 17 00:00:00 2001 From: Timo Stamm Date: Tue, 23 Apr 2024 12:54:19 +0200 Subject: [PATCH] V2: Bump supported version of TypeScript to 4.9.5 (#805) --- README.md | 2 +- package-lock.json | 32 ------------------- packages/protobuf-test/src/binary.test.ts | 10 +++--- packages/protobuf-test/src/create.test.ts | 12 +++---- packages/protobuf/src/wire/base64-encoding.ts | 4 +-- packages/protobuf/src/wire/binary-encoding.ts | 5 ++- packages/typescript-compat/README.md | 2 +- .../typescript-compat/v4.1.x/package.json | 11 ------- .../typescript-compat/v4.1.x/tsconfig.json | 25 --------------- .../typescript-compat/v4.2.x/package.json | 11 ------- .../typescript-compat/v4.2.x/tsconfig.json | 25 --------------- .../typescript-compat/v4.3.x/package.json | 11 ------- .../typescript-compat/v4.3.x/tsconfig.json | 17 ---------- .../typescript-compat/v4.4.x/package.json | 11 ------- .../typescript-compat/v4.4.x/tsconfig.json | 17 ---------- .../typescript-compat/v4.5.x/package.json | 11 ------- .../typescript-compat/v4.5.x/tsconfig.json | 19 ----------- .../typescript-compat/v4.6.x/package.json | 11 ------- .../typescript-compat/v4.6.x/tsconfig.json | 19 ----------- .../typescript-compat/v4.7.x/package.json | 11 ------- .../typescript-compat/v4.7.x/tsconfig.json | 19 ----------- .../typescript-compat/v4.8.x/package.json | 11 ------- .../typescript-compat/v4.8.x/tsconfig.json | 19 ----------- 23 files changed, 17 insertions(+), 298 deletions(-) delete mode 100644 packages/typescript-compat/v4.1.x/package.json delete mode 100644 packages/typescript-compat/v4.1.x/tsconfig.json delete mode 100644 packages/typescript-compat/v4.2.x/package.json delete mode 100644 packages/typescript-compat/v4.2.x/tsconfig.json delete mode 100644 packages/typescript-compat/v4.3.x/package.json delete mode 100644 packages/typescript-compat/v4.3.x/tsconfig.json delete mode 100644 packages/typescript-compat/v4.4.x/package.json delete mode 100644 packages/typescript-compat/v4.4.x/tsconfig.json delete mode 100644 packages/typescript-compat/v4.5.x/package.json delete mode 100644 packages/typescript-compat/v4.5.x/tsconfig.json delete mode 100644 packages/typescript-compat/v4.6.x/package.json delete mode 100644 packages/typescript-compat/v4.6.x/tsconfig.json delete mode 100644 packages/typescript-compat/v4.7.x/package.json delete mode 100644 packages/typescript-compat/v4.7.x/tsconfig.json delete mode 100644 packages/typescript-compat/v4.8.x/package.json delete mode 100644 packages/typescript-compat/v4.8.x/tsconfig.json diff --git a/README.md b/README.md index 453303e4b..216adea1d 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ You should now see a generated file at `src/gen/example_pb.ts` that contains a c ## TypeScript -The generated code is compatible with TypeScript **v4.1.2** or later, with the default compiler settings. +The generated code is compatible with TypeScript **v4.9.5** or later, with the default compiler settings. ## Copyright diff --git a/package-lock.json b/package-lock.json index d89fb2201..177d64338 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6216,38 +6216,6 @@ "dev": true, "license": "MIT" }, - "node_modules/ts4.1": { - "resolved": "packages/typescript-compat/v4.1.x", - "link": true - }, - "node_modules/ts4.2": { - "resolved": "packages/typescript-compat/v4.2.x", - "link": true - }, - "node_modules/ts4.3": { - "resolved": "packages/typescript-compat/v4.3.x", - "link": true - }, - "node_modules/ts4.4": { - "resolved": "packages/typescript-compat/v4.4.x", - "link": true - }, - "node_modules/ts4.5": { - "resolved": "packages/typescript-compat/v4.5.x", - "link": true - }, - "node_modules/ts4.6": { - "resolved": "packages/typescript-compat/v4.6.x", - "link": true - }, - "node_modules/ts4.7": { - "resolved": "packages/typescript-compat/v4.7.x", - "link": true - }, - "node_modules/ts4.8": { - "resolved": "packages/typescript-compat/v4.8.x", - "link": true - }, "node_modules/ts4.9": { "resolved": "packages/typescript-compat/v4.9.x", "link": true diff --git a/packages/protobuf-test/src/binary.test.ts b/packages/protobuf-test/src/binary.test.ts index e09f96d53..3f72a2f17 100644 --- a/packages/protobuf-test/src/binary.test.ts +++ b/packages/protobuf-test/src/binary.test.ts @@ -20,15 +20,18 @@ import { toBinary, fromBinary, } from "@bufbuild/protobuf"; -import type { MessageInitShape } from "@bufbuild/protobuf"; +import { + type MessageInitShape, + type DescMessage, + protoInt64, +} from "@bufbuild/protobuf"; +import { StructDesc, ValueDesc } from "@bufbuild/protobuf/wkt"; import { RepeatedScalarValuesMessageDesc, ScalarValuesMessageDesc, } from "./gen/ts/extra/msg-scalar_pb.js"; -import { protoInt64 } from "@bufbuild/protobuf"; import { MapsMessageDesc } from "./gen/ts/extra/msg-maps_pb.js"; import { MessageFieldMessageDesc } from "./gen/ts/extra/msg-message_pb.js"; -import type { DescMessage } from "@bufbuild/protobuf"; import { Proto2ExtendeeDesc, @@ -37,7 +40,6 @@ import { import { OneofMessageDesc } from "./gen/ts/extra/msg-oneof_pb.js"; import { JsonNamesMessageDesc } from "./gen/ts/extra/msg-json-names_pb.js"; import { JSTypeProto2NormalMessageDesc } from "./gen/ts/extra/jstype-proto2_pb.js"; -import { StructDesc, ValueDesc } from "@bufbuild/protobuf/wkt"; describe(`binary serialization`, () => { testBinary(ScalarValuesMessageDesc, { diff --git a/packages/protobuf-test/src/create.test.ts b/packages/protobuf-test/src/create.test.ts index a554531d0..1bc5851ac 100644 --- a/packages/protobuf-test/src/create.test.ts +++ b/packages/protobuf-test/src/create.test.ts @@ -671,15 +671,14 @@ describe("create()", () => { // @ts-expect-error expected type error repeatedInt64JsStringField: [protoInt64.parse(6)], either: { - // @ts-ignore -- required for older TS case: "oneofInt64Field", - // @ts-ignore -- required for older TS + // @ts-expect-error expected type error value: 7, }, mapInt64Int64Field: { - // @ts-ignore -- required for older TS + // @ts-expect-error expected type error "1": 8, - // @ts-ignore -- required for older TS + // @ts-expect-error expected type error "2": 9, }, }); @@ -714,9 +713,8 @@ describe("create()", () => { [0xde, 0xad, 0xbe, 0xef], ], either: { - // @ts-ignore -- number array is still a type error case: "oneofBytesField", - // @ts-ignore -- number array is still a type error + // @ts-expect-error -- number array is still a type error value: [0xde, 0xad, 0xbe, 0xef], }, }); @@ -798,7 +796,7 @@ describe("create()", () => { describe("enum field", () => { test("accepts proto3 enum value out of range", () => { const msg = create(proto3_ts.Proto3MessageDesc, { - // @ts-ignore -- cannot use ts-expect-error, not an error in older TS + // @ts-ignore -- required for older TS singularEnumField: 99, }); expect(msg.singularEnumField).toBe(99); diff --git a/packages/protobuf/src/wire/base64-encoding.ts b/packages/protobuf/src/wire/base64-encoding.ts index ef041d04c..a2dd5d370 100644 --- a/packages/protobuf/src/wire/base64-encoding.ts +++ b/packages/protobuf/src/wire/base64-encoding.ts @@ -41,10 +41,10 @@ export function base64Decode(base64Str: string) { b = table[base64Str.charCodeAt(i)]; if (b === undefined) { switch (base64Str[i]) { - // @ts-ignore TS7029: Fallthrough case in switch + // @ts-expect-error TS7029: Fallthrough case in switch case "=": groupPos = 0; // reset state when padding found - // @ts-ignore TS7029: Fallthrough case in switch + // eslint-disable-next-line no-fallthrough case "\n": case "\r": case "\t": diff --git a/packages/protobuf/src/wire/binary-encoding.ts b/packages/protobuf/src/wire/binary-encoding.ts index b720a7adb..db86f50e5 100644 --- a/packages/protobuf/src/wire/binary-encoding.ts +++ b/packages/protobuf/src/wire/binary-encoding.ts @@ -386,11 +386,10 @@ export class BinaryReader { } break; // eslint-disable-next-line - // @ts-ignore TS7029: Fallthrough case in switch + // @ts-expect-error TS7029: Fallthrough case in switch case WireType.Bit64: this.pos += 4; - // eslint-disable-next-line - // @ts-ignore TS7029: Fallthrough case in switch + // eslint-disable-next-line no-fallthrough case WireType.Bit32: this.pos += 4; break; diff --git a/packages/typescript-compat/README.md b/packages/typescript-compat/README.md index a4c6b6f5f..63174f3e0 100644 --- a/packages/typescript-compat/README.md +++ b/packages/typescript-compat/README.md @@ -12,7 +12,7 @@ respective to that version of TypeScript. ### Which versions are tested -- the earliest TypeScript version we support (4.1.2). +- the earliest TypeScript version we support. - the latest patch release of all minor versions up to the current release. ### Adding a new version diff --git a/packages/typescript-compat/v4.1.x/package.json b/packages/typescript-compat/v4.1.x/package.json deleted file mode 100644 index cf0d2c764..000000000 --- a/packages/typescript-compat/v4.1.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.1", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "18.11.9", - "typescript": "4.1.x" - } -} diff --git a/packages/typescript-compat/v4.1.x/tsconfig.json b/packages/typescript-compat/v4.1.x/tsconfig.json deleted file mode 100644 index 1da0a1abe..000000000 --- a/packages/typescript-compat/v4.1.x/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - "exclude": [ - // Exclude WKTs and their usage in tests because they use syntax not - // compatible with older versions of TypeScript. WKTs are typically not - // generated, but imported from @bufbuild/protobuf, which is compatible. - // Users of this version of TypeScript must use them. - "../../protobuf-test/src/gen/ts/google/protobuf/*.ts", - "../../protobuf-test/src/google/protobuf/*.test.ts" - ], - // These are the default compiler options for TypeScript v4.1.2, - // created with `tsc --init` - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -} diff --git a/packages/typescript-compat/v4.2.x/package.json b/packages/typescript-compat/v4.2.x/package.json deleted file mode 100644 index 58826e6b0..000000000 --- a/packages/typescript-compat/v4.2.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.2", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "18.15.3", - "typescript": "4.2.x" - } -} diff --git a/packages/typescript-compat/v4.2.x/tsconfig.json b/packages/typescript-compat/v4.2.x/tsconfig.json deleted file mode 100644 index ece8bf1a2..000000000 --- a/packages/typescript-compat/v4.2.x/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - "exclude": [ - // Exclude WKTs and their usage in tests because they use syntax not - // compatible with older versions of TypeScript. WKTs are typically not - // generated, but imported from @bufbuild/protobuf, which is compatible. - // Users of this version of TypeScript must use them. - "../../protobuf-test/src/gen/ts/google/protobuf/*.ts", - "../../protobuf-test/src/google/protobuf/*.test.ts" - ], - // These are the default compiler options for TypeScript v4.2.4, - // created with `tsc --init` - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -} diff --git a/packages/typescript-compat/v4.3.x/package.json b/packages/typescript-compat/v4.3.x/package.json deleted file mode 100644 index 8d5e9cc96..000000000 --- a/packages/typescript-compat/v4.3.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.3", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "20.6.0", - "typescript": "4.3.x" - } -} diff --git a/packages/typescript-compat/v4.3.x/tsconfig.json b/packages/typescript-compat/v4.3.x/tsconfig.json deleted file mode 100644 index 22f81bd8d..000000000 --- a/packages/typescript-compat/v4.3.x/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - // These are the default compiler options for TypeScript v4.3.5, - // created with `tsc --init` - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -} diff --git a/packages/typescript-compat/v4.4.x/package.json b/packages/typescript-compat/v4.4.x/package.json deleted file mode 100644 index b3f1948aa..000000000 --- a/packages/typescript-compat/v4.4.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.4", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "ts4.4", - "typescript": "4.4.x" - } -} diff --git a/packages/typescript-compat/v4.4.x/tsconfig.json b/packages/typescript-compat/v4.4.x/tsconfig.json deleted file mode 100644 index fa3a3fa69..000000000 --- a/packages/typescript-compat/v4.4.x/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - // These are the default compiler options for TypeScript v4.4.x, created - // with `tsc --init` (except where noted in comments below) - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -} diff --git a/packages/typescript-compat/v4.5.x/package.json b/packages/typescript-compat/v4.5.x/package.json deleted file mode 100644 index d7b780272..000000000 --- a/packages/typescript-compat/v4.5.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.5", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "20.8.8", - "typescript": "4.5.x" - } -} diff --git a/packages/typescript-compat/v4.5.x/tsconfig.json b/packages/typescript-compat/v4.5.x/tsconfig.json deleted file mode 100644 index bf55e55bc..000000000 --- a/packages/typescript-compat/v4.5.x/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - // These are the default compiler options for TypeScript v4.5.2, created - // with `tsc --init` (except where noted in comments below) - "compilerOptions": { - "target": "es2016", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - // To guard against regression and ensure we are remaining backwards - // compatible, set the skipLibCheck flag to false explicitly. - "skipLibCheck": false, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -} diff --git a/packages/typescript-compat/v4.6.x/package.json b/packages/typescript-compat/v4.6.x/package.json deleted file mode 100644 index dc854a10b..000000000 --- a/packages/typescript-compat/v4.6.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.6", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "20.8.8", - "typescript": "4.6.x" - } -} diff --git a/packages/typescript-compat/v4.6.x/tsconfig.json b/packages/typescript-compat/v4.6.x/tsconfig.json deleted file mode 100644 index 60d9d8794..000000000 --- a/packages/typescript-compat/v4.6.x/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - // These are the default compiler options for TypeScript v4.6.x, created - // with `tsc --init` (except where noted in comments below) - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - // To guard against regression and ensure we are remaining backwards - // compatible, set the skipLibCheck flag to false explicitly. - "skipLibCheck": false, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -} diff --git a/packages/typescript-compat/v4.7.x/package.json b/packages/typescript-compat/v4.7.x/package.json deleted file mode 100644 index 8d7300254..000000000 --- a/packages/typescript-compat/v4.7.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.7", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "20.8.8", - "typescript": "4.7.x" - } -} diff --git a/packages/typescript-compat/v4.7.x/tsconfig.json b/packages/typescript-compat/v4.7.x/tsconfig.json deleted file mode 100644 index 57b4455a0..000000000 --- a/packages/typescript-compat/v4.7.x/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - // These are the default compiler options for TypeScript v4.7.x, created - // with `tsc --init` (except where noted in comments below) - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - // To guard against regression and ensure we are remaining backwards - // compatible, set the skipLibCheck flag to false explicitly. - "skipLibCheck": false, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -} diff --git a/packages/typescript-compat/v4.8.x/package.json b/packages/typescript-compat/v4.8.x/package.json deleted file mode 100644 index e38654416..000000000 --- a/packages/typescript-compat/v4.8.x/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ts4.8", - "scripts": { - "test": "node_modules/.bin/tsc --outDir dist" - }, - "dependencies": { - "@bufbuild/protobuf-test": "*", - "@types/node": "20.8.8", - "typescript": "4.8.x" - } -} diff --git a/packages/typescript-compat/v4.8.x/tsconfig.json b/packages/typescript-compat/v4.8.x/tsconfig.json deleted file mode 100644 index 0c699769d..000000000 --- a/packages/typescript-compat/v4.8.x/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "include": ["../../protobuf-test/src/**/*"], - // These are the default compiler options for TypeScript v4.8.x, created - // with `tsc --init` (except where noted in comments below) - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - // To guard against regression and ensure we are remaining backwards - // compatible, set the skipLibCheck flag to false explicitly. - "skipLibCheck": false, - // Certain errors are only triggered by actually emitting declaration files, - // see https://github.com/bufbuild/protobuf-es/pull/398 - "declaration": true, - "declarationMap": true - } -}