How to use the @teleporthq/teleport-plugin-common.ParsedASTNode function in @teleporthq/teleport-plugin-common

To help you get started, we’ve selected a few @teleporthq/teleport-plugin-common 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 teleporthq / teleport-code-generators / packages / teleport-plugin-vue-base-component / src / utils.ts View on Github external
break
      default:
        // don't handle anything else
        throw new Error(
          `createVuePropsDefinition encountered a unknown PropDefinition, ${JSON.stringify(
            uidlPropDefinitions[name]
          )}`
        )
    }

    let defaultPropValue = null

    if (defaultValue !== undefined) {
      defaultPropValue =
        type === 'array' || type === 'object'
          ? new ParsedASTNode(
              t.arrowFunctionExpression([], ASTUtils.convertValueToLiteral(defaultValue))
            )
          : defaultValue
    }

    acc[name] = defaultPropValue ? { type: mappedType, default: defaultPropValue } : mappedType
    acc[name] = isRequired ? { required: isRequired, ...acc[name] } : acc[name]

    return acc
  }, {})
}
github teleporthq / teleport-code-generators / packages / teleport-plugin-jsx-proptypes / src / utils.ts View on Github external
(acc: any, key) => {
      const { type, isRequired } = propDefinitions[key]
      const astProp = t.memberExpression(t.identifier(propTypesNames), t.identifier(type))
      const astValue = isRequired
        ? t.memberExpression(astProp, t.identifier('isRequired'))
        : astProp
      acc.values[key] = new ParsedASTNode(astValue)
      acc.count++
      return acc
    },
    { values: {}, count: 0 }
github teleporthq / teleport-code-generators / packages / teleport-plugin-react-jss / src / index.ts View on Github external
jssStyleMap[className] = UIDLUtils.transformDynamicStyles(style, (styleValue) => {
          if (styleValue.content.referenceType === 'prop') {
            return new ParsedASTNode(
              ASTBuilders.createArrowFunctionWithMemberExpression('props', styleValue.content.id)
            )
          }
          throw new Error(
            `Error running transformDynamicStyles in reactJSSComponentStyleChunksPlugin. Unsupported styleValue.content.referenceType value ${styleValue.content.referenceType}`
          )
        })
        ASTUtils.addDynamicAttributeToJSXTag(

@teleporthq/teleport-plugin-common

Common building and modelating functions for ASTs and HASTs

MIT
Latest version published 2 days ago

Package Health Score

82 / 100
Full package analysis

Similar packages