本文整理汇总了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;
}