mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-05 00:32:41 -05:00
Prefer 'return Debug.fail()' over 'throw Debug.fail()' (#22092)
This commit is contained in:
@@ -224,7 +224,7 @@ namespace ts {
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate;
|
||||
default:
|
||||
throw Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token);
|
||||
return Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token);
|
||||
}
|
||||
}
|
||||
return lastOnTemplateStack === SyntaxKind.TemplateHead ? EndOfLineState.InTemplateSubstitutionPosition : undefined;
|
||||
@@ -343,7 +343,7 @@ namespace ts {
|
||||
case EndOfLineState.None:
|
||||
return { prefix: "" };
|
||||
default:
|
||||
throw Debug.assertNever(lexState);
|
||||
return Debug.assertNever(lexState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -699,7 +699,7 @@ namespace ts.codefix {
|
||||
// Fall back to the `import * as ns` style import.
|
||||
return ImportKind.Namespace;
|
||||
default:
|
||||
throw Debug.assertNever(moduleKind);
|
||||
return Debug.assertNever(moduleKind);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace ts.codefix {
|
||||
return isSetAccessor(containingFunction) ? getCodeActionForSetAccessor(containingFunction, program, cancellationToken) : undefined;
|
||||
|
||||
default:
|
||||
throw Debug.fail(String(errorCode));
|
||||
return Debug.fail(String(errorCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace ts.Completions {
|
||||
case CompletionDataKind.JsDocParameterName:
|
||||
return jsdocCompletionInfo(JsDoc.getJSDocParameterNameCompletions(completionData.tag));
|
||||
default:
|
||||
throw Debug.assertNever(completionData);
|
||||
return Debug.assertNever(completionData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1453,7 +1453,7 @@ namespace ts.Completions {
|
||||
isNewIdentifierLocation = false;
|
||||
|
||||
const rootDeclaration = getRootDeclaration(objectLikeContainer.parent);
|
||||
if (!isVariableLike(rootDeclaration)) throw Debug.fail("Root declaration is not variable-like.");
|
||||
if (!isVariableLike(rootDeclaration)) return Debug.fail("Root declaration is not variable-like.");
|
||||
|
||||
// We don't want to complete using the type acquired by the shape
|
||||
// of the binding pattern; we are only interested in types acquired
|
||||
|
||||
@@ -318,7 +318,7 @@ namespace ts.JsTyping {
|
||||
case PackageNameValidationResult.NameContainsNonURISafeCharacters:
|
||||
return `Package name '${typing}' contains non URI safe characters`;
|
||||
case PackageNameValidationResult.Ok:
|
||||
throw Debug.fail(); // Shouldn't have called this.
|
||||
return Debug.fail(); // Shouldn't have called this.
|
||||
default:
|
||||
Debug.assertNever(result);
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace ts.textChanges {
|
||||
else if (isVariableDeclaration(before)) { // insert `x = 1, ` into `const x = 1, y = 2;
|
||||
return { suffix: ", " };
|
||||
}
|
||||
throw Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it
|
||||
return Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it
|
||||
}
|
||||
|
||||
public insertNodeAtConstructorStart(sourceFile: SourceFile, ctr: ConstructorDeclaration, newStatement: Statement): void {
|
||||
@@ -430,7 +430,7 @@ namespace ts.textChanges {
|
||||
else if (isVariableDeclaration(node)) {
|
||||
return { prefix: ", " };
|
||||
}
|
||||
throw Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it
|
||||
return Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user