How to use the babel-types.objectProperty function in babel-types

To help you get started, we’ve selected a few babel-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Canner / canner / packages / canner-schema-loader / src / index.js View on Github external
Object.keys(canner).forEach(key => {
    if (key === 'cannerDataType') {
      if (type !== 'json') { // the component of json type is same as object, but the type can't be changed
        properties.push(t.objectProperty(t.stringLiteral('type'), t.stringLiteral(canner[key])));
      }
    } else if (typeof canner[key] === 'string'){
      properties.push(t.objectProperty(t.stringLiteral(key), t.stringLiteral(canner[key])));
    } else if (typeof canner[key] === 'number'){
      properties.push(t.objectProperty(t.stringLiteral(key), t.numberLiteral(canner[key])));
    } else if (typeof canner[key] === 'boolean'){
      properties.push(t.objectProperty(t.stringLiteral(key), t.booleanLiteral(canner[key])));
    } else {
      throw new Error(`Not support the type of object and array config in canner yet, but got key: ${key} with value: ${canner[key]}.`);
    }
  });
  return properties;
github Canner / canner / packages / canner-schema-loader / src / index.js View on Github external
Object.keys(canner).forEach(key => {
    if (key === 'cannerDataType') {
      if (type !== 'json') { // the component of json type is same as object, but the type can't be changed
        properties.push(t.objectProperty(t.stringLiteral('type'), t.stringLiteral(canner[key])));
      }
    } else if (typeof canner[key] === 'string'){
      properties.push(t.objectProperty(t.stringLiteral(key), t.stringLiteral(canner[key])));
    } else if (typeof canner[key] === 'number'){
      properties.push(t.objectProperty(t.stringLiteral(key), t.numberLiteral(canner[key])));
    } else if (typeof canner[key] === 'boolean'){
      properties.push(t.objectProperty(t.stringLiteral(key), t.booleanLiteral(canner[key])));
    } else {
      throw new Error(`Not support the type of object and array config in canner yet, but got key: ${key} with value: ${canner[key]}.`);
    }
  });
  return properties;
github Tencent / omi / packages / omip / my-app / scripts / taro-cli / src / weapp.js View on Github external
specifiers.forEach(s => {
          if (t.isImportDefaultSpecifier(s)) {
            defaultDeclator = [t.variableDeclarator(t.identifier(s.local.name), t.objectExpression(objectPropperties))]
          } else {
            importItems.push(t.objectProperty(t.identifier(s.local.name), t.identifier(s.local.name)))
          }
        })
        normalDeclator = [t.variableDeclarator(t.objectPattern(importItems), t.objectExpression(objectPropperties))]
github alibaba / ice / tools / iceworks / app / main / scaffolder / lib / appendRouteV4.js View on Github external
function routeNode({ path, layout = '', component }) {
  if (layout) {
    return t.objectExpression([
      t.objectProperty(t.stringLiteral('path'), t.stringLiteral(path)),
      t.objectProperty(
        t.stringLiteral('layout'),
        t.identifier(upperCamelCase(layout))
      ),
      t.objectProperty(t.stringLiteral('component'), t.identifier(component)),
    ]);
  }
  return t.objectExpression([
    t.objectProperty(t.stringLiteral('path'), t.stringLiteral(path)),
    t.objectProperty(t.stringLiteral('component'), t.identifier(component)),
  ]);
}
github groupon / swagql / lib / generator / type-map.js View on Github external
t.objectExpression([
        t.objectProperty(
          t.identifier('type'),
          typeMap.ref(
            props[propKey],
            requiredProps.includes(propKey),
            type,
            propKey
          )
        ),
      ])
    );
  });
  if (!fields.length) {
    fields.push(
      t.objectProperty(
        t.identifier('unknownShape'),
        t.objectExpression([
          t.objectProperty(
            t.identifier('type'),
            typeMap.ref({ type: 'boolean' }, false)
          ),
        ])
      )
    );
  }
  const node = t.variableDeclaration('const', [
    t.variableDeclarator(
      t.identifier(graphqlName),
      t.newExpression(typeMap.objectTypeRef, [
        t.objectExpression([
          t.objectProperty(t.identifier('name'), t.stringLiteral(graphqlName)),
github Tencent / omi / packages / cax-omip / scripts / taro-cli / src / h5.js View on Github external
exit (astPath) {
        const node = astPath.node
        const key = node.key
        const value = node.value
        if (key.name !== 'state' || !t.isObjectExpression(value)) return
        astPath.node.value.properties.push(t.objectProperty(
          t.identifier(tabBarConfigName),
          tabBar
        ))
      }
    },
github groupon / swagql / lib / generator / type-map.js View on Github external
const fields = Object.keys(props).map(propKey => {
    return t.objectProperty(
      t.identifier(propKey),
      t.objectExpression([
        t.objectProperty(
          t.identifier('type'),
          typeMap.ref(
            props[propKey],
            requiredProps.includes(propKey),
            type,
            propKey
          )
        ),
      ])
    );
  });
  if (!fields.length) {
github Tencent / omi / packages / omip / taro-cli / src / weapp.js View on Github external
specifiers.forEach(s => {
          if (t.isImportDefaultSpecifier(s)) {
            defaultDeclator = [t.variableDeclarator(t.identifier(s.local.name), t.objectExpression(objectPropperties))]
          } else {
            importItems.push(t.objectProperty(t.identifier(s.local.name), t.identifier(s.local.name)))
          }
        })
        normalDeclator = [t.variableDeclarator(t.objectPattern(importItems), t.objectExpression(objectPropperties))]
github salesforce / lwc / packages / raptor-template-compiler / src / codegen / index.ts View on Github external
t.identifier(TEMPLATE_PARAMS.CONTEXT),
                            memorizedId,
                        ),
                        handler,
                    );

                    handler = t.logicalExpression(
                        '||',
                        memorizedId,
                        memorization,
                    );
                }

                return handler;
            });
            data.push(t.objectProperty(t.identifier('on'), onObj));
        }

        return t.objectExpression(data);
    }
github trivago / melody / packages / melody-compiler / src / convert / blocks.js View on Github external
UseStatement(path) {
        const useStmt = path.node,
            source = useStmt.source;
        if (useStmt.aliases.length) {
            const members = [];
            for (const { name, alias } of (useStmt.aliases: Array)) {
                const aliasName = toBlockName(alias.name),
                    nameName = toBlockName(name.name);
                this.addImportFrom(source.value, aliasName, nameName);
                members.push(
                    t.objectProperty(
                        t.identifier(aliasName),
                        t.identifier(aliasName),
                        false,
                        true
                    )
                );
            }
            const inheritBlocks = t.expressionStatement(
                t.callExpression(
                    t.memberExpression(
                        t.identifier('Object'),
                        t.identifier('assign')
                    ),
                    [
                        t.identifier(this.templateVariableName),
                        t.objectExpression(members),