From 1519a1be9bd1574884aa0ab8b9ca8abaa060d0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 15 May 2024 11:42:55 +0200 Subject: [PATCH] Import types from @babel/core in plugins --- .../src/for-await.ts | 3 +-- .../src/index.ts | 4 ++-- .../src/index.ts | 3 +-- .../src/annex-B_3_3.ts | 2 +- .../babel-plugin-transform-block-scoping/src/index.ts | 4 ++-- .../babel-plugin-transform-block-scoping/src/loop.ts | 9 ++++++--- .../src/validation.ts | 8 ++++---- .../src/index.ts | 2 +- .../babel-plugin-transform-classes/src/transformClass.ts | 4 ++-- .../src/index.ts | 3 +-- .../babel-plugin-transform-destructuring/src/index.ts | 3 +-- .../babel-plugin-transform-destructuring/src/util.ts | 6 ++---- .../babel-plugin-transform-flow-comments/src/index.ts | 3 +-- .../babel-plugin-transform-flow-strip-types/src/index.ts | 3 +-- packages/babel-plugin-transform-for-of/src/index.ts | 3 +-- .../src/no-helper-implementation.ts | 4 ++-- .../babel-plugin-transform-json-strings/src/index.ts | 3 +-- packages/babel-plugin-transform-modules-amd/src/index.ts | 4 ++-- .../src/dynamic-import.ts | 4 ++-- .../babel-plugin-transform-modules-commonjs/src/index.ts | 4 ++-- .../babel-plugin-transform-modules-systemjs/src/index.ts | 4 ++-- packages/babel-plugin-transform-modules-umd/src/index.ts | 3 +-- packages/babel-plugin-transform-new-target/src/index.ts | 3 +-- .../src/index.ts | 3 +-- .../src/index.ts | 3 +-- .../babel-plugin-transform-object-super/src/index.ts | 4 ++-- .../src/index.ts | 3 +-- .../src/transform.ts | 3 +-- .../babel-plugin-transform-optional-chaining/src/util.ts | 2 +- packages/babel-plugin-transform-parameters/src/rest.ts | 2 +- .../src/shadow-utils.ts | 2 +- .../src/index.ts | 3 +-- .../src/index.ts | 2 +- .../babel-plugin-transform-react-jsx-self/src/index.ts | 2 +- .../src/create-plugin.ts | 3 +-- .../src/index.ts | 3 +-- .../babel-plugin-transform-reserved-words/src/index.ts | 3 +-- packages/babel-plugin-transform-spread/src/index.ts | 3 +-- .../src/index.ts | 3 +-- .../babel-plugin-transform-typescript/src/const-enum.ts | 3 +-- packages/babel-plugin-transform-typescript/src/enum.ts | 3 +-- .../src/global-types.ts | 2 +- packages/babel-plugin-transform-typescript/src/index.ts | 5 ++--- .../babel-plugin-transform-typescript/src/namespace.ts | 3 +-- .../babel-plugin-transform-unicode-escapes/src/index.ts | 3 +-- .../src/plugin-rewrite-ts-imports.ts | 3 +-- 46 files changed, 65 insertions(+), 90 deletions(-) diff --git a/packages/babel-plugin-transform-async-generator-functions/src/for-await.ts b/packages/babel-plugin-transform-async-generator-functions/src/for-await.ts index fce810c5e9bca..c4045f349b527 100644 --- a/packages/babel-plugin-transform-async-generator-functions/src/for-await.ts +++ b/packages/babel-plugin-transform-async-generator-functions/src/for-await.ts @@ -1,5 +1,4 @@ -import { types as t, template } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, template, type NodePath } from "@babel/core"; const buildForAwait = template(` async function wrapper() { diff --git a/packages/babel-plugin-transform-async-generator-functions/src/index.ts b/packages/babel-plugin-transform-async-generator-functions/src/index.ts index 16510d45cb04b..ac7be8fe0089d 100644 --- a/packages/babel-plugin-transform-async-generator-functions/src/index.ts +++ b/packages/babel-plugin-transform-async-generator-functions/src/index.ts @@ -1,7 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import remapAsyncToGenerator from "@babel/helper-remap-async-to-generator"; -import type { NodePath, Visitor } from "@babel/traverse"; -import { traverse, types as t, type PluginPass } from "@babel/core"; +import type { NodePath, Visitor, PluginPass } from "@babel/core"; +import { traverse, types as t } from "@babel/core"; import rewriteForAwait from "./for-await.ts"; import environmentVisitor from "@babel/helper-environment-visitor"; diff --git a/packages/babel-plugin-transform-block-scoped-functions/src/index.ts b/packages/babel-plugin-transform-block-scoped-functions/src/index.ts index 8f6d1cf9f7b49..be6c4c7fc2985 100644 --- a/packages/babel-plugin-transform-block-scoped-functions/src/index.ts +++ b/packages/babel-plugin-transform-block-scoped-functions/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import { types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, type NodePath } from "@babel/core"; export default declare(api => { api.assertVersion(REQUIRED_VERSION(7)); diff --git a/packages/babel-plugin-transform-block-scoping/src/annex-B_3_3.ts b/packages/babel-plugin-transform-block-scoping/src/annex-B_3_3.ts index 42f5a85790974..a34ba80b224d8 100644 --- a/packages/babel-plugin-transform-block-scoping/src/annex-B_3_3.ts +++ b/packages/babel-plugin-transform-block-scoping/src/annex-B_3_3.ts @@ -1,5 +1,5 @@ import { types as t } from "@babel/core"; -import type { NodePath, Visitor, Scope } from "@babel/traverse"; +import type { NodePath, Visitor, Scope } from "@babel/core"; // Whenever a function declaration in a nested block scope // doesn't conflict with a block-scoped binding from an outer diff --git a/packages/babel-plugin-transform-block-scoping/src/index.ts b/packages/babel-plugin-transform-block-scoping/src/index.ts index 45abcaa7640ec..e7e0e6edc6aa5 100644 --- a/packages/babel-plugin-transform-block-scoping/src/index.ts +++ b/packages/babel-plugin-transform-block-scoping/src/index.ts @@ -1,6 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; -import type { NodePath, Scope, Visitor } from "@babel/traverse"; -import { type PluginPass, types as t, traverse } from "@babel/core"; +import type { NodePath, Scope, Visitor, PluginPass } from "@babel/core"; +import { types as t, traverse } from "@babel/core"; import { getLoopBodyBindings, diff --git a/packages/babel-plugin-transform-block-scoping/src/loop.ts b/packages/babel-plugin-transform-block-scoping/src/loop.ts index 666cd89d24943..72b2df7ddfac1 100644 --- a/packages/babel-plugin-transform-block-scoping/src/loop.ts +++ b/packages/babel-plugin-transform-block-scoping/src/loop.ts @@ -1,8 +1,8 @@ import { template, types as t } from "@babel/core"; -import type { NodePath, Visitor, Binding } from "@babel/traverse"; +import type { NodePath, Visitor, Scope } from "@babel/core"; interface LoopBodyBindingsState { - blockScoped: Binding[]; + blockScoped: Scope.Binding[]; } const collectLoopBodyBindingsVisitor: Visitor = { @@ -32,7 +32,10 @@ export function getLoopBodyBindings(loopPath: NodePath) { return state.blockScoped; } -export function getUsageInBody(binding: Binding, loopPath: NodePath) { +export function getUsageInBody( + binding: Scope.Binding, + loopPath: NodePath, +) { // UpdateExpressions are counted both as a reference and a mutation, // so we need to de-duplicate them. const seen = new WeakSet(); diff --git a/packages/babel-plugin-transform-block-scoping/src/validation.ts b/packages/babel-plugin-transform-block-scoping/src/validation.ts index 38657bb971b34..5aec79aca88bb 100644 --- a/packages/babel-plugin-transform-block-scoping/src/validation.ts +++ b/packages/babel-plugin-transform-block-scoping/src/validation.ts @@ -1,5 +1,5 @@ -import { types as t, type PluginPass } from "@babel/core"; -import type { Binding, NodePath } from "@babel/traverse"; +import { types as t } from "@babel/core"; +import type { Scope, NodePath, PluginPass } from "@babel/core"; export function validateUsage( path: NodePath, @@ -25,7 +25,7 @@ export function validateUsage( function disallowConstantViolations( name: string, - binding: Binding, + binding: Scope.Binding, state: PluginPass, ) { for (const violation of binding.constantViolations) { @@ -151,7 +151,7 @@ function getTDZReplacement( return { status, node: buildTDZAssert(status, id, state) }; } -function injectTDZChecks(binding: Binding, state: PluginPass) { +function injectTDZChecks(binding: Scope.Binding, state: PluginPass) { const allUsages = new Set(binding.referencePaths); binding.constantViolations.forEach(allUsages.add, allUsages); diff --git a/packages/babel-plugin-transform-class-static-block/src/index.ts b/packages/babel-plugin-transform-class-static-block/src/index.ts index 2681079e19891..58f7c9772430b 100644 --- a/packages/babel-plugin-transform-class-static-block/src/index.ts +++ b/packages/babel-plugin-transform-class-static-block/src/index.ts @@ -1,5 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import type { Scope } from "@babel/traverse"; +import type { Scope } from "@babel/core"; import { enableFeature, diff --git a/packages/babel-plugin-transform-classes/src/transformClass.ts b/packages/babel-plugin-transform-classes/src/transformClass.ts index b16158b0124d5..e57bb1150476e 100644 --- a/packages/babel-plugin-transform-classes/src/transformClass.ts +++ b/packages/babel-plugin-transform-classes/src/transformClass.ts @@ -1,8 +1,8 @@ -import type { NodePath, Scope, Visitor } from "@babel/traverse"; +import type { NodePath, Scope, Visitor, File } from "@babel/core"; import nameFunction from "@babel/helper-function-name"; import ReplaceSupers from "@babel/helper-replace-supers"; import environmentVisitor from "@babel/helper-environment-visitor"; -import { traverse, template, types as t, type File } from "@babel/core"; +import { traverse, template, types as t } from "@babel/core"; import annotateAsPure from "@babel/helper-annotate-as-pure"; import addCallSuperHelper from "./inline-callSuper-helpers.ts"; diff --git a/packages/babel-plugin-transform-computed-properties/src/index.ts b/packages/babel-plugin-transform-computed-properties/src/index.ts index c423ae76b8370..ef6ba631f93e2 100644 --- a/packages/babel-plugin-transform-computed-properties/src/index.ts +++ b/packages/babel-plugin-transform-computed-properties/src/index.ts @@ -1,8 +1,7 @@ import { types as t } from "@babel/core"; -import type { PluginPass } from "@babel/core"; +import type { PluginPass, Scope } from "@babel/core"; import { declare } from "@babel/helper-plugin-utils"; import template from "@babel/template"; -import type { Scope } from "@babel/traverse"; export interface Options { loose?: boolean; diff --git a/packages/babel-plugin-transform-destructuring/src/index.ts b/packages/babel-plugin-transform-destructuring/src/index.ts index c278d06c8eb1c..05847cd97b6c6 100644 --- a/packages/babel-plugin-transform-destructuring/src/index.ts +++ b/packages/babel-plugin-transform-destructuring/src/index.ts @@ -1,5 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import { types as t } from "@babel/core"; +import { types as t, type NodePath } from "@babel/core"; import { DestructuringTransformer, convertVariableDeclaration, @@ -8,7 +8,6 @@ import { type DestructuringTransformerNode, } from "./util.ts"; export { buildObjectExcludingKeys, unshiftForXStatementBody } from "./util.ts"; -import type { NodePath } from "@babel/traverse"; /** * Test if a VariableDeclaration's declarations contains any Patterns. diff --git a/packages/babel-plugin-transform-destructuring/src/util.ts b/packages/babel-plugin-transform-destructuring/src/util.ts index 5a6a71ede6f71..4fbf1f121677c 100644 --- a/packages/babel-plugin-transform-destructuring/src/util.ts +++ b/packages/babel-plugin-transform-destructuring/src/util.ts @@ -1,7 +1,5 @@ import { types as t } from "@babel/core"; -import type { File } from "@babel/core"; -import type { Scope, NodePath } from "@babel/traverse"; -import type { TraversalAncestors } from "@babel/types"; +import type { File, Scope, NodePath } from "@babel/core"; function isPureVoid(node: t.Node) { return ( @@ -61,7 +59,7 @@ interface ArrayUnpackVisitorState { // NOTE: This visitor is meant to be used via t.traverse const arrayUnpackVisitor = ( node: t.Node, - ancestors: TraversalAncestors, + ancestors: t.TraversalAncestors, state: ArrayUnpackVisitorState, ) => { if (!ancestors.length) { diff --git a/packages/babel-plugin-transform-flow-comments/src/index.ts b/packages/babel-plugin-transform-flow-comments/src/index.ts index 56e3526891882..b8acd875149db 100644 --- a/packages/babel-plugin-transform-flow-comments/src/index.ts +++ b/packages/babel-plugin-transform-flow-comments/src/index.ts @@ -1,8 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxFlow from "@babel/plugin-syntax-flow"; -import { types as t } from "@babel/core"; +import { types as t, type NodePath } from "@babel/core"; import generateCode from "@babel/generator"; -import type { NodePath } from "@babel/traverse"; export default declare(api => { api.assertVersion(REQUIRED_VERSION(7)); diff --git a/packages/babel-plugin-transform-flow-strip-types/src/index.ts b/packages/babel-plugin-transform-flow-strip-types/src/index.ts index 5513ed6077c98..de0a5b2a3c94e 100644 --- a/packages/babel-plugin-transform-flow-strip-types/src/index.ts +++ b/packages/babel-plugin-transform-flow-strip-types/src/index.ts @@ -1,7 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxFlow from "@babel/plugin-syntax-flow"; -import { types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, type NodePath } from "@babel/core"; export interface Options { requireDirective?: boolean; diff --git a/packages/babel-plugin-transform-for-of/src/index.ts b/packages/babel-plugin-transform-for-of/src/index.ts index cef59a53c5bec..d0a62ba58381b 100644 --- a/packages/babel-plugin-transform-for-of/src/index.ts +++ b/packages/babel-plugin-transform-for-of/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import { template, types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { template, types as t, type NodePath } from "@babel/core"; import transformWithoutHelper from "./no-helper-implementation.ts"; import { skipTransparentExprWrapperNodes } from "@babel/helper-skip-transparent-expression-wrappers"; diff --git a/packages/babel-plugin-transform-for-of/src/no-helper-implementation.ts b/packages/babel-plugin-transform-for-of/src/no-helper-implementation.ts index 774b8dcbeb161..69d3187f55b4b 100644 --- a/packages/babel-plugin-transform-for-of/src/no-helper-implementation.ts +++ b/packages/babel-plugin-transform-for-of/src/no-helper-implementation.ts @@ -1,5 +1,5 @@ -import { type PluginPass, template, types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { template, types as t } from "@babel/core"; +import type { PluginPass, NodePath } from "@babel/core"; // This is the legacy implementation, which inlines all the code. // It must be kept for compatibility reasons. diff --git a/packages/babel-plugin-transform-json-strings/src/index.ts b/packages/babel-plugin-transform-json-strings/src/index.ts index bcdb9bf0a3949..633cbbdfff4cc 100644 --- a/packages/babel-plugin-transform-json-strings/src/index.ts +++ b/packages/babel-plugin-transform-json-strings/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import type * as t from "@babel/types"; -import type { NodePath } from "@babel/traverse"; +import type { NodePath, types as t } from "@babel/core"; export default declare(api => { api.assertVersion(REQUIRED_VERSION(7)); diff --git a/packages/babel-plugin-transform-modules-amd/src/index.ts b/packages/babel-plugin-transform-modules-amd/src/index.ts index a1f7e8f0eab0c..e9d35f6191480 100644 --- a/packages/babel-plugin-transform-modules-amd/src/index.ts +++ b/packages/babel-plugin-transform-modules-amd/src/index.ts @@ -11,9 +11,9 @@ import { wrapInterop, getModuleName, } from "@babel/helper-module-transforms"; -import { template, types as t, type PluginPass } from "@babel/core"; +import { template, types as t } from "@babel/core"; import type { PluginOptions } from "@babel/helper-module-transforms"; -import type { NodePath } from "@babel/traverse"; +import type { NodePath, PluginPass } from "@babel/core"; const buildWrapper = template.statement(` define(MODULE_NAME, AMD_ARGUMENTS, function(IMPORT_NAMES) { diff --git a/packages/babel-plugin-transform-modules-commonjs/src/dynamic-import.ts b/packages/babel-plugin-transform-modules-commonjs/src/dynamic-import.ts index 36eb869d8c87c..6abacc5f7f175 100644 --- a/packages/babel-plugin-transform-modules-commonjs/src/dynamic-import.ts +++ b/packages/babel-plugin-transform-modules-commonjs/src/dynamic-import.ts @@ -1,8 +1,8 @@ // Heavily inspired by // https://github.com/airbnb/babel-plugin-dynamic-import-node/blob/master/src/utils.js -import type { NodePath } from "@babel/traverse"; -import { types as t, template, type File } from "@babel/core"; +import type { File, NodePath } from "@babel/core"; +import { types as t, template } from "@babel/core"; import { buildDynamicImport } from "@babel/helper-module-transforms"; const requireNoInterop = (source: t.Expression) => diff --git a/packages/babel-plugin-transform-modules-commonjs/src/index.ts b/packages/babel-plugin-transform-modules-commonjs/src/index.ts index a7ecffbfd13b6..cf673acd037f3 100644 --- a/packages/babel-plugin-transform-modules-commonjs/src/index.ts +++ b/packages/babel-plugin-transform-modules-commonjs/src/index.ts @@ -10,9 +10,9 @@ import { getModuleName, } from "@babel/helper-module-transforms"; import simplifyAccess from "@babel/helper-simple-access"; -import { template, types as t, type PluginPass } from "@babel/core"; +import { template, types as t } from "@babel/core"; +import type { PluginPass, Visitor, Scope, NodePath } from "@babel/core"; import type { PluginOptions } from "@babel/helper-module-transforms"; -import type { Visitor, Scope, NodePath } from "@babel/traverse"; import { transformDynamicImport } from "./dynamic-import.ts"; import { lazyImportsHook } from "./lazy.ts"; diff --git a/packages/babel-plugin-transform-modules-systemjs/src/index.ts b/packages/babel-plugin-transform-modules-systemjs/src/index.ts index e34e22102f45c..bb5fea4a89666 100644 --- a/packages/babel-plugin-transform-modules-systemjs/src/index.ts +++ b/packages/babel-plugin-transform-modules-systemjs/src/index.ts @@ -1,6 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import hoistVariables from "@babel/helper-hoist-variables"; -import { template, types as t, type PluginPass } from "@babel/core"; +import { template, types as t } from "@babel/core"; +import type { PluginPass, NodePath, Scope, Visitor } from "@babel/core"; import { buildDynamicImport, getModuleName, @@ -8,7 +9,6 @@ import { } from "@babel/helper-module-transforms"; import type { PluginOptions } from "@babel/helper-module-transforms"; import { isIdentifierName } from "@babel/helper-validator-identifier"; -import type { NodePath, Scope, Visitor } from "@babel/traverse"; const buildTemplate = template.statement(` SYSTEM_REGISTER(MODULE_NAME, SOURCES, function (EXPORT_IDENTIFIER, CONTEXT_IDENTIFIER) { diff --git a/packages/babel-plugin-transform-modules-umd/src/index.ts b/packages/babel-plugin-transform-modules-umd/src/index.ts index ebe0dfaa58fc8..28431911ed09d 100644 --- a/packages/babel-plugin-transform-modules-umd/src/index.ts +++ b/packages/babel-plugin-transform-modules-umd/src/index.ts @@ -12,8 +12,7 @@ import { getModuleName, } from "@babel/helper-module-transforms"; import type { PluginOptions } from "@babel/helper-module-transforms"; -import { types as t, template } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, template, type NodePath } from "@babel/core"; const buildPrerequisiteAssignment = template(` GLOBAL_REFERENCE = GLOBAL_REFERENCE || {} diff --git a/packages/babel-plugin-transform-new-target/src/index.ts b/packages/babel-plugin-transform-new-target/src/index.ts index 88361b17d3fae..3ce4aa9fa127c 100644 --- a/packages/babel-plugin-transform-new-target/src/index.ts +++ b/packages/babel-plugin-transform-new-target/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import { types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, type NodePath } from "@babel/core"; export default declare(api => { api.assertVersion(REQUIRED_VERSION(7)); diff --git a/packages/babel-plugin-transform-numeric-separator/src/index.ts b/packages/babel-plugin-transform-numeric-separator/src/index.ts index 99f99bf30ff6e..c43769a654572 100644 --- a/packages/babel-plugin-transform-numeric-separator/src/index.ts +++ b/packages/babel-plugin-transform-numeric-separator/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import type { NodePath } from "@babel/traverse"; -import type * as t from "@babel/types"; +import type { NodePath, types as t } from "@babel/core"; /** * Given a bigIntLiteral or NumericLiteral, remove numeric diff --git a/packages/babel-plugin-transform-object-rest-spread/src/index.ts b/packages/babel-plugin-transform-object-rest-spread/src/index.ts index f85525dbcc70a..458aa3797fccf 100644 --- a/packages/babel-plugin-transform-object-rest-spread/src/index.ts +++ b/packages/babel-plugin-transform-object-rest-spread/src/index.ts @@ -1,7 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; -import type { PluginPass } from "@babel/core"; -import type { NodePath, Scope } from "@babel/traverse"; +import type { PluginPass, NodePath, Scope } from "@babel/core"; import { convertFunctionParams } from "@babel/plugin-transform-parameters"; import { isRequired } from "@babel/helper-compilation-targets"; import shouldStoreRHSInTemporaryVariable from "./shouldStoreRHSInTemporaryVariable.ts"; diff --git a/packages/babel-plugin-transform-object-super/src/index.ts b/packages/babel-plugin-transform-object-super/src/index.ts index 45d424cb1b17e..fe71aa236a147 100644 --- a/packages/babel-plugin-transform-object-super/src/index.ts +++ b/packages/babel-plugin-transform-object-super/src/index.ts @@ -1,7 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import ReplaceSupers from "@babel/helper-replace-supers"; -import { types as t, type File } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t } from "@babel/core"; +import type { File, NodePath } from "@babel/core"; function replacePropertySuper( path: NodePath, diff --git a/packages/babel-plugin-transform-optional-chaining/src/index.ts b/packages/babel-plugin-transform-optional-chaining/src/index.ts index 1cf326d120bdc..3d89689514799 100644 --- a/packages/babel-plugin-transform-optional-chaining/src/index.ts +++ b/packages/babel-plugin-transform-optional-chaining/src/index.ts @@ -1,7 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import { transform, transformOptionalChain } from "./transform.ts"; -import type { NodePath } from "@babel/traverse"; -import type * as t from "@babel/types"; +import type { NodePath, types as t } from "@babel/core"; export interface Options { loose?: boolean; diff --git a/packages/babel-plugin-transform-optional-chaining/src/transform.ts b/packages/babel-plugin-transform-optional-chaining/src/transform.ts index 704b043cb2a3a..c205f1844eea4 100644 --- a/packages/babel-plugin-transform-optional-chaining/src/transform.ts +++ b/packages/babel-plugin-transform-optional-chaining/src/transform.ts @@ -1,5 +1,4 @@ -import { types as t, template } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, template, type NodePath } from "@babel/core"; import { skipTransparentExprWrapperNodes, skipTransparentExprWrappers, diff --git a/packages/babel-plugin-transform-optional-chaining/src/util.ts b/packages/babel-plugin-transform-optional-chaining/src/util.ts index 4bb72bc55bf01..473fd04608380 100644 --- a/packages/babel-plugin-transform-optional-chaining/src/util.ts +++ b/packages/babel-plugin-transform-optional-chaining/src/util.ts @@ -1,4 +1,4 @@ -import type { NodePath } from "@babel/traverse"; +import type { NodePath } from "@babel/core"; import { isTransparentExprWrapper } from "@babel/helper-skip-transparent-expression-wrappers"; /** * Test if a NodePath will be cast to boolean when evaluated. diff --git a/packages/babel-plugin-transform-parameters/src/rest.ts b/packages/babel-plugin-transform-parameters/src/rest.ts index e7b516d3940c3..0056c29b7ce69 100644 --- a/packages/babel-plugin-transform-parameters/src/rest.ts +++ b/packages/babel-plugin-transform-parameters/src/rest.ts @@ -1,5 +1,5 @@ import { template, types as t } from "@babel/core"; -import type { NodePath, Visitor } from "@babel/traverse"; +import type { NodePath, Visitor } from "@babel/core"; import { iifeVisitor, diff --git a/packages/babel-plugin-transform-parameters/src/shadow-utils.ts b/packages/babel-plugin-transform-parameters/src/shadow-utils.ts index fe9648ed765cb..03c7ff8e6deec 100644 --- a/packages/babel-plugin-transform-parameters/src/shadow-utils.ts +++ b/packages/babel-plugin-transform-parameters/src/shadow-utils.ts @@ -1,5 +1,5 @@ import { types as t } from "@babel/core"; -import type { NodePath, Scope, Visitor } from "@babel/traverse"; +import type { NodePath, Scope, Visitor } from "@babel/core"; type State = { needsOuterBinding: boolean; diff --git a/packages/babel-plugin-transform-private-property-in-object/src/index.ts b/packages/babel-plugin-transform-private-property-in-object/src/index.ts index 8bb8f07f3613c..cc8cefea84b4f 100644 --- a/packages/babel-plugin-transform-private-property-in-object/src/index.ts +++ b/packages/babel-plugin-transform-private-property-in-object/src/index.ts @@ -6,8 +6,7 @@ import { buildCheckInRHS, } from "@babel/helper-create-class-features-plugin"; import annotateAsPure from "@babel/helper-annotate-as-pure"; -import type * as t from "@babel/types"; -import type { NodePath, Scope } from "@babel/traverse"; +import type { NodePath, Scope, types as t } from "@babel/core"; export interface Options { loose?: boolean; diff --git a/packages/babel-plugin-transform-react-constant-elements/src/index.ts b/packages/babel-plugin-transform-react-constant-elements/src/index.ts index 4f392eb4208bd..80262eb03dbe5 100644 --- a/packages/babel-plugin-transform-react-constant-elements/src/index.ts +++ b/packages/babel-plugin-transform-react-constant-elements/src/index.ts @@ -1,6 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t, template } from "@babel/core"; -import type { Visitor, Scope, NodePath } from "@babel/traverse"; +import type { Visitor, Scope, NodePath } from "@babel/core"; export interface Options { allowMutablePropsOnTags?: null | string[]; diff --git a/packages/babel-plugin-transform-react-jsx-self/src/index.ts b/packages/babel-plugin-transform-react-jsx-self/src/index.ts index f4cb7a126d843..3c8f0d6f0176c 100644 --- a/packages/babel-plugin-transform-react-jsx-self/src/index.ts +++ b/packages/babel-plugin-transform-react-jsx-self/src/index.ts @@ -14,7 +14,7 @@ */ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; -import type { Visitor, NodePath } from "@babel/traverse"; +import type { Visitor, NodePath } from "@babel/core"; const TRACE_ID = "__self"; diff --git a/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts b/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts index 6567238958c54..e18cabe957dd1 100644 --- a/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts +++ b/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts @@ -1,8 +1,7 @@ import jsx from "@babel/plugin-syntax-jsx"; import { declare } from "@babel/helper-plugin-utils"; import { template, types as t } from "@babel/core"; -import type { PluginPass } from "@babel/core"; -import type { NodePath, Scope, Visitor } from "@babel/traverse"; +import type { PluginPass, NodePath, Scope, Visitor } from "@babel/core"; import { addNamed, addNamespace, isModule } from "@babel/helper-module-imports"; import annotateAsPure from "@babel/helper-annotate-as-pure"; import type { diff --git a/packages/babel-plugin-transform-react-pure-annotations/src/index.ts b/packages/babel-plugin-transform-react-pure-annotations/src/index.ts index a04b836b75646..0cf4ddd6ce8f4 100644 --- a/packages/babel-plugin-transform-react-pure-annotations/src/index.ts +++ b/packages/babel-plugin-transform-react-pure-annotations/src/index.ts @@ -1,7 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import annotateAsPure from "@babel/helper-annotate-as-pure"; -import { types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, type NodePath } from "@babel/core"; // Mapping of React top-level methods that are pure. // This plugin adds a /*#__PURE__#/ annotation to calls to these methods, diff --git a/packages/babel-plugin-transform-reserved-words/src/index.ts b/packages/babel-plugin-transform-reserved-words/src/index.ts index 13f5e0d9ac634..50a012ebdb8b8 100644 --- a/packages/babel-plugin-transform-reserved-words/src/index.ts +++ b/packages/babel-plugin-transform-reserved-words/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import { types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, type NodePath } from "@babel/core"; export default declare(api => { api.assertVersion(REQUIRED_VERSION(7)); diff --git a/packages/babel-plugin-transform-spread/src/index.ts b/packages/babel-plugin-transform-spread/src/index.ts index 616ac881f0044..98d29bf56bfe4 100644 --- a/packages/babel-plugin-transform-spread/src/index.ts +++ b/packages/babel-plugin-transform-spread/src/index.ts @@ -1,8 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import { skipTransparentExprWrappers } from "@babel/helper-skip-transparent-expression-wrappers"; -import type { File } from "@babel/core"; import { types as t } from "@babel/core"; -import type { NodePath, Scope } from "@babel/traverse"; +import type { File, NodePath, Scope } from "@babel/core"; type ListElement = t.SpreadElement | t.Expression; diff --git a/packages/babel-plugin-transform-template-literals/src/index.ts b/packages/babel-plugin-transform-template-literals/src/index.ts index d3f7a760b278d..9746809339982 100644 --- a/packages/babel-plugin-transform-template-literals/src/index.ts +++ b/packages/babel-plugin-transform-template-literals/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import { template, types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { template, types as t, type NodePath } from "@babel/core"; export interface Options { loose?: boolean; diff --git a/packages/babel-plugin-transform-typescript/src/const-enum.ts b/packages/babel-plugin-transform-typescript/src/const-enum.ts index c45eb68b13985..de8bb8ead37bb 100644 --- a/packages/babel-plugin-transform-typescript/src/const-enum.ts +++ b/packages/babel-plugin-transform-typescript/src/const-enum.ts @@ -1,5 +1,4 @@ -import type * as t from "@babel/types"; -import type { NodePath } from "@babel/traverse"; +import type { NodePath, types as t } from "@babel/core"; import { translateEnumValues } from "./enum.ts"; diff --git a/packages/babel-plugin-transform-typescript/src/enum.ts b/packages/babel-plugin-transform-typescript/src/enum.ts index de2f7ef6a42c4..cdc209c6634a4 100644 --- a/packages/babel-plugin-transform-typescript/src/enum.ts +++ b/packages/babel-plugin-transform-typescript/src/enum.ts @@ -1,5 +1,4 @@ -import { template, types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { template, types as t, type NodePath } from "@babel/core"; import assert from "assert"; import annotateAsPure from "@babel/helper-annotate-as-pure"; diff --git a/packages/babel-plugin-transform-typescript/src/global-types.ts b/packages/babel-plugin-transform-typescript/src/global-types.ts index 552320fe56b02..f57ca31a5f5d8 100644 --- a/packages/babel-plugin-transform-typescript/src/global-types.ts +++ b/packages/babel-plugin-transform-typescript/src/global-types.ts @@ -1,4 +1,4 @@ -import type { NodePath, Scope } from "@babel/traverse"; +import type { NodePath, Scope } from "@babel/core"; export const GLOBAL_TYPES = new WeakMap>(); diff --git a/packages/babel-plugin-transform-typescript/src/index.ts b/packages/babel-plugin-transform-typescript/src/index.ts index e996c6f14666c..59c7b316fbab1 100644 --- a/packages/babel-plugin-transform-typescript/src/index.ts +++ b/packages/babel-plugin-transform-typescript/src/index.ts @@ -1,8 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxTypeScript from "@babel/plugin-syntax-typescript"; -import type { PluginPass, types as t } from "@babel/core"; +import type { PluginPass, types as t, Scope, NodePath } from "@babel/core"; import { injectInitialization } from "@babel/helper-create-class-features-plugin"; -import type { Binding, NodePath } from "@babel/traverse"; import type { Options as SyntaxOptions } from "@babel/plugin-syntax-typescript"; import transpileConstEnum from "./const-enum.ts"; @@ -724,7 +723,7 @@ export default declare((api, opts: Options) => { pragmaImportName, pragmaFragImportName, }: { - binding: Binding; + binding: Scope.Binding; programPath: NodePath; pragmaImportName: string; pragmaFragImportName: string; diff --git a/packages/babel-plugin-transform-typescript/src/namespace.ts b/packages/babel-plugin-transform-typescript/src/namespace.ts index eaf7d4f9e64d6..3aaecc6cffc87 100644 --- a/packages/babel-plugin-transform-typescript/src/namespace.ts +++ b/packages/babel-plugin-transform-typescript/src/namespace.ts @@ -1,5 +1,4 @@ -import { template, types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { template, types as t, type NodePath } from "@babel/core"; import { registerGlobalType } from "./global-types.ts"; diff --git a/packages/babel-plugin-transform-unicode-escapes/src/index.ts b/packages/babel-plugin-transform-unicode-escapes/src/index.ts index e3a7291d7993d..8b6304f3d4cf1 100644 --- a/packages/babel-plugin-transform-unicode-escapes/src/index.ts +++ b/packages/babel-plugin-transform-unicode-escapes/src/index.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import { types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import { types as t, type NodePath } from "@babel/core"; export default declare(api => { api.assertVersion(REQUIRED_VERSION(7)); diff --git a/packages/babel-preset-typescript/src/plugin-rewrite-ts-imports.ts b/packages/babel-preset-typescript/src/plugin-rewrite-ts-imports.ts index b585bfcf78854..2f256eb5391bb 100644 --- a/packages/babel-preset-typescript/src/plugin-rewrite-ts-imports.ts +++ b/packages/babel-preset-typescript/src/plugin-rewrite-ts-imports.ts @@ -1,6 +1,5 @@ import { declare } from "@babel/helper-plugin-utils"; -import type { types as t } from "@babel/core"; -import type { NodePath } from "@babel/traverse"; +import type { types as t, NodePath } from "@babel/core"; export default declare(function ({ types: t }) { return {