當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript types.isClassDeclaration函數代碼示例

本文整理匯總了TypeScript中@babel/types.isClassDeclaration函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isClassDeclaration函數的具體用法?TypeScript isClassDeclaration怎麽用?TypeScript isClassDeclaration使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isClassDeclaration函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getPolymerProperties

export function getPolymerProperties(
    node: babel.Node, document: JavaScriptDocument): ScannedPolymerProperty[] {
  if (!babel.isClassDeclaration(node) && !babel.isClassExpression(node)) {
    return [];
  }
  const propertiesNode = getStaticGetterValue(node, 'properties');
  return propertiesNode ? analyzeProperties(propertiesNode, document) : [];
}
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:8,代碼來源:polymer2-config.ts

示例2: _getMethods

function* _getMethods(node: babel.Node) {
  if (!babel.isClassDeclaration(node) && !babel.isClassExpression(node)) {
    return;
  }
  for (const statement of node.body.body) {
    if (babel.isClassMethod(statement) && statement.kind === 'method') {
      yield statement;
    }
  }
}
開發者ID:Polymer,項目名稱:tools,代碼行數:10,代碼來源:esutil.ts

示例3: process

export default function process(source: string, ast: t.File): Changes {
  const tokens: Array<Token> = ast.tokens;
  const insertions: Array<Insertion> = [];
  const removals: Array<Removal> = [];

  traverse(ast, {
    VariableDeclaration(path: NodePath<t.VariableDeclaration>): void {
      const { node, parent } = path;
      const isForInit = (
        (t.isForStatement(parent)  && parent.init === node) ||
        ((t.isForInStatement(parent) || t.isForOfStatement(parent)) && parent.left === node)
      );

      if (!isForInit) {
        checkForSemicolon(node);
      }
    },

    ExpressionStatement(path: NodePath<t.ExpressionStatement>): void {
      checkForSemicolon(path.node);
    },

    ReturnStatement(path: NodePath<t.ReturnStatement>): void {
      checkForSemicolon(path.node);
    },

    ThrowStatement(path: NodePath<t.ThrowStatement>): void {
      checkForSemicolon(path.node);
    },

    DoWhileStatement(path: NodePath<t.DoWhileStatement>): void {
      checkForSemicolon(path.node);
    },

    DebuggerStatement(path: NodePath<t.DebuggerStatement>): void {
      checkForSemicolon(path.node);
    },

    BreakStatement(path: NodePath<t.BreakStatement>): void {
      checkForSemicolon(path.node);
    },

    ContinueStatement(path: NodePath<t.ContinueStatement>): void {
      checkForSemicolon(path.node);
    },

    ImportDeclaration(path: NodePath<t.ImportDeclaration>): void {
      checkForSemicolon(path.node);
    },

    ExportAllDeclaration(path: NodePath<t.ExportAllDeclaration>): void {
      checkForSemicolon(path.node);
    },

    ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>): void {
      if (!path.node.declaration) {
        checkForSemicolon(path.node);
      }
    },

    ExportDefaultDeclaration(path: NodePath<t.ExportDefaultDeclaration>): void {
      const { node } = path;
      const { declaration } = node;

      if (t.isClassDeclaration(declaration) || t.isFunctionDeclaration(declaration)) {
        if (!declaration.id) {
          checkForSemicolon(node);
        }
      } else {
        checkForSemicolon(node);
      }
    },

    EmptyStatement(path: NodePath<t.EmptyStatement>): void {
      const { node, parent } = path;

      if (
        !t.isForStatement(parent) &&
        !t.isForOfStatement(parent) &&
        !t.isForInStatement(parent) &&
        !t.isWhileStatement(parent) &&
        !t.isDoWhileStatement(parent)
      ) {
        remove(startOfNode(node), endOfNode(node));
      }
    },

    ClassBody(path: NodePath<t.ClassBody>): void {
      checkClassBodyForSemicolon(tokenAfterToken(firstTokenOfNode(path.node)));
    },

    ClassMethod(path: NodePath<t.ClassMethod>): void {
      checkClassBodyForSemicolon(tokenAfterToken(lastTokenOfNode(path.node)));
    }
  });

  return { insertions, removals };

  /**
   * Checks a node to see if it's followed by a semicolon.
//.........這裏部分代碼省略.........
開發者ID:eventualbuddha,項目名稱:automatic-semicolon-insertion,代碼行數:101,代碼來源:index.ts


注:本文中的@babel/types.isClassDeclaration函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。