Skip to content

Commit

Permalink
Fix crash when extending non-EntityNameExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Hanson committed Sep 29, 2017
1 parent 7aee3a1 commit c27f747
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 '""'.

22 changes: 22 additions & 0 deletions tests/baselines/reference/classExtendsInterface_not.js
Original file line number Diff line number Diff line change
@@ -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));
4 changes: 4 additions & 0 deletions tests/baselines/reference/classExtendsInterface_not.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=== tests/cases/compiler/classExtendsInterface_not.ts ===
class C extends "".bogus {}
>C : Symbol(C, Decl(classExtendsInterface_not.ts, 0, 0))

7 changes: 7 additions & 0 deletions tests/baselines/reference/classExtendsInterface_not.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
=== tests/cases/compiler/classExtendsInterface_not.ts ===
class C extends "".bogus {}
>C : C
>"".bogus : any
>"" : ""
>bogus : any

1 change: 1 addition & 0 deletions tests/cases/compiler/classExtendsInterface_not.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class C extends "".bogus {}

0 comments on commit c27f747

Please sign in to comment.