Skip to content

Commit 025fa87

Browse files
Merge pull request #16382 from Microsoft/ContainsMaster
[Master] Rename & internalize PossiblyContainsDynamicImport
2 parents 0d36d0e + af41c28 commit 025fa87

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/compiler/parser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ namespace ts {
484484
const newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
485485
// 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.
486486
// We will manually port the flag to the new source file.
487-
newSourceFile.flags |= (sourceFile.flags & NodeFlags.PossiblyContainDynamicImport);
487+
newSourceFile.flags |= (sourceFile.flags & NodeFlags.PossiblyContainsDynamicImport);
488488
return newSourceFile;
489489
}
490490

@@ -3705,7 +3705,7 @@ namespace ts {
37053705
// For example:
37063706
// var foo3 = require("subfolder
37073707
// import * as foo1 from "module-from-node -> we want this import to be a statement rather than import call expression
3708-
sourceFile.flags |= NodeFlags.PossiblyContainDynamicImport;
3708+
sourceFile.flags |= NodeFlags.PossiblyContainsDynamicImport;
37093709
expression = parseTokenNode<PrimaryExpression>();
37103710
}
37113711
else {

src/compiler/program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ namespace ts {
13791379

13801380
for (const node of file.statements) {
13811381
collectModuleReferences(node, /*inAmbientModule*/ false);
1382-
if ((file.flags & NodeFlags.PossiblyContainDynamicImport) || isJavaScriptFile) {
1382+
if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || isJavaScriptFile) {
13831383
collectDynamicImportOrRequireCalls(node);
13841384
}
13851385
}

src/compiler/types.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,16 @@ namespace ts {
451451
ThisNodeOrAnySubNodesHasError = 1 << 17, // If this node or any of its children had an error
452452
HasAggregatedChildData = 1 << 18, // If we've computed data from children and cached it in this node
453453

454-
// This flag will be set to true when the parse encounter dynamic import so that post-parsing process of module resolution
455-
// will not walk the tree if the flag is not set. However, this flag is just a approximation because once it is set, the flag never get reset.
456-
// (hence it is named "possiblyContainDynamicImport").
457-
// During editing, if dynamic import is remove, incremental parsing will *NOT* update this flag. This will then causes walking of the tree during module resolution.
458-
// However, the removal operation should not occur often and in the case of the removal, it is likely that users will add back the import anyway.
459-
// The advantage of this approach is its simplicity. For the case of batch compilation, we garuntee that users won't have to pay the price of walking the tree if dynamic import isn't used.
460-
PossiblyContainDynamicImport = 1 << 19,
454+
// This flag will be set when the parser encounters a dynamic import expression so that module resolution
455+
// will not have to walk the tree if the flag is not set. However, this flag is just a approximation because
456+
// once it is set, the flag never gets cleared (hence why it's named "PossiblyContainsDynamicImport").
457+
// During editing, if dynamic import is removed, incremental parsing will *NOT* update this flag. This means that the tree will always be traversed
458+
// during module resolution. However, the removal operation should not occur often and in the case of the
459+
// removal, it is likely that users will add the import anyway.
460+
// The advantage of this approach is its simplicity. For the case of batch compilation,
461+
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
462+
/* @internal */
463+
PossiblyContainsDynamicImport = 1 << 19,
461464

462465
BlockScoped = Let | Const,
463466

0 commit comments

Comments
 (0)