From e21d01724642fa4a3d6482a4ad60e75791527d46 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Thu, 3 Nov 2022 17:12:13 +0800 Subject: [PATCH 1/3] fix --- packages/babel-plugin-transform-typescript/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/babel-plugin-transform-typescript/src/index.ts b/packages/babel-plugin-transform-typescript/src/index.ts index e11a51b7c245..962464d68b99 100644 --- a/packages/babel-plugin-transform-typescript/src/index.ts +++ b/packages/babel-plugin-transform-typescript/src/index.ts @@ -595,7 +595,9 @@ export default declare((api, opts: Options) => { [`TSAsExpression${ // Added in Babel 7.20.0 - t.tsSatisfiesExpression ? "|TSSatisfiesExpression" : "" + // Some downstream bundled `@babel/core` and `@babel/types`. + // Ref: https://github.com/babel/babel/issues/15089 + api.types.tsSatisfiesExpression ? "|TSSatisfiesExpression" : "" }`](path: NodePath) { let { node }: { node: t.Expression } = path; do { From 61e7016f5127b96a5ffba83ed8da058b91aa9ea6 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Thu, 3 Nov 2022 22:39:17 +0800 Subject: [PATCH 2/3] review --- .../babel-plugin-transform-typescript/src/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/babel-plugin-transform-typescript/src/index.ts b/packages/babel-plugin-transform-typescript/src/index.ts index 962464d68b99..c1773d90d57c 100644 --- a/packages/babel-plugin-transform-typescript/src/index.ts +++ b/packages/babel-plugin-transform-typescript/src/index.ts @@ -1,6 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxTypeScript from "@babel/plugin-syntax-typescript"; -import { types as t, template } from "@babel/core"; +import type { types as t } from "@babel/core"; import { injectInitialization } from "@babel/helper-create-class-features-plugin"; import type { Binding, NodePath, Scope } from "@babel/traverse"; import type { Options as SyntaxOptions } from "@babel/plugin-syntax-typescript"; @@ -96,6 +96,10 @@ type ExtraNodeProps = { }; export default declare((api, opts: Options) => { + // Some downstream bundled `@babel/core` and `@babel/types`. + // Ref: https://github.com/babel/babel/issues/15089 + const { types: t, template } = api; + api.assertVersion(7); const JSX_PRAGMA_REGEX = /\*?\s*@jsx((?:Frag)?)\s+([^\s]+)/; @@ -595,9 +599,7 @@ export default declare((api, opts: Options) => { [`TSAsExpression${ // Added in Babel 7.20.0 - // Some downstream bundled `@babel/core` and `@babel/types`. - // Ref: https://github.com/babel/babel/issues/15089 - api.types.tsSatisfiesExpression ? "|TSSatisfiesExpression" : "" + t.tsSatisfiesExpression ? "|TSSatisfiesExpression" : "" }`](path: NodePath) { let { node }: { node: t.Expression } = path; do { From 7d4766a1f423b67c8ba7525a50bc86d439d5774f Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Fri, 4 Nov 2022 00:00:19 +0800 Subject: [PATCH 3/3] Update packages/babel-plugin-transform-typescript/src/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Huáng Jùnliàng --- packages/babel-plugin-transform-typescript/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-plugin-transform-typescript/src/index.ts b/packages/babel-plugin-transform-typescript/src/index.ts index c1773d90d57c..5e094c60aa20 100644 --- a/packages/babel-plugin-transform-typescript/src/index.ts +++ b/packages/babel-plugin-transform-typescript/src/index.ts @@ -96,7 +96,7 @@ type ExtraNodeProps = { }; export default declare((api, opts: Options) => { - // Some downstream bundled `@babel/core` and `@babel/types`. + // `@babel/core` and `@babel/types` are bundled in some downstream libraries. // Ref: https://github.com/babel/babel/issues/15089 const { types: t, template } = api;