Copy PossiblyContainDynamicImport from old source file to new one

This commit is contained in:
Kanchalai Tanglertsampan
2017-06-08 12:58:39 -07:00
parent b325790270
commit 58aa0f3f76

View File

@@ -481,7 +481,11 @@ namespace ts {
// becoming detached from any SourceFile). It is recommended that this SourceFile not
// be used once 'update' is called on it.
export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile {
return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
const newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
// Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import.
// We will manually port the flag to the new source file.
newSourceFile.flags |= (sourceFile.flags & NodeFlags.PossiblyContainDynamicImport);
return newSourceFile;
}
/* @internal */