How to use the classProperty function from @babel/types

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

56
57
58
59
60
61
62
63
64
65
  fs.unlinkSync(interfaceFile)
}

if (ExportDefaultDeclaration) {
  ExportDefaultDeclaration.declaration.body.body.unshift(
    t.classProperty(
      t.identifier('schema'),
      babelParser.parseExpression(JSON.stringify(schema, null, 2)),
      null,
      null,
fork icon42
star icon91
watch icon8

53
54
55
56
57
58
59
60
61
62
        if (path.node.left.name === 'config' && !t.isExportDefaultDeclaration(parent)) {
            ObjectExpression = path.node.right
        }
    }
})
const ClassProperty = t.classProperty(t.identifier('config'), ObjectExpression)
classBody.push(ClassProperty)
classBody.push(genConstructor(state))
if (Object.keys(state.props).length) {
    classBody.push(genPropTypes(state.props));
fork icon1
star icon2
watch icon1

134
135
136
137
138
139
140
141
142
143
const parent = superClasses ? t.identifier(superClasses.getText()) : null;
const body = this.visitChildren(children[children.length - 1]).map(
  child => {
    switch (child.type) {
      case "ExpressionStatement":
        return t.classProperty(t.identifier(child.expression.name));
      case "FunctionDeclaration":
        const isConstructor = child.id.name === "__init__";
        const methodId = isConstructor ? "constructor" : child.id.name;
        const methodParams = child.params.filter(
fork icon0
star icon1
watch icon0

Other functions in @babel/types

Sorted by popularity

function icon

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