@babel/types APIs
- ObjectExpression
- Expression
- Identifier
- CallExpression
- Node
- ImportDeclaration
- ArrayExpression
- VariableDeclarator
- JSXElement
- File
- JSXAttribute
- ImportSpecifier
- Statement
- ObjectProperty
- JSXExpressionContainer
- JSXMemberExpression
- BlockStatement
- JSXIdentifier
- ObjectPattern
- isIdentifier
- identifier
- stringLiteral
- booleanLiteral
- isObjectProperty
- isMemberExpression
- StringLiteral
- ArrowFunctionExpression
- VariableDeclaration
- ImportDefaultSpecifier
- FunctionExpression
- jsxAttribute
- jsxIdentifier
- JSXFragment
- JSXSpreadChild
- JSXText
- expressionStatement
- Program
- BooleanLiteral
- JSXOpeningElement
- MemberExpression
- FunctionDeclaration
- PatternLike
- RestElement
- LVal
- SourceLocation
- SpreadElement
- file
- Comment
- isCallExpression
- isVariableDeclarator
- isLogicalExpression
- isReturnStatement
- conditionalExpression
- isAssignmentExpression
- isNumericLiteral
- arrayPattern
- jsxElement
- isStringLiteral
- isBooleanLiteral
- jsxExpressionContainer
- isExpression
- jsxOpeningElement
- jsxMemberExpression
- isObjectExpression
- jsxClosingElement
- jsxText
- isArrayPattern
- isExpressionStatement
- isFunctionExpression
- ExpressionStatement
- ImportNamespaceSpecifier
- ReturnStatement
- JSXNamespacedName
- JSX
- LogicalExpression
- AssignmentPattern
- objectProperty
- objectExpression
- arrayExpression
- objectPattern
- nullLiteral
- numericLiteral
- isAssignmentPattern
- isRestElement
- importDeclaration
- importSpecifier
- isTemplateLiteral
- callExpression
- isImportSpecifier
- isArrowFunctionExpression
- isTSTypeReference
- isTypeAnnotation
- isObjectPattern
- BinaryExpression
- UnaryExpression
- ArrayPattern
- CatchClause
- DoWhileStatement
- ForInStatement
- ForOfStatement
- ForStatement
- NewExpression
- SwitchCase
- TemplateLiteral
- WhileStatement
- program
- isJSXIdentifier
- isJSXMemberExpression
- ClassDeclaration
- DebuggerStatement
- Declaration
- ExportDefaultDeclaration
- ExportNamedDeclaration
- ExportSpecifier
- NumericLiteral
- ObjectMethod
- Pattern
- TSDeclareFunction
- ExportDeclaration
- AssignmentExpression
- JSXEmptyExpression
- JSXSpreadAttribute
- isTSModuleDeclaration
- CommentBlock
- CommentLine
- InterpreterDirective
- addComments
- removeComments
Other Related APIs
- lodash#cloneDeep
- @babel/types#Expression
- @babel/types#JSXElement
- @babel/types#ImportDeclaration
- @babel/types#JSXAttribute
- @babel/types#JSXExpressionContainer
- @babel/types#Comment
- @babel/types#JSXIdentifier
- @babel/types#JSXFragment
- @babel/types#JSXSpreadChild
- @babel/types#JSXText
- @babel/types#ReturnStatement
- @babel/types#JSXEmptyExpression
- @babel/types#JSXNamespacedName
- @babel/types#JSXSpreadAttribute
- @babel/traverse#Node
@babel/types#AssignmentExpression TypeScript Examples
The following examples show how to use
@babel/types#AssignmentExpression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From plasmic with MIT License | 6 votes |
tryExtractPlasmicJsxExpression = (
node: AssignmentExpression | ReturnStatement
): VersionedJsx | undefined => {
for (const c of node.leadingComments || []) {
const m = c.value.match(/^\s*plasmic-managed-jsx\/(\d+)\s*$/);
if (m) {
if (node.type === "AssignmentExpression") {
return { jsx: node.right, identifyingComment: c, revision: +m[1] };
} else {
return {
jsx: ensure(node.argument),
identifyingComment: c,
revision: +m[1],
};
}
}
}
return undefined;
}
Example #2
Source File: index.ts From plasmic with MIT License | 6 votes |
tryParseComponentSkeletonFile = (
fileContent: string
): PlasmicComponentSkeletonFile | undefined => {
const file = parser.parse(fileContent, {
strictMode: true,
sourceType: "module",
plugins: ["jsx", "typescript"],
});
let jsx: VersionedJsx | undefined = undefined;
traverse(file, {
noScope: true,
AssignmentExpression: function (path) {
jsx = tryExtractPlasmicJsxExpression(path.node);
if (jsx) {
path.stop();
}
},
ReturnStatement: function (path) {
jsx = tryExtractPlasmicJsxExpression(path.node);
if (jsx) {
path.stop();
}
},
});
// typescript treat jsx as never type... why?
jsx = jsx as VersionedJsx | undefined;
return jsx ? { ...jsx, file } : undefined;
}