本文整理汇总了TypeScript中op/Op.orThrow函数的典型用法代码示例。如果您正苦于以下问题:TypeScript orThrow函数的具体用法?TypeScript orThrow怎么用?TypeScript orThrow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了orThrow函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: verifyPoly
export default function verifyPoly({value}: Poly): void {
if (value instanceof FunBlock)
// value always has opDeclareThis
makeUseOptional(orThrow(value.opDeclareThis))
value.args.forEach(makeUseOptional)
opEach(value.opRestArg, makeUseOptional)
verifyMethodValue(value)
// name set by AssignSingle
}
示例2: verifySuperCall
export function verifySuperCall(_: SuperCall, sk: SK): void {
const {loc, args} = _
const meth = orThrow(method, () => fail(loc, _ => _.superNeedsMethod))
results.superCallToMethod.set(_, meth)
if (meth instanceof Constructor) {
check(sk === SK.Do, loc, _ => _.superMustBeStatement)
results.constructorToSuper.set(meth, _)
}
verifyEachVal(args)
}
示例3: verifyLocalAccess
export function verifyLocalAccess(_: LocalAccess): void {
const {loc, name} = _
const declare = locals.get(name)
if (declare === undefined) {
const builtinPath = orThrow(
compileOptions.opBuiltinPath(name),
() => missingLocalFail(loc, name))
results.accessBuiltin(name, builtinPath)
} else {
results.localAccessToDeclare.set(_, declare)
setDeclareAccessed(declare, _)
}
}
示例4: verifyConstructor
function verifyConstructor(_: Constructor, classHasSuper: boolean): void {
const {loc, fun, memberArgs} = _
// Constructor function always has opDeclareThis.
makeUseOptional(orThrow(fun.opDeclareThis))
withMethod(_, () => verifyVal(fun))
const superCall = results.constructorToSuper.get(_)
if (classHasSuper)
check(superCall !== undefined, loc, _ => _.superNeeded)
else
check(superCall === undefined, () => superCall.loc, _ => _.superForbidden)
for (const arg of memberArgs)
setDeclareAccessed(arg, _)
}
示例5: verifyBreak
export function verifyBreak(_: Break): void {
const {opValue, loc} = _
verifyOpVal(opValue)
const {loop, sk: loopSK} = orThrow(opLoop, () => fail(loc, _ => _.misplacedBreak))
if (loop instanceof For)
if (loopSK === SK.Do)
check(opValue === null, loc, _ => _.breakCantHaveValue)
else
check(opValue !== null, loc, _ => _.breakNeedsValue)
else {
// (ForAsync isn't really a loop)
assert(loop instanceof ForBag)
check(opValue === null, this.loc, _ => _.breakValInForBag)
}
if (isInSwitch) {
results.loopsNeedingLabel.add(loop)
results.breaksInSwitch.add(_)
}
}
示例6: doit
doit(() => {
// fun always has opDeclareThis
makeUseOptional(orThrow(fun.opDeclareThis))
verifyFunBlock(fun)
})
示例7: beforeAndBlock
export function beforeAndBlock(tokens: Tokens): [Tokens, Lines] {
const [before, opBlock] = beforeAndOpBlock(tokens)
const block = orThrow(opBlock, () => fail(tokens.loc, _ => _.expectedBlock))
return [before, block]
}