Skip to content

Commit 37bf00b

Browse files
author
Kanchalai Tanglertsampan
committed
Copy PossiblyContainDynamicImport from old source file to new one
1 parent 1360a98 commit 37bf00b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/compiler/parser.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,11 @@ namespace ts {
481481
// becoming detached from any SourceFile). It is recommended that this SourceFile not
482482
// be used once 'update' is called on it.
483483
export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile {
484-
return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
484+
const newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
485+
// 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.
486+
// We will manually port the flag to the new source file.
487+
newSourceFile.flags |= (sourceFile.flags & NodeFlags.PossiblyContainDynamicImport);
488+
return newSourceFile;
485489
}
486490

487491
/* @internal */

0 commit comments

Comments
 (0)