本文整理汇总了TypeScript中esast-create-util/lib/util.member函数的典型用法代码示例。如果您正苦于以下问题:TypeScript member函数的具体用法?TypeScript member怎么用?TypeScript member使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了member函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getMember
function getMember(
object: Expression,
gotName: string,
isLazy: boolean,
isModule: boolean): Expression {
return isLazy ?
msCall('lazyProp', object, new LiteralString(gotName)) :
isModule && compileOptions.checks ?
msCall('get', object, new LiteralString(gotName)) :
member(object, gotName)
}
示例2: transpileMember
export function transpileMember(object: Expression, memberName: MemberName): MemberExpression {
return typeof memberName === 'string' ?
member(object, memberName) :
new MemberExpressionComputed(object, transpileVal(memberName))
}
示例3: transpileBlock
const body = () => transpileBlock(block, {lead, opReturnType})
const argAsts = args.map(transpileLocalDeclare)
const id = opMap(verifyResults.opName(_), identifier)
switch (kind) {
case Funs.Async: {
const plainBody = transpileBlock(block, {opReturnType})
const genFunc = new FunctionExpression(null, [], plainBody, {generator: true})
const ret = new ReturnStatement(msCall('async', genFunc))
return new FunctionExpression(id, argAsts, new BlockStatement(cat(lead, ret)))
}
case Funs.Generator:
return new FunctionExpression(id, argAsts, body(), {generator: true})
case Funs.Plain:
// TODO:ES6 Should be able to use rest args in arrow function
return id === null && opDeclareThis === null && opDeclareRest === null ?
new ArrowFunctionExpression(argAsts, body()) :
new FunctionExpression(id, argAsts, body())
default:
throw new Error(String(kind))
}
})
}
const arraySliceCall = member(member(new ArrayExpression([]), 'slice'), 'call')
const idArguments = new Identifier('arguments')
function focusFun(value: Expression): Expression {
return new ArrowFunctionExpression([idFocus], value)
}
示例4: msMember
export function msMember(name: string): Expression {
return member(idMs, name)
}
示例5: msCall
export function msCall(name: string, ...args: Array<Expression>): Expression {
return new CallExpression(member(idMs, name), args)
}
示例6: Identifier
import Identifier from 'esast/lib/Identifier'
import {LiteralNull, LiteralNumber} from 'esast/lib/Literal'
import ObjectExpression from 'esast/lib/ObjectExpression'
import {ExpressionStatement, ReturnStatement} from 'esast/lib/Statement'
import {member} from 'esast-create-util/lib/util'
export const
esGlobalError = new Identifier('Error'),
idBuilt = new Identifier('built'),
idError = new Identifier('Error'),
idFocus = new Identifier('_'),
idLexicalThis = new Identifier('_this'),
litNull = new LiteralNull(),
litUndefined = new UnaryExpression('void', new LiteralNumber(0)),
returnFocus = new ReturnStatement(idFocus),
esThis = new ThisExpression(),
declareBuiltBag = new VariableDeclarationLet(
[new VariableDeclarator(idBuilt, new ArrayExpression([]))]),
declareBuiltMap = new VariableDeclarationLet([
new VariableDeclarator(
idBuilt,
new NewExpression(member(new Identifier('global'), 'Map'), []))]),
declareBuiltObj = new VariableDeclarationLet(
[new VariableDeclarator(idBuilt, new ObjectExpression([]))]),
declareLexicalThis = new VariableDeclarationLet(
[new VariableDeclarator(idLexicalThis, esThis)]),
letLexicalThis = new VariableDeclarationLet([new VariableDeclarator(idLexicalThis)]),
setLexicalThis = new ExpressionStatement(new AssignmentExpression('=', idLexicalThis, esThis))