Skip to content

Commit b1c15f4

Browse files
author
Andy Hanson
committed
Add assertion
1 parent 4071d50 commit b1c15f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/compiler/utilities.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ namespace ts {
18661866
case SyntaxKind.Identifier:
18671867
case SyntaxKind.StringLiteral:
18681868
case SyntaxKind.NumericLiteral:
1869-
return isDeclaration(name.parent) && name.parent.name === name;
1869+
return isDeclaration(node.parent) && node.parent.name === name;
18701870
default:
18711871
return false;
18721872
}
@@ -4300,7 +4300,9 @@ namespace ts {
43004300

43014301
/** @internal */
43024302
export function isNamedDeclaration(node: Node): node is NamedDeclaration & { name: DeclarationName } {
4303-
return !!(node as NamedDeclaration).name;
4303+
const name = (node as NamedDeclaration).name;
4304+
Debug.assert(!name || isDeclaration(node) && node.name === name, "A 'name' property should always be a DeclarationName.");
4305+
return !!name;
43044306
}
43054307

43064308
export function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined {

0 commit comments

Comments
 (0)