From 58aa0f3f7685f006d93c44dcfee6952c396de693 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 8 Jun 2017 12:58:39 -0700 Subject: [PATCH] Copy PossiblyContainDynamicImport from old source file to new one --- src/compiler/parser.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8002709f3f6..526329b2056 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -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 */