Skip to content

Commit 637ed57

Browse files
author
Andy
authored
Fix crash when extending non-EntityNameExpression (#18853)
1 parent e698072 commit 637ed57

6 files changed

+46
-2
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,10 @@ namespace ts {
12721272
case SyntaxKind.PropertyAccessExpression:
12731273
return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
12741274
case SyntaxKind.ExpressionWithTypeArguments:
1275-
Debug.assert(isEntityNameExpression((<ExpressionWithTypeArguments>node).expression));
1276-
return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression;
1275+
if (isEntityNameExpression((<ExpressionWithTypeArguments>node).expression)) {
1276+
return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression;
1277+
}
1278+
// falls through
12771279
default:
12781280
return undefined;
12791281
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests/cases/compiler/classExtendsInterface_not.ts(1,20): error TS2339: Property 'bogus' does not exist on type '""'.
2+
3+
4+
==== tests/cases/compiler/classExtendsInterface_not.ts (1 errors) ====
5+
class C extends "".bogus {}
6+
~~~~~
7+
!!! error TS2339: Property 'bogus' does not exist on type '""'.
8+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [classExtendsInterface_not.ts]
2+
class C extends "".bogus {}
3+
4+
5+
//// [classExtendsInterface_not.js]
6+
var __extends = (this && this.__extends) || (function () {
7+
var extendStatics = Object.setPrototypeOf ||
8+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10+
return function (d, b) {
11+
extendStatics(d, b);
12+
function __() { this.constructor = d; }
13+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14+
};
15+
})();
16+
var C = /** @class */ (function (_super) {
17+
__extends(C, _super);
18+
function C() {
19+
return _super !== null && _super.apply(this, arguments) || this;
20+
}
21+
return C;
22+
}("".bogus));
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/compiler/classExtendsInterface_not.ts ===
2+
class C extends "".bogus {}
3+
>C : Symbol(C, Decl(classExtendsInterface_not.ts, 0, 0))
4+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/classExtendsInterface_not.ts ===
2+
class C extends "".bogus {}
3+
>C : C
4+
>"".bogus : any
5+
>"" : ""
6+
>bogus : any
7+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class C extends "".bogus {}

0 commit comments

Comments
 (0)