Fix crash when extending non-EntityNameExpression (#18853)

This commit is contained in:
Andy 2017-10-02 10:39:03 -07:00 committed by GitHub
parent e6980722a6
commit 637ed57451
6 changed files with 46 additions and 2 deletions

View file

@ -1272,8 +1272,10 @@ namespace ts {
case SyntaxKind.PropertyAccessExpression:
return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
case SyntaxKind.ExpressionWithTypeArguments:
Debug.assert(isEntityNameExpression((<ExpressionWithTypeArguments>node).expression));
return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression;
if (isEntityNameExpression((<ExpressionWithTypeArguments>node).expression)) {
return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression;
}
// falls through
default:
return undefined;
}

View file

@ -0,0 +1,8 @@
tests/cases/compiler/classExtendsInterface_not.ts(1,20): error TS2339: Property 'bogus' does not exist on type '""'.
==== tests/cases/compiler/classExtendsInterface_not.ts (1 errors) ====
class C extends "".bogus {}
~~~~~
!!! error TS2339: Property 'bogus' does not exist on type '""'.

View file

@ -0,0 +1,22 @@
//// [classExtendsInterface_not.ts]
class C extends "".bogus {}
//// [classExtendsInterface_not.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var C = /** @class */ (function (_super) {
__extends(C, _super);
function C() {
return _super !== null && _super.apply(this, arguments) || this;
}
return C;
}("".bogus));

View file

@ -0,0 +1,4 @@
=== tests/cases/compiler/classExtendsInterface_not.ts ===
class C extends "".bogus {}
>C : Symbol(C, Decl(classExtendsInterface_not.ts, 0, 0))

View file

@ -0,0 +1,7 @@
=== tests/cases/compiler/classExtendsInterface_not.ts ===
class C extends "".bogus {}
>C : C
>"".bogus : any
>"" : ""
>bogus : any

View file

@ -0,0 +1 @@
class C extends "".bogus {}