Add possible node types (#18621)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-01-14 01:42:32 +08:00
1 parent e636454118
commit 204731adeb
5 files changed
+46 -3

No files matched your search

+3
View File
@@ -60,6 +60,9 @@ function shouldAddParensIfNotBreak(node) {
// so that the required parentheses end up on their own lines.
const shouldAlwaysAddParens = (node) => node.type === "SequenceExpression";
/*
- `ArrowFunctionExpression`
*/
function printArrowFunction(path, options, print, args = {}) {
/** @type {Doc[]} */
const signatureDocs = [];
@@ -31,6 +31,29 @@ import {
/** @import AstPath from "../../common/ast-path.js" */
/*
- `ArrowFunctionExpression`
- `FunctionDeclaration`
- `FunctionExpression`
- `ObjectMethod`
- `Property`
- `ObjectProperty`
- `ClassMethod`
- `ClassPrivateMethod`
- `MethodDefinition
- `TSFunctionType` (TypeScript)
- `TSCallSignatureDeclaration` (TypeScript)
- `TSConstructorType` (TypeScript)
- `TSConstructSignatureDeclaration` (TypeScript)
- `TSDeclareFunction`(TypeScript)
- `TSAbstractMethodDefinition` (TypeScript)
- `TSDeclareMethod` (TypeScript)
- `TSEmptyBodyFunctionExpression` (TypeScript)
- `TSMethodSignature` (TypeScript)
- `FunctionTypeAnnotation` (Flow)
- `HookDeclaration` (Flow)
- `HookTypeAnnotation` (Flow)
*/
function printFunctionParameters(
path,
options,
+16 -2
View File
@@ -34,8 +34,8 @@ const isMethodValue = ({ node, key, parent }) =>
(parent.type === "Property" && isMethod(parent)));
/*
- "FunctionDeclaration"
- "FunctionExpression"
- `FunctionDeclaration`
- `FunctionExpression`
- `TSDeclareFunction`(TypeScript)
*/
function printFunction(path, options, print, args) {
@@ -100,6 +100,9 @@ function printFunction(path, options, print, args) {
}
/*
- `FunctionDeclaration`
- `FunctionExpression`
- `TSDeclareFunction`(TypeScript)
- `ObjectMethod`
- `Property`
- `ObjectProperty`
@@ -139,6 +142,17 @@ function printMethod(path, options, print) {
return parts;
}
/*
- `ObjectMethod`
- `Property`
- `ObjectProperty`
- `ClassMethod`
- `ClassPrivateMethod`
- `MethodDefinition
- `TSAbstractMethodDefinition` (TypeScript)
- `TSDeclareMethod` (TypeScript)
- `TSEmptyBodyFunctionExpression` (TypeScript)
*/
function printMethodValue(path, options, print) {
const { node } = path;
const parametersDoc = printFunctionParameters(path, options, print);
+1 -1
View File
@@ -12,7 +12,7 @@ import { printDeclareToken } from "./miscellaneous.js";
*/
/*
- "HookDeclaration"
- `HookDeclaration` (Flow)
*/
function printHook(path, options, print) {
const { node } = path;
@@ -10,6 +10,9 @@ import {
} from "./miscellaneous.js";
import { printTypeAnnotationProperty } from "./type-annotation.js";
/*
- `TSMethodSignature` (TypeScript)
*/
function printMethodSignature(path, options, print) {
const { node } = path;
const parts = [];