mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Prefer 'return Debug.fail()' over 'throw Debug.fail()' (#22092)
This commit is contained in:
@@ -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 &&
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user