@@ -44,10 +44,10 @@ namespace ts {
4444
4545 // NOTE: 'reusedElements' is the expected count of elements reused from the old tree to the new
4646 // tree. It may change as we tweak the parser. If the count increases then that should always
47- // be a good thing. If it decreases, that's not great (less reusability), but that may be
48- // unavoidable. If it does decrease an investigation should be done to make sure that things
47+ // be a good thing. If it decreases, that's not great (less reusability), but that may be
48+ // unavoidable. If it does decrease an investigation should be done to make sure that things
4949 // are still ok and we're still appropriately reusing most of the tree.
50- function compareTrees ( oldText : IScriptSnapshot , newText : IScriptSnapshot , textChangeRange : TextChangeRange , expectedReusedElements : number , oldTree ?: SourceFile ) : SourceFile {
50+ function compareTrees ( oldText : IScriptSnapshot , newText : IScriptSnapshot , textChangeRange : TextChangeRange , expectedReusedElements : number , oldTree ?: SourceFile ) {
5151 oldTree = oldTree || createTree ( oldText , /*version:*/ "." ) ;
5252 Utils . assertInvariants ( oldTree , /*parent:*/ undefined ) ;
5353
@@ -76,7 +76,7 @@ namespace ts {
7676 assert . equal ( actualReusedCount , expectedReusedElements , actualReusedCount + " !== " + expectedReusedElements ) ;
7777 }
7878
79- return incrementalNewTree ;
79+ return { oldTree , newTree , incrementalNewTree } ;
8080 }
8181
8282 function reusedElements ( oldNode : SourceFile , newNode : SourceFile ) : number {
@@ -103,7 +103,7 @@ namespace ts {
103103 for ( let i = 0 ; i < repeat ; i ++ ) {
104104 const oldText = ScriptSnapshot . fromString ( source ) ;
105105 const newTextAndChange = withDelete ( oldText , index , 1 ) ;
106- const newTree = compareTrees ( oldText , newTextAndChange . text , newTextAndChange . textChangeRange , - 1 , oldTree ) ;
106+ const newTree = compareTrees ( oldText , newTextAndChange . text , newTextAndChange . textChangeRange , - 1 , oldTree ) . incrementalNewTree ;
107107
108108 source = newTextAndChange . text . getText ( 0 , newTextAndChange . text . getLength ( ) ) ;
109109 oldTree = newTree ;
@@ -116,7 +116,7 @@ namespace ts {
116116 for ( let i = 0 ; i < repeat ; i ++ ) {
117117 const oldText = ScriptSnapshot . fromString ( source ) ;
118118 const newTextAndChange = withInsert ( oldText , index + i , toInsert . charAt ( i ) ) ;
119- const newTree = compareTrees ( oldText , newTextAndChange . text , newTextAndChange . textChangeRange , - 1 , oldTree ) ;
119+ const newTree = compareTrees ( oldText , newTextAndChange . text , newTextAndChange . textChangeRange , - 1 , oldTree ) . incrementalNewTree ;
120120
121121 source = newTextAndChange . text . getText ( 0 , newTextAndChange . text . getLength ( ) ) ;
122122 oldTree = newTree ;
@@ -639,7 +639,7 @@ module m3 { }\
639639 } ) ;
640640
641641 it ( "Unterminated comment after keyword converted to identifier" , ( ) => {
642- // 'public' as a keyword should be incrementally unusable (because it has an
642+ // 'public' as a keyword should be incrementally unusable (because it has an
643643 // unterminated comment). When we convert it to an identifier, that shouldn't
644644 // change anything, and we should still get the same errors.
645645 const source = "return; a.public /*" ;
@@ -796,6 +796,16 @@ module m3 { }\
796796 compareTrees ( oldText , newTextAndChange . text , newTextAndChange . textChangeRange , 4 ) ;
797797 } ) ;
798798
799+ it ( "Reuse transformFlags of subtree during bind" , ( ) => {
800+ const source = `class Greeter { constructor(element: HTMLElement) { } }` ;
801+ const oldText = ScriptSnapshot . fromString ( source ) ;
802+ const newTextAndChange = withChange ( oldText , 15 , 0 , "\n" ) ;
803+ const { oldTree, incrementalNewTree } = compareTrees ( oldText , newTextAndChange . text , newTextAndChange . textChangeRange , - 1 ) ;
804+ bindSourceFile ( oldTree , { } ) ;
805+ bindSourceFile ( incrementalNewTree , { } ) ;
806+ assert . equal ( oldTree . transformFlags , incrementalNewTree . transformFlags ) ;
807+ } ) ;
808+
799809 // Simulated typing tests.
800810
801811 it ( "Type extends clause 1" , ( ) => {
0 commit comments