@@ -10,6 +10,7 @@ namespace ts {
10
10
NoNodeConverters = 1 << 1 ,
11
11
// Ensures new `PropertyAccessExpression` nodes are created with the `NoIndentation` emit flag set.
12
12
NoIndentationOnFreshPropertyAccess = 1 << 2 ,
13
+ NoOriginalNode = 1 << 3 ,
13
14
}
14
15
15
16
/**
@@ -22,6 +23,7 @@ namespace ts {
22
23
// Lazily load the parenthesizer, node converters, and some factory methods until they are used.
23
24
const parenthesizerRules = memoize ( ( ) => flags & NodeFactoryFlags . NoParenthesizerRules ? nullParenthesizerRules : createParenthesizerRules ( factory ) ) ;
24
25
const converters = memoize ( ( ) => flags & NodeFactoryFlags . NoNodeConverters ? nullNodeConverters : createNodeConverters ( factory ) ) ;
26
+ const update = flags & NodeFactoryFlags . NoOriginalNode ? updateWithoutOriginal : updateWithOriginal ;
25
27
26
28
// lazy initializaton of common operator factories
27
29
const getBinaryCreateFunction = memoizeOne ( ( operator : BinaryOperator ) => ( left : Expression , right : Expression ) => createBinaryExpression ( left , operator , right ) ) ;
@@ -553,7 +555,13 @@ namespace ts {
553
555
modifiers
554
556
) ;
555
557
node . name = asName ( name ) ;
556
- node . transformFlags |= propagateChildFlags ( node . name ) ;
558
+ node . transformFlags |=
559
+ kind === SyntaxKind . MethodDeclaration ||
560
+ kind === SyntaxKind . GetAccessor ||
561
+ kind === SyntaxKind . SetAccessor ||
562
+ kind === SyntaxKind . PropertyDeclaration ?
563
+ propagatePropertyNameFlags ( node . name ) :
564
+ propagateChildFlags ( node . name ) ;
557
565
return node ;
558
566
}
559
567
@@ -820,6 +828,9 @@ namespace ts {
820
828
// NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
821
829
node . typeArguments = createNodeArray ( typeArguments ) ;
822
830
}
831
+ if ( node . originalKeywordKind === SyntaxKind . AwaitKeyword ) {
832
+ node . transformFlags |= TransformFlags . ContainsPossibleTopLevelAwait ;
833
+ }
823
834
return node ;
824
835
}
825
836
@@ -2090,7 +2101,7 @@ namespace ts {
2090
2101
node . name = asName ( name ) ;
2091
2102
node . transformFlags =
2092
2103
propagateChildFlags ( node . expression ) |
2093
- propagateChildFlags ( node . name ) ;
2104
+ propagatePropertyNameFlags ( node . name ) ;
2094
2105
if ( isSuperKeyword ( expression ) ) {
2095
2106
// super method calls require a lexical 'this'
2096
2107
// super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
@@ -4754,7 +4765,7 @@ namespace ts {
4754
4765
hasNoDefaultLib : boolean ,
4755
4766
libReferences : readonly FileReference [ ]
4756
4767
) {
4757
- const node = createBaseNode < SourceFile > ( SyntaxKind . SourceFile ) ;
4768
+ const node = baseFactory . createBaseSourceFileNode ( SyntaxKind . SourceFile ) as Mutable < SourceFile > ;
4758
4769
for ( const p in source ) {
4759
4770
if ( p === "emitNode" || hasProperty ( node , p ) || ! hasProperty ( source , p ) ) continue ;
4760
4771
( node as any ) [ p ] = ( source as any ) [ p ] ;
@@ -5681,7 +5692,15 @@ namespace ts {
5681
5692
}
5682
5693
}
5683
5694
5684
- function update < T extends Node > ( updated : T , original : T ) : T {
5695
+ function updateWithoutOriginal < T extends Node > ( updated : T , original : T ) : T {
5696
+ if ( updated !== original ) {
5697
+ setOriginalNode ( updated , original ) ;
5698
+ setTextRange ( updated , original ) ;
5699
+ }
5700
+ return updated ;
5701
+ }
5702
+
5703
+ function updateWithOriginal < T extends Node > ( updated : T , original : T ) : T {
5685
5704
if ( updated !== original ) {
5686
5705
setOriginalNode ( updated , original ) ;
5687
5706
setTextRange ( updated , original ) ;
@@ -5766,14 +5785,23 @@ namespace ts {
5766
5785
return tokenValue ;
5767
5786
}
5768
5787
5769
- function propagatePropertyNameFlags ( node : PropertyName , transformFlags : TransformFlags ) {
5788
+ function propagatePropertyNameFlags ( node : Node | undefined ) {
5789
+ if ( ! node ) return TransformFlags . None ;
5790
+ // `await` in a property name should not be considered a possible top-level await keyword
5791
+ const transformFlags = propagateChildFlags ( node ) ;
5792
+ return isIdentifier ( node ) ?
5793
+ transformFlags & ~ TransformFlags . ContainsPossibleTopLevelAwait :
5794
+ transformFlags ;
5795
+ }
5796
+
5797
+ function propagatePropertyNameFlagsOfChild ( node : PropertyName , transformFlags : TransformFlags ) {
5770
5798
return transformFlags | ( node . transformFlags & TransformFlags . PropertyNamePropagatingFlags ) ;
5771
5799
}
5772
5800
5773
5801
function propagateChildFlags ( child : Node | undefined ) : TransformFlags {
5774
5802
if ( ! child ) return TransformFlags . None ;
5775
5803
const childFlags = child . transformFlags & ~ getTransformFlagsSubtreeExclusions ( child . kind ) ;
5776
- return isNamedDeclaration ( child ) && isPropertyName ( child . name ) ? propagatePropertyNameFlags ( child . name , childFlags ) : childFlags ;
5804
+ return isNamedDeclaration ( child ) && isPropertyName ( child . name ) ? propagatePropertyNameFlagsOfChild ( child . name , childFlags ) : childFlags ;
5777
5805
}
5778
5806
5779
5807
function propagateChildrenFlags ( children : NodeArray < Node > | undefined ) : TransformFlags {
0 commit comments