@@ -10,7 +10,10 @@ namespace ts.codefix {
1010 getCodeActions : ( context : CodeFixContext ) => {
1111 const sourceFile = context . sourceFile ;
1212 const token = getTokenAtPosition ( sourceFile , context . span . start ) ;
13- Debug . assert ( token . kind === SyntaxKind . ConstructorKeyword , "Failed to find the constructor." ) ;
13+
14+ if ( token . kind !== SyntaxKind . ConstructorKeyword ) {
15+ return undefined ;
16+ }
1417
1518 const newPosition = getOpenBraceEnd ( < ConstructorDeclaration > token . parent , sourceFile ) ;
1619 return [ {
@@ -26,14 +29,18 @@ namespace ts.codefix {
2629 const sourceFile = context . sourceFile ;
2730
2831 const token = getTokenAtPosition ( sourceFile , context . span . start ) ;
29- const constructor = getContainingFunction ( token ) ;
30- Debug . assert ( constructor . kind === SyntaxKind . Constructor , "Failed to find the constructor." ) ;
32+ if ( token . kind !== SyntaxKind . ConstructorKeyword ) {
33+ return undefined ;
34+ }
3135
36+ const constructor = getContainingFunction ( token ) ;
3237 const superCall = findSuperCall ( ( < ConstructorDeclaration > constructor ) . body ) ;
33- Debug . assert ( ! ! superCall , "Failed to find super call." ) ;
38+ if ( ! superCall ) {
39+ return undefined ;
40+ }
3441
3542 const newPosition = getOpenBraceEnd ( < ConstructorDeclaration > constructor , sourceFile ) ;
36- const changes = [ {
43+ const changes = [ {
3744 fileName : sourceFile . fileName , textChanges : [ {
3845 newText : superCall . getText ( sourceFile ) ,
3946 span : { start : newPosition , length : 0 }
0 commit comments