当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript builders.assignmentExpression方法代码示例

本文整理汇总了TypeScript中ast-types.builders.assignmentExpression方法的典型用法代码示例。如果您正苦于以下问题:TypeScript builders.assignmentExpression方法的具体用法?TypeScript builders.assignmentExpression怎么用?TypeScript builders.assignmentExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ast-types.builders的用法示例。


在下文中一共展示了builders.assignmentExpression方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: moduleExportsExpression

 .map(specifier =>
   b.expressionStatement(
     b.assignmentExpression(
       '=',
       moduleExportsExpression(specifier.exported.name),
       b.literal(specifier.local.name)
     )
   )
开发者ID:ZauberNerd,项目名称:paeckchen,代码行数:8,代码来源:es6-export.ts

示例2: exportAllKeys

/**
 * Object.keys(identifier).forEach(function(key) {
 *   module.exports[key] = identifier.exports[key];
 * });
 */
function exportAllKeys(identifier: ESTree.Identifier): ESTree.ExpressionStatement {
  return b.expressionStatement(
    b.callExpression(
      b.memberExpression(
        b.callExpression(
          b.memberExpression(
            b.identifier('Object'),
            b.identifier('keys'),
            false
          ),
          [
            b.memberExpression(
              identifier,
              b.identifier('exports'),
              false
            )
          ]
        ),
        b.identifier('forEach'),
        false
      ),
      [
        b.functionExpression(
          null,
          [
            b.identifier('key')
          ],
          b.blockStatement([
            b.expressionStatement(
              b.assignmentExpression(
                '=',
                b.memberExpression(
                  b.memberExpression(
                    b.identifier('module'),
                    b.identifier('exports'),
                    false
                  ),
                  b.identifier('key'),
                  true
                ),
                b.memberExpression(
                  b.memberExpression(
                    identifier,
                    b.identifier('exports'),
                    false
                  ),
                  b.identifier('key'),
                  true
                )
              )
            )
          ])
        )
      ]
    )
  );
}
开发者ID:ZauberNerd,项目名称:paeckchen,代码行数:62,代码来源:es6-export.ts

示例3: function

    visitExportDefaultDeclaration: function(path: IPath<ESTree.ExportDefaultDeclaration>): boolean {
      const declaration = path.node.declaration;

      if (n.Identifier.check(declaration)) {
        // e.g. export default a;
        path.replace(
          b.expressionStatement(
            b.assignmentExpression(
              '=',
              moduleExportsExpression('default'),
              b.identifier(declaration.name)
            )
          )
        );
      } else if (n.FunctionDeclaration.check(declaration) || n.ClassDeclaration.check(declaration)) {
        // e.g. export default class {}
        path.replace(declaration);
        path.insertAfter(
          b.expressionStatement(
            b.assignmentExpression(
              '=',
              moduleExportsExpression('default'),
              b.identifier(declaration.id.name)
            )
          )
        );
      } else if (n.FunctionExpression.check(declaration)) {
        // e.g. export default function() {}
        path.replace(
          b.expressionStatement(
            b.assignmentExpression(
              '=',
              moduleExportsExpression('default'),
              declaration
            )
          )
        );
      }
      return false;
    }
开发者ID:ZauberNerd,项目名称:paeckchen,代码行数:40,代码来源:es6-export.ts

示例4: wrapExternalModule

function wrapExternalModule(modulePath: string, context: IPaeckchenContext): ESTree.Program {
  const external = context.config.externals[modulePath] === false
    ? b.objectExpression([])
    : b.identifier(context.config.externals[modulePath] as string);
  return b.program([
    b.expressionStatement(
      b.assignmentExpression(
        '=',
        b.memberExpression(
          b.identifier('module'),
          b.identifier('exports'),
          false
        ),
        external
      )
    )
  ]);
}
开发者ID:ZauberNerd,项目名称:paeckchen,代码行数:18,代码来源:modules.ts


注:本文中的ast-types.builders.assignmentExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。