How to use the isFunctionDeclaration function from @babel/types

Find comprehensive JavaScript @babel/types.isFunctionDeclaration code examples handpicked from public code repositorys.

84
85
86
87
88
89
90
91
92
93
isComponent = isComponent || (
  t.isArrowFunctionExpression(node)
  || t.isFunctionExpression(node)
  || t.isClassMethod(node)
  || t.isObjectMethod(node)
  || t.isFunctionDeclaration(node)
)

if (!componentNode && isComponent) {
  componentNode = node
fork icon10
star icon44
watch icon10

+ 17 other calls in file

143
144
145
146
147
148
149
150
151
152
let local;

if (t.isIdentifier(declaration)) {
  local = declaration.name;
} else if (
  t.isFunctionDeclaration(declaration) ||
  t.isClassDeclaration(declaration)
) {
  if (declaration.id) {
    local = declaration.id.name;
fork icon6
star icon34
watch icon0

+ 7 other calls in file

46
47
48
49
50
51
52
53
54
55
},

ExportDefaultDeclaration: (path) => {
  const { declaration } = path.node;
  // insert `export default ${identifier}(module)(xxx)`
  if (t.isClassDeclaration(declaration) || t.isFunctionDeclaration(declaration)) {
    if (t.isIdentifier(declaration.id)) {
      path.replaceWith(declaration);
      insertNodes.push(
        t.ExportDefaultDeclaration(
fork icon1
star icon5
watch icon0

100
101
102
103
104
105
106
107
108
109
  types.isBlockStatement(node) ||
  types.isBlock(node)
) {
  return node.body.some(statement => hasBinding(statement, name));
} else if (
  types.isFunctionDeclaration(node) ||
  types.isFunctionExpression(node) ||
  types.isArrowFunctionExpression(node)
) {
  return (
fork icon0
star icon2
watch icon2

+ 3 other calls in file

201
202
203
204
205
206
207
208
209
210
  scope
} = path;
if (t.isExportAllDeclaration(node)) return;
const declar = node.declaration;

if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
  const id = declar.id;
  if (!id) return;
  const binding = scope.getBinding(id.name);
  if (binding) binding.reference(path);
fork icon0
star icon1
watch icon1

+ 16 other calls in file

516
517
518
519
520
521
522
523
524
525
	}
},
FunctionDeclaration(path)
{
	let {body} = path.node.body;
	if (body.length == 2 && types.isFunctionDeclaration(body[0]) &&
	   types.isTryStatement(body[1]))
	{
		let sourceCode = path.toString();
		if (sourceCode.includes("constructor") &&
fork icon0
star icon0
watch icon1

+ 71 other calls in file

15
16
17
18
19
20
21
22
23
24
 * 函数表达式
 * 方法
 * 则返回 true
 * **/
const isAsyncFuncNode = node =>
    t.isFunctionDeclaration(node, {
        async: true
    }) ||
    t.isArrowFunctionExpression(node, {
        async: true
fork icon0
star icon0
watch icon0

513
514
515
516
517
518
519
520
521
522
var componentBlock = getParentComponentOrUseFuncBlock(path);
var childToPut = types.cloneNode(transformedPath.node); // console.log(path.parent);
// console.log(transformedPath.node);
// if (typeExp === "DECLARE") {

if (typeExp === "DECLARE" && types.isFunctionDeclaration(path.node)) {
  childToPut = types.callExpression(types.identifier(path.node.id.name), initAnnotationParser(immidateTopComment.value));
}

if (typeExp === "DECLARE" && types.isVariableDeclaration(path.node) && (types.isArrowFunctionExpression(path.node.declarations[0].init) || types.isFunctionExpression(path.node.declarations[0].init))) {
fork icon0
star icon0
watch icon1

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)