Remove outdated node type "Import" (#16831)

This commit is contained in:
fisker Cheung authored and GitHub committed 2024-11-09 12:00:34 +08:00
1 parent dc8df0ab80
commit 51d943abcf
6 files changed
+4 -10

No files matched your search

@@ -14,8 +14,6 @@ import {
const nodeTypesCanNotAttachComment = new Set([
"EmptyStatement",
"TemplateElement",
// In ESTree `import` is a token, `import("foo")`
"Import",
// There is no similar node in Babel AST
// ```ts
// class Foo {
+2 -4
View File
@@ -78,13 +78,11 @@ function printCallArguments(path, options, print) {
printedArguments.push(argDoc);
});
// Dynamic imports cannot have trailing commas
const isDynamicImport =
node.type === "ImportExpression" || node.callee.type === "Import";
const maybeTrailingComma =
// Angular does not allow trailing comma
!options.parser.startsWith("__ng_") &&
!isDynamicImport &&
// Dynamic imports cannot have trailing commas
node.type !== "ImportExpression" &&
shouldPrintComma(options, "all")
? ","
: "";
-2
View File
@@ -229,8 +229,6 @@ function printEstree(path, options, print, args) {
return printModuleSpecifier(path, options, print);
case "ImportAttribute":
return printProperty(path, options, print);
case "Import":
return "import";
case "Program":
case "BlockStatement":
@@ -95,5 +95,7 @@ const visitorKeys = Object.fromEntries(
// Babel will remove this in v8
delete visitorKeys.DecimalLiteral;
// Won't exist since we use `createImportExpressions` when parsing with babel
delete visitorKeys.Import;
export default visitorKeys;
-1
View File
@@ -191,7 +191,6 @@ const isSingleWordType = createTypeCheckFunction([
"Super",
"PrivateName",
"PrivateIdentifier",
"Import",
]);
const isObjectType = createTypeCheckFunction([
@@ -411,7 +411,6 @@ exports[`visitor keys estree 1`] = `
"consequent",
"test",
],
"Import": [],
"ImportAttribute": [
"key",
"value",