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