本文整理汇总了TypeScript中@babel/types.isStatement函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isStatement函数的具体用法?TypeScript isStatement怎么用?TypeScript isStatement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isStatement函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getBestComment
export function getBestComment(nodePath: NodePath): string|undefined {
const maybeComment = getAttachedComment(nodePath.node);
if (maybeComment !== undefined) {
return maybeComment;
}
const parent = nodePath.parentPath;
if (parent === undefined) {
return undefined;
}
if (!isStatementWithUniqueStatementChild(parent.node) &&
babel.isStatement(nodePath.node)) {
// Don't walk up above the nearest statement.
return undefined;
}
if (babel.isVariableDeclaration(parent.node) &&
parent.node.declarations.length !== 1) {
// The parent node is multiple declarations. We can't be sure its
// comment applies to us.
return undefined;
}
if (parent.isClassBody() || nodePath.isObjectMember()) {
// don't go above an object or class member.
return undefined;
}
return getBestComment(parent);
}
示例2: getCanonicalStatement
export function getCanonicalStatement(nodePath: NodePath): babel.Statement|
undefined {
const node = nodePath.node;
const parent = nodePath.parentPath;
if ((parent && !isStatementWithUniqueStatementChild(parent.node)) &&
babel.isStatement(node)) {
return node;
}
if (parent != null) {
return getCanonicalStatement(parent);
}
return undefined;
}