How to use the isReturnStatement function from babel-types

Find comprehensive JavaScript babel-types.isReturnStatement code examples handpicked from public code repositorys.

70
71
72
73
74
75
76
77
78
    const node = path.node;

    // only matches inside directives
    // return { .. controller: function($scope, $timeout), ...}

    return limit("directive", t.isReturnStatement(node) &&
        node.argument && t.isObjectExpression(node.argument) &&
        matchProp("controller", (path.get && path.get("argument.properties") || node.argument.properties)));
}
fork icon156
star icon0
watch icon2

+ 5 other calls in file

117
118
119
120
121
122
123
124
125
126
  node = props.filter(p => t.isObjectProperty(p) && p.key.name === 'data').shift()
  if (node) {
    throw new Error('sfd-editor:data should be a function, got an object ')
  }
}
const retSta = node.body.body.filter(n => t.isReturnStatement(n)).shift()
if (!retSta || retSta.argument === null || !t.isObjectExpression(retSta.argument)) {
  throw new Error('sfc-editor:data function did not return an object!')
}
const retObjProps = retSta.argument.properties
fork icon1
star icon3
watch icon2

+ 11 other calls in file

27
28
29
30
31
32
33
34
35
36

//  const expr = body[0];
//  console.log(body);

switch (true) {
    case t.isReturnStatement(expr):
        var needWrap = expr.argument.type !== 'JSXElement';
        var jsx = generate(expr.argument).code;
        var jsxAst = babel.transform(jsx, {
            babelrc: false,
fork icon330
star icon0
watch icon0

55
56
57
58
59
60
61
62
63
    // Array
    this.state.props[this.childKey].value = body;
} else if (t.isBlockStatement(body)) {
    // Object/Block array
    const childNodes = body.body;
    if (childNodes.length === 1 && t.isReturnStatement(childNodes[0])) {
        this.state.props[this.childKey].value = childNodes[0].argument;
    }
}
fork icon65
star icon411
watch icon8

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)