Prefer 'return Debug.fail()' over 'throw Debug.fail()' (#22092)

This commit is contained in:
Andy
2018-03-02 10:44:06 -08:00
committed by GitHub
parent b15157356a
commit ba8879d005
8 changed files with 14 additions and 14 deletions
+3 -3
View File
@@ -15333,7 +15333,7 @@ namespace ts {
const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
if (intrinsicElementsType !== unknownType) {
// Property case
if (!isIdentifier(node.tagName)) throw Debug.fail();
if (!isIdentifier(node.tagName)) return Debug.fail();
const intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
if (intrinsicProp) {
links.jsxFlags |= JsxFlags.IntrinsicNamedElement;
@@ -18106,7 +18106,7 @@ namespace ts {
}
// Make sure require is not a local function
if (!isIdentifier(node.expression)) throw Debug.fail();
if (!isIdentifier(node.expression)) return Debug.fail();
const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
if (!resolvedRequire) {
// project does not contain symbol named 'require' - assume commonjs require
@@ -21841,7 +21841,7 @@ namespace ts {
const symbol = getSymbolOfNode(node);
if (symbol.flags & SymbolFlags.FunctionScopedVariable) {
if (!isIdentifier(node.name)) throw Debug.fail();
if (!isIdentifier(node.name)) return Debug.fail();
const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
if (localDeclarationSymbol &&
localDeclarationSymbol !== symbol &&
+2 -2
View File
@@ -1545,10 +1545,10 @@ namespace ts {
let isDebugInfoEnabled = false;
export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal)
? (node: Node, message?: string): void => fail(
? (node: Node, message?: string): never => fail(
`${message || "Unexpected node."}\r\nNode ${formatSyntaxKind(node.kind)} was unexpected.`,
failBadSyntaxKind)
: noop;
: noop as () => never; // TODO: GH#22091
export const assertEachNode = shouldAssert(AssertionLevel.Normal)
? (nodes: Node[], test: (node: Node) => boolean, message?: string): void => assert(