How to use the classProperty function from babel-types

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

39
40
41
42
43
44
45
46
47
48
properties.forEach(property => {
  const typeAnnotation = property.get('typeAnnotation');
  const { name } = property.node.key;
  const objectExpression = convertWithHandler(typeAnnotation, property);
  const propsClassProperty = Object.assign(
    t.classProperty(t.identifier(name), objectExpression),
    { static: true }
  );
  property.insertAfter(propsClassProperty);
});
fork icon1
star icon9
watch icon2

374
375
376
377
378
379
380
381
382
383
if (tabBar) {
    if (!hasComponentWillMount) {
        node.body.push(t.classMethod('method', t.identifier('componentWillMount'), [], t.blockStatement([initTabbarApiNode]), false, false));
    }
    if (!stateNode) {
        stateNode = t.classProperty(t.identifier('state'), t.objectExpression([]));
        node.body.unshift(stateNode);
    }
    if (t.isObjectExpression(stateNode.value)) {
        stateNode.value.properties.push(t.objectProperty(t.identifier(constants_2.tabBarConfigName), tabBar));
fork icon0
star icon0
watch icon0

+ 11 other calls in file

75
76
77
78
79
80
81
82
83
84
85
86
87


        properties.push(t.objectProperty(identifier, val));
    }


    // Babel does't support to create static class property???
    return t.classProperty(t.identifier('static propTypes'), t.objectExpression(properties), null, []);
};


exports.genDefaultProps = function genDefaultProps (props) {
    const properties = [];
fork icon0
star icon0
watch icon0

318
319
320
321
322
323
324
325
326
327
  astPath.pushContainer('body', t.classMethod(
    'method', t.identifier('componentWillMount'), [],
    t.blockStatement([]), false, false))
}
if (!hasState) {
  astPath.unshiftContainer('body', t.classProperty(
    t.identifier('state'),
    t.objectExpression([])
  ))
}
fork icon0
star icon0
watch icon0

+ 7 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

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