本文整理匯總了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)
)
)
示例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
)
)
)
])
)
]
)
);
}
示例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;
}
示例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
)
)
]);
}