From d0548445b82654db33525a06007b8b383fd005f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 17 Nov 2022 14:00:19 -0500 Subject: [PATCH 1/2] bump typescript to 4.9.3 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 7b6910172a04..52ae29b46f7a 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "shelljs": "^0.8.5", "test262-stream": "^1.4.0", "through2": "^4.0.0", - "typescript": "~4.8.3" + "typescript": "~4.9.3" }, "workspaces": [ "codemods/*", diff --git a/yarn.lock b/yarn.lock index 3d2fecc2c294..8ba1cf3aed27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5971,7 +5971,7 @@ __metadata: shelljs: ^0.8.5 test262-stream: ^1.4.0 through2: ^4.0.0 - typescript: ~4.8.3 + typescript: ~4.9.3 dependenciesMeta: core-js: built: false @@ -14707,23 +14707,23 @@ fsevents@^1.2.7: languageName: node linkType: hard -"typescript@npm:~4.8.3": - version: 4.8.4 - resolution: "typescript@npm:4.8.4" +"typescript@npm:~4.9.3": + version: 4.9.3 + resolution: "typescript@npm:4.9.3" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 3e4f061658e0c8f36c820802fa809e0fd812b85687a9a2f5430bc3d0368e37d1c9605c3ce9b39df9a05af2ece67b1d844f9f6ea8ff42819f13bcb80f85629af0 + checksum: 17b8f816050b412403e38d48eef0e893deb6be522d6dc7caf105e54a72e34daf6835c447735fd2b28b66784e72bfbf87f627abb4818a8e43d1fa8106396128dc languageName: node linkType: hard -"typescript@patch:typescript@~4.8.3#~builtin": - version: 4.8.4 - resolution: "typescript@patch:typescript@npm%3A4.8.4#~builtin::version=4.8.4&hash=701156" +"typescript@patch:typescript@~4.9.3#~builtin": + version: 4.9.3 + resolution: "typescript@patch:typescript@npm%3A4.9.3#~builtin::version=4.9.3&hash=701156" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 301459fc3eb3b1a38fe91bf96d98eb55da88a9cb17b4ef80b4d105d620f4d547ba776cc27b44cc2ef58b66eda23fe0a74142feb5e79a6fb99f54fc018a696afa + checksum: ef65c22622d864497d0a0c5db693523329b3284c15fe632e93ad9aa059e8dc38ef3bd767d6f26b1e5ecf9446f49bd0f6c4e5714a2eeaf352805dc002479843d1 languageName: node linkType: hard From 9a2de421b8dcd634330c1413c523c4425191f21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 17 Nov 2022 14:17:19 -0500 Subject: [PATCH 2/2] fix typing errors --- .../config/validation/option-assertions.ts | 19 ++++++++++++++++--- packages/babel-parser/src/parse-error.ts | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/babel-core/src/config/validation/option-assertions.ts b/packages/babel-core/src/config/validation/option-assertions.ts index 041e0c8cf0f5..9d47ffcd7e57 100644 --- a/packages/babel-core/src/config/validation/option-assertions.ts +++ b/packages/babel-core/src/config/validation/option-assertions.ts @@ -85,6 +85,7 @@ export function assertRootMode( `${msg(loc)} must be a "root", "upward", "upward-optional" or undefined`, ); } + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -102,6 +103,7 @@ export function assertSourceMaps( `${msg(loc)} must be a boolean, "inline", "both", or undefined`, ); } + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -112,6 +114,7 @@ export function assertCompact( if (value !== undefined && typeof value !== "boolean" && value !== "auto") { throw new Error(`${msg(loc)} must be a boolean, "auto", or undefined`); } + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -129,6 +132,7 @@ export function assertSourceType( `${msg(loc)} must be "module", "script", "unambiguous", or undefined`, ); } + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -186,6 +190,7 @@ export function assertString(loc: GeneralPath, value: unknown): string | void { if (value !== undefined && typeof value !== "string") { throw new Error(`${msg(loc)} must be a string, or undefined`); } + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -196,6 +201,7 @@ export function assertFunction( if (value !== undefined && typeof value !== "function") { throw new Error(`${msg(loc)} must be a function, or undefined`); } + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -206,6 +212,7 @@ export function assertBoolean( if (value !== undefined && typeof value !== "boolean") { throw new Error(`${msg(loc)} must be a boolean, or undefined`); } + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -263,7 +270,10 @@ export function assertConfigApplicableTest( loc: OptionPath, value: unknown, ): ConfigApplicableTest | void { - if (value === undefined) return value; + if (value === undefined) { + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true + return value; + } if (Array.isArray(value)) { value.forEach((item, i) => { @@ -303,7 +313,7 @@ export function assertConfigFileSearch( `got ${JSON.stringify(value)}`, ); } - + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true return value; } @@ -311,7 +321,10 @@ export function assertBabelrcSearch( loc: OptionPath, value: unknown, ): BabelrcSearch | void { - if (value === undefined || typeof value === "boolean") return value; + if (value === undefined || typeof value === "boolean") { + // @ts-expect-error: TS can only narrow down the type when "strictNullCheck" is true + return value; + } if (Array.isArray(value)) { value.forEach((item, i) => { diff --git a/packages/babel-parser/src/parse-error.ts b/packages/babel-parser/src/parse-error.ts index bd15bfb5369f..88ee87b94db7 100644 --- a/packages/babel-parser/src/parse-error.ts +++ b/packages/babel-parser/src/parse-error.ts @@ -47,7 +47,7 @@ export type ParseErrorConstructor = (a: { details: ErrorDetails; }) => ParseError; -function toParseErrorConstructor({ +function toParseErrorConstructor({ toMessage, ...properties }: ParseErrorCredentials): ParseErrorConstructor {