@@ -429,10 +429,7 @@ namespace ts.textChanges {
429429 }
430430
431431 public insertNodeAfter ( sourceFile : SourceFile , after : Node , newNode : Node ) : this {
432- if ( isStatementButNotDeclaration ( after ) ||
433- after . kind === SyntaxKind . PropertyDeclaration ||
434- after . kind === SyntaxKind . PropertySignature ||
435- after . kind === SyntaxKind . MethodSignature ) {
432+ if ( needSemicolonBetween ( after , newNode ) ) {
436433 // check if previous statement ends with semicolon
437434 // if not - insert semicolon to preserve the code from changing the meaning due to ASI
438435 if ( sourceFile . text . charCodeAt ( after . end - 1 ) !== CharacterCodes . semicolon ) {
@@ -453,7 +450,7 @@ namespace ts.textChanges {
453450 if ( isClassDeclaration ( node ) || isModuleDeclaration ( node ) ) {
454451 return { prefix : this . newLineCharacter , suffix : this . newLineCharacter } ;
455452 }
456- else if ( isStatement ( node ) || isClassElement ( node ) || isTypeElement ( node ) ) {
453+ else if ( isStatement ( node ) || isClassOrTypeElement ( node ) ) {
457454 return { suffix : this . newLineCharacter } ;
458455 }
459456 else if ( isVariableDeclaration ( node ) ) {
@@ -904,4 +901,9 @@ namespace ts.textChanges {
904901 }
905902 }
906903 }
904+
905+ function needSemicolonBetween ( a : Node , b : Node ) : boolean {
906+ return ( isPropertySignature ( a ) || isPropertyDeclaration ( a ) ) && isClassOrTypeElement ( b ) && b . name . kind === SyntaxKind . ComputedPropertyName
907+ || isStatementButNotDeclaration ( a ) && isStatementButNotDeclaration ( b ) ; // TODO: only if b would start with a `(` or `[`
908+ }
907909}
0 commit comments