Fix assertion: class reference location may be 'default' keyword instead of class name (#21630)

* Fix assertion: class reference location may be 'default' keyword instead of class name

* Update API baselines
This commit is contained in:
Andy
2018-02-05 13:24:08 -08:00
committed by GitHub
parent d11c7aeeaf
commit d584f4d97b
5 changed files with 9 additions and 1 deletions

View File

@@ -2027,6 +2027,7 @@ namespace ts {
export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement {
kind: SyntaxKind.ClassDeclaration;
/** May be undefined in `export default class { ... }`. */
name?: Identifier;
}

View File

@@ -990,7 +990,7 @@ namespace ts.FindAllReferences.Core {
const pusher = () => state.referenceAdder(search.symbol, search.location);
if (isClassLike(referenceLocation.parent)) {
Debug.assert(referenceLocation.parent.name === referenceLocation);
Debug.assert(referenceLocation.kind === SyntaxKind.DefaultKeyword || referenceLocation.parent.name === referenceLocation);
// This is the class declaration containing the constructor.
findOwnConstructorReferences(search.symbol, sourceFile, pusher());
}

View File

@@ -1266,6 +1266,7 @@ declare namespace ts {
}
interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement {
kind: SyntaxKind.ClassDeclaration;
/** May be undefined in `export default class { ... }`. */
name?: Identifier;
}
interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression {

View File

@@ -1266,6 +1266,7 @@ declare namespace ts {
}
interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement {
kind: SyntaxKind.ClassDeclaration;
/** May be undefined in `export default class { ... }`. */
name?: Identifier;
}
interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression {

View File

@@ -0,0 +1,5 @@
////export default class {
//// [|constructor|]() {}
////}
verify.singleReferenceGroup("constructor default(): default");