@@ -44,10 +44,10 @@ namespace ts {
44
44
45
45
// NOTE: 'reusedElements' is the expected count of elements reused from the old tree to the new
46
46
// 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
49
49
// 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 ) {
51
51
oldTree = oldTree || createTree ( oldText , /*version:*/ "." ) ;
52
52
Utils . assertInvariants ( oldTree , /*parent:*/ undefined ) ;
53
53
@@ -76,7 +76,7 @@ namespace ts {
76
76
assert . equal ( actualReusedCount , expectedReusedElements , actualReusedCount + " !== " + expectedReusedElements ) ;
77
77
}
78
78
79
- return incrementalNewTree ;
79
+ return { oldTree , newTree , incrementalNewTree } ;
80
80
}
81
81
82
82
function reusedElements ( oldNode : SourceFile , newNode : SourceFile ) : number {
@@ -103,7 +103,7 @@ namespace ts {
103
103
for ( let i = 0 ; i < repeat ; i ++ ) {
104
104
const oldText = ScriptSnapshot . fromString ( source ) ;
105
105
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 ;
107
107
108
108
source = newTextAndChange . text . getText ( 0 , newTextAndChange . text . getLength ( ) ) ;
109
109
oldTree = newTree ;
@@ -116,7 +116,7 @@ namespace ts {
116
116
for ( let i = 0 ; i < repeat ; i ++ ) {
117
117
const oldText = ScriptSnapshot . fromString ( source ) ;
118
118
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 ;
120
120
121
121
source = newTextAndChange . text . getText ( 0 , newTextAndChange . text . getLength ( ) ) ;
122
122
oldTree = newTree ;
@@ -639,7 +639,7 @@ module m3 { }\
639
639
} ) ;
640
640
641
641
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
643
643
// unterminated comment). When we convert it to an identifier, that shouldn't
644
644
// change anything, and we should still get the same errors.
645
645
const source = "return; a.public /*" ;
@@ -796,6 +796,16 @@ module m3 { }\
796
796
compareTrees ( oldText , newTextAndChange . text , newTextAndChange . textChangeRange , 4 ) ;
797
797
} ) ;
798
798
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
+
799
809
// Simulated typing tests.
800
810
801
811
it ( "Type extends clause 1" , ( ) => {
0 commit comments