From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Mon, 20 Mar 2023 22:49:50 +0800 Subject: [PATCH] chore: Update TS 5.0.2 (#15502) * update * prettier origin: backport, https://github.com/babel/babel/commit/032203ea18288b9ae51f0c18dfece03a59555113 bug: https://github.com/babel/babel/pull/15502 --- package.json | 2 +- packages/babel-core/src/config/files/index.ts | 2 +- packages/babel-core/src/config/printer.ts | 6 +++--- packages/babel-core/src/config/resolve-targets.ts | 2 +- packages/babel-core/src/config/validation/options.ts | 2 +- packages/babel-core/src/transform-file.ts | 2 +- packages/babel-helper-compilation-targets/src/utils.ts | 2 +- packages/babel-helper-create-regexp-features-plugin/src/features.ts | 2 +- packages/babel-parser/src/parser/lval.ts | 4 ++-- packages/babel-parser/src/plugins/typescript/index.ts | 2 +- packages/babel-plugin-syntax-pipeline-operator/src/index.ts | 4 ++-- packages/babel-preset-env/src/types.d.ts | 4 ++-- packages/babel-traverse/src/path/evaluation.ts | 4 ++-- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index df6d234..d8c03ee 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.9.3" + "typescript": "^5.0.2" }, "workspaces": [ "codemods/*", diff --git a/packages/babel-core/src/config/files/index.ts b/packages/babel-core/src/config/files/index.ts index 31e8560..5c340eb 100644 --- a/packages/babel-core/src/config/files/index.ts +++ b/packages/babel-core/src/config/files/index.ts @@ -3,7 +3,7 @@ type indexType = typeof import("./index"); // Kind of gross, but essentially asserting that the exports of this module are the same as the // exports of index-browser, since this file may be replaced at bundle time with index-browser. -({} as any as indexBrowserType as indexType); +({}) as any as indexBrowserType as indexType; export { findPackageData } from "./package"; diff --git a/packages/babel-core/src/config/printer.ts b/packages/babel-core/src/config/printer.ts index 7e26ed7..618a9c3 100644 --- a/packages/babel-core/src/config/printer.ts +++ b/packages/babel-core/src/config/printer.ts @@ -15,7 +15,7 @@ export const ChainFormatter = { type PrintableConfig = { content: OptionsAndDescriptors; - type: typeof ChainFormatter[keyof typeof ChainFormatter]; + type: (typeof ChainFormatter)[keyof typeof ChainFormatter]; callerName: string | undefined | null; filepath: string | undefined | null; index: number | undefined | null; @@ -24,7 +24,7 @@ type PrintableConfig = { const Formatter = { title( - type: typeof ChainFormatter[keyof typeof ChainFormatter], + type: (typeof ChainFormatter)[keyof typeof ChainFormatter], callerName?: string | null, filepath?: string | null, ): string { @@ -98,7 +98,7 @@ export class ConfigPrinter { _stack: Array = []; configure( enabled: boolean, - type: typeof ChainFormatter[keyof typeof ChainFormatter], + type: (typeof ChainFormatter)[keyof typeof ChainFormatter], { callerName, filepath, diff --git a/packages/babel-core/src/config/resolve-targets.ts b/packages/babel-core/src/config/resolve-targets.ts index a7d9a79..04c7fec 100644 --- a/packages/babel-core/src/config/resolve-targets.ts +++ b/packages/babel-core/src/config/resolve-targets.ts @@ -3,7 +3,7 @@ type nodeType = typeof import("./resolve-targets"); // Kind of gross, but essentially asserting that the exports of this module are the same as the // exports of index-browser, since this file may be replaced at bundle time with index-browser. -({} as any as browserType as nodeType); +({}) as any as browserType as nodeType; import type { ValidatedOptions } from "./validation/options"; import path from "path"; diff --git a/packages/babel-core/src/config/validation/options.ts b/packages/babel-core/src/config/validation/options.ts index d79ea0f..52b1338 100644 --- a/packages/babel-core/src/config/validation/options.ts +++ b/packages/babel-core/src/config/validation/options.ts @@ -286,7 +286,7 @@ const knownAssumptions = [ "skipForOfIteratorClosing", "superIsCallableConstructor", ] as const; -export type AssumptionName = typeof knownAssumptions[number]; +export type AssumptionName = (typeof knownAssumptions)[number]; export const assumptionsNames = new Set(knownAssumptions); function getSource(loc: NestingPath): OptionsSource { diff --git a/packages/babel-core/src/transform-file.ts b/packages/babel-core/src/transform-file.ts index c493425..c9706ba 100644 --- a/packages/babel-core/src/transform-file.ts +++ b/packages/babel-core/src/transform-file.ts @@ -12,7 +12,7 @@ type transformFileType = typeof import("./transform-file"); // Kind of gross, but essentially asserting that the exports of this module are the same as the // exports of transform-file-browser, since this file may be replaced at bundle time with // transform-file-browser. -({} as any as transformFileBrowserType as transformFileType); +({}) as any as transformFileBrowserType as transformFileType; const transformFileRunner = gensync(function* ( filename: string, diff --git a/packages/babel-helper-compilation-targets/src/utils.ts b/packages/babel-helper-compilation-targets/src/utils.ts index 984eba7..2590886 100644 --- a/packages/babel-helper-compilation-targets/src/utils.ts +++ b/packages/babel-helper-compilation-targets/src/utils.ts @@ -53,7 +53,7 @@ export function isUnreleasedVersion( export function getLowestUnreleased(a: string, b: string, env: Target): string { const unreleasedLabel: - | typeof unreleasedLabels[keyof typeof unreleasedLabels] + | (typeof unreleasedLabels)[keyof typeof unreleasedLabels] | undefined = // @ts-expect-error unreleasedLabel is undefined when env is not safari unreleasedLabels[env]; diff --git a/packages/babel-helper-create-regexp-features-plugin/src/features.ts b/packages/babel-helper-create-regexp-features-plugin/src/features.ts index ed9b6f4..acb9ab1 100644 --- a/packages/babel-helper-create-regexp-features-plugin/src/features.ts +++ b/packages/babel-helper-create-regexp-features-plugin/src/features.ts @@ -18,7 +18,7 @@ export const FEATURES = Object.freeze({ export const featuresKey = "@babel/plugin-regexp-features/featuresKey"; export const runtimeKey = "@babel/plugin-regexp-features/runtimeKey"; -type FeatureType = typeof FEATURES[keyof typeof FEATURES]; +type FeatureType = (typeof FEATURES)[keyof typeof FEATURES]; export function enableFeature(features: number, feature: FeatureType): number { return features | feature; diff --git a/packages/babel-parser/src/parser/lval.ts b/packages/babel-parser/src/parser/lval.ts index d1df5f9..97cb414 100644 --- a/packages/babel-parser/src/parser/lval.ts +++ b/packages/babel-parser/src/parser/lval.ts @@ -383,7 +383,7 @@ export default abstract class LValParser extends NodeUtils { parseBindingList( this: Parser, close: TokenType, - closeCharCode: typeof charCodes[keyof typeof charCodes], + closeCharCode: (typeof charCodes)[keyof typeof charCodes], allowEmpty?: boolean, allowModifiers?: boolean, ): Array { @@ -710,7 +710,7 @@ export default abstract class LValParser extends NodeUtils { } checkCommaAfterRest( - close: typeof charCodes[keyof typeof charCodes], + close: (typeof charCodes)[keyof typeof charCodes], ): boolean { if (!this.match(tt.comma)) { return false; diff --git a/packages/babel-parser/src/plugins/typescript/index.ts b/packages/babel-parser/src/plugins/typescript/index.ts index e781b07..ca150b2 100644 --- a/packages/babel-parser/src/plugins/typescript/index.ts +++ b/packages/babel-parser/src/plugins/typescript/index.ts @@ -3651,7 +3651,7 @@ export default (superClass: ClassWithMixin) => } checkCommaAfterRest( - close: typeof charCodes[keyof typeof charCodes], + close: (typeof charCodes)[keyof typeof charCodes], ): boolean { if ( this.state.isAmbientContext && diff --git a/packages/babel-plugin-syntax-pipeline-operator/src/index.ts b/packages/babel-plugin-syntax-pipeline-operator/src/index.ts index 2834cc9..f2754b3 100644 --- a/packages/babel-plugin-syntax-pipeline-operator/src/index.ts +++ b/packages/babel-plugin-syntax-pipeline-operator/src/index.ts @@ -6,8 +6,8 @@ const documentationURL = "https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator"; export interface Options { - proposal: typeof PIPELINE_PROPOSALS[number]; - topicToken?: typeof TOPIC_TOKENS[number]; + proposal: (typeof PIPELINE_PROPOSALS)[number]; + topicToken?: (typeof TOPIC_TOKENS)[number]; } export default declare((api, { proposal, topicToken }: Options) => { diff --git a/packages/babel-preset-env/src/types.d.ts b/packages/babel-preset-env/src/types.d.ts index e0fb50e..aec4b3f 100644 --- a/packages/babel-preset-env/src/types.d.ts +++ b/packages/babel-preset-env/src/types.d.ts @@ -4,9 +4,9 @@ import type { Targets, InputTargets } from "@babel/helper-compilation-targets"; // Options // Use explicit modules to prevent typo errors. -export type ModuleOption = typeof ModulesOption[keyof typeof ModulesOption]; +export type ModuleOption = (typeof ModulesOption)[keyof typeof ModulesOption]; export type BuiltInsOption = - typeof UseBuiltInsOption[keyof typeof UseBuiltInsOption]; + (typeof UseBuiltInsOption)[keyof typeof UseBuiltInsOption]; type CorejsVersion = 2 | 3 | string; diff --git a/packages/babel-traverse/src/path/evaluation.ts b/packages/babel-traverse/src/path/evaluation.ts index 85f284c..ac65bd6 100644 --- a/packages/babel-traverse/src/path/evaluation.ts +++ b/packages/babel-traverse/src/path/evaluation.ts @@ -6,14 +6,14 @@ import type * as t from "@babel/types"; const VALID_CALLEES = ["String", "Number", "Math"] as const; const INVALID_METHODS = ["random"] as const; -function isValidCallee(val: string): val is typeof VALID_CALLEES[number] { +function isValidCallee(val: string): val is (typeof VALID_CALLEES)[number] { return VALID_CALLEES.includes( // @ts-expect-error val is a string val, ); } -function isInvalidMethod(val: string): val is typeof INVALID_METHODS[number] { +function isInvalidMethod(val: string): val is (typeof INVALID_METHODS)[number] { return INVALID_METHODS.includes( // @ts-expect-error val is a string val,