本文整理匯總了TypeScript中basic/base.fail函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fail函數的具體用法?TypeScript fail怎麽用?TypeScript fail使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了fail函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: dareParseNumberAt
export function dareParseNumberAt(args: string[], at: number, failure: string): number {
const value = args[at];
if (value === undefined) return fail(failure + ' ' + parseNumberFailure);
const parsed = mightParseInteger(value);
if (thereIsNo(parsed)) return fail(failure + ' ' + parseNumberFailure + ' ' + whyNo(parsed));
return parsed;
}
示例2: verifyIdentifier
function verifyIdentifier(node: ts.Identifier, checker: ts.TypeChecker): Issue | void {
if (node.parent === undefined) return;
if (isVariableDeclaration(node.parent) && node.parent.initializer === node) return;
const symbol = checker.getSymbolAtLocation(node);
if (symbol === undefined) return fail('Unable to get symbol.');
const declared = symbol.getDeclarations();
if (declared === undefined) return fail('There is no declaration.');
if (declared.length < 1) return fail('There are ' + declared.length + ' declarations.');
const declaration = declared[0];
if (isVariableDeclaration(declaration) && hasConstModifier(declaration)) {
return issueFrom(node, 'const returned', 'no-const-lambdas');
}
}
示例3: haveCompiled
export function betterBeNoIssues<r>(tried: TriedCompiling, haveCompiled: (compiled: Compiled) => r): r {
if (bt.isLuck(tried)) {
return haveCompiled(tried.luck);
} else {
const issues = ba.fromList(tried.fuck);
ba.forEach(issues, issue => {
console.warn(formatDiagnostic(issue));
});
return bb.fail('Stopped due to detected issues.');
}
}
示例4: toUnexpectedState
export function toUnexpectedState(_: never): never {
return fail('Unhandled state.');
}
示例5: willBeServing
willBeServing(async () => {
return fail('!!!');
});
示例6: dare
dare(failure: string, format: (fail: b) => string): a {
return isLuck(this.value) ? this.value.luck : fail(failure + ' ' + format(this.value.fuck));
}
示例7: dareAt
export function dareAt(args: string[], at: number, failure: string): string {
const value = args[at];
if (value === undefined) return fail(failure);
return value;
}