當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript base.fail函數代碼示例

本文整理匯總了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;
}
開發者ID:aleksey-bykov,項目名稱:commandlining,代碼行數:7,代碼來源:primitive.ts

示例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');
    }
}
開發者ID:aleksey-bykov,項目名稱:rules,代碼行數:14,代碼來源:rule.ts

示例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.');
    }
}
開發者ID:aleksey-bykov,項目名稱:linting,代碼行數:14,代碼來源:compiling-assertions.ts

示例4: toUnexpectedState

export function toUnexpectedState(_: never): never {
    return fail('Unhandled state.');
}
開發者ID:aleksey-bykov,項目名稱:commandlining,代碼行數:3,代碼來源:parsing.ts

示例5: willBeServing

willBeServing(async () => {
    return fail('!!!');
});
開發者ID:zpdDG4gta8XKpMCd,項目名稱:wh3,代碼行數:3,代碼來源:run.ts

示例6: dare

 dare(failure: string, format: (fail: b) => string): a {
     return isLuck(this.value) ? this.value.luck : fail(failure + ' ' + format(this.value.fuck));
 }
開發者ID:aleksey-bykov,項目名稱:fluent,代碼行數:3,代碼來源:trying.ts

示例7: dareAt

export function dareAt(args: string[], at: number, failure: string): string {
    const value = args[at];
    if (value === undefined) return fail(failure);
    return value;
}
開發者ID:aleksey-bykov,項目名稱:commandlining,代碼行數:5,代碼來源:primitive.ts


注:本文中的basic/base.fail函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。