Skip to content

Commit 2f61d47

Browse files
author
Yui T
committed
Address minor PR comment
1 parent 2b96374 commit 2f61d47

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

src/compiler/parser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3517,10 +3517,10 @@ namespace ts {
35173517
* 5) --UnaryExpression[?Yield]
35183518
*/
35193519
if (isUpdateExpression()) {
3520-
const UpdateExpression = parseUpdateExpression();
3520+
const updateExpression = parseUpdateExpression();
35213521
return token() === SyntaxKind.AsteriskAsteriskToken ?
3522-
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), UpdateExpression) :
3523-
UpdateExpression;
3522+
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), updateExpression) :
3523+
updateExpression;
35243524
}
35253525

35263526
/**
@@ -3700,7 +3700,7 @@ namespace ts {
37003700
// For example:
37013701
// var foo3 = require("subfolder
37023702
// import * as foo1 from "module-from-node -> we want this import to be a statement rather than import call expression
3703-
sourceFile.possiblyContainDynamicImport = true;
3703+
sourceFile.flags |= NodeFlags.possiblyContainDynamicImport;
37043704
expression = parseTokenNode<PrimaryExpression>();
37053705
}
37063706
else {

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ namespace ts {
12231223

12241224
for (const node of file.statements) {
12251225
collectModuleReferences(node, /*inAmbientModule*/ false);
1226-
if (file.possiblyContainDynamicImport || isJavaScriptFile) {
1226+
if ((file.flags & NodeFlags.possiblyContainDynamicImport) || isJavaScriptFile) {
12271227
collectDynamicImportOrRequireCalls(node);
12281228
}
12291229
}

src/compiler/types.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,14 @@ namespace ts {
448448
ThisNodeOrAnySubNodesHasError = 1 << 17, // If this node or any of its children had an error
449449
HasAggregatedChildData = 1 << 18, // If we've computed data from children and cached it in this node
450450

451+
// This flag will be set to true when the parse encounter dynamic import so that post-parsing process of module resolution
452+
// 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.
453+
// (hence it is named "possiblyContainDynamicImport").
454+
// 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.
455+
// 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.
456+
// 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.
457+
possiblyContainDynamicImport = 1 << 19,
458+
451459
BlockScoped = Let | Const,
452460

453461
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn,
@@ -990,8 +998,10 @@ namespace ts {
990998
_unaryExpressionBrand: any;
991999
}
9921000

1001+
/** Deprecated, please use UpdateExpression */
1002+
export type IncrementExpression = UpdateExpression;
9931003
export interface UpdateExpression extends UnaryExpression {
994-
_incrementExpressionBrand: any;
1004+
_updateExpressionBrand: any;
9951005
}
9961006

9971007
// see: https://tc39.github.io/ecma262/#prod-UpdateExpression
@@ -1002,8 +1012,7 @@ namespace ts {
10021012
| SyntaxKind.PlusToken
10031013
| SyntaxKind.MinusToken
10041014
| SyntaxKind.TildeToken
1005-
| SyntaxKind.ExclamationToken
1006-
;
1015+
| SyntaxKind.ExclamationToken;
10071016

10081017
export interface PrefixUnaryExpression extends UpdateExpression {
10091018
kind: SyntaxKind.PrefixUnaryExpression;
@@ -2305,13 +2314,6 @@ namespace ts {
23052314
/* @internal */ patternAmbientModules?: PatternAmbientModule[];
23062315
/* @internal */ ambientModuleNames: string[];
23072316
/* @internal */ checkJsDirective: CheckJsDirective | undefined;
2308-
// This flag will be set to true when the parse encounter dynamic import so that post-parsing process of module resolution
2309-
// 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.
2310-
// (hence it is named "possiblyContainDynamicImport").
2311-
// 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.
2312-
// 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.
2313-
// 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.
2314-
/* @internal */ possiblyContainDynamicImport: boolean;
23152317
}
23162318

23172319
export interface Bundle extends Node {
@@ -3866,7 +3868,10 @@ namespace ts {
38663868

38673869
ContainsDynamicImport = 1 << 26,
38683870

3869-
HasComputedFlags = 1 << 27, // Transform flags have been computed.
3871+
// Please leave this as 1 << 29.
3872+
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
3873+
// It is a good reminder of how much room we have left
3874+
HasComputedFlags = 1 << 29, // Transform flags have been computed.
38703875

38713876
// Assertions
38723877
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ namespace ts {
355355
_primaryExpressionBrand: any;
356356
_memberExpressionBrand: any;
357357
_leftHandSideExpressionBrand: any;
358-
_incrementExpressionBrand: any;
358+
_updateExpressionBrand: any;
359359
_unaryExpressionBrand: any;
360360
_expressionBrand: any;
361361
constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) {

0 commit comments

Comments
 (0)