typescript 4.8.0-dev.20220603 → 4.8.0-dev.20220604

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220603";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220604";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -5572,21 +5572,22 @@ var ts;
5572
5572
  TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 4096] = "ContainsDestructuringAssignment";
5573
5573
  // Markers
5574
5574
  // - Flags used to indicate that a subtree contains a specific transformation.
5575
- TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax";
5576
- TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis";
5577
- TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread";
5578
- TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread";
5579
- TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName";
5580
- TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding";
5581
- TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern";
5582
- TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield";
5583
- TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait";
5584
- TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion";
5585
- TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport";
5586
- TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields";
5587
- TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait";
5588
- TransformFlags[TransformFlags["ContainsLexicalSuper"] = 33554432] = "ContainsLexicalSuper";
5589
- TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 67108864] = "ContainsUpdateExpressionForIdentifier";
5575
+ TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 8192] = "ContainsTypeScriptClassSyntax";
5576
+ TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis";
5577
+ TransformFlags[TransformFlags["ContainsRestOrSpread"] = 32768] = "ContainsRestOrSpread";
5578
+ TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 65536] = "ContainsObjectRestOrSpread";
5579
+ TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 131072] = "ContainsComputedPropertyName";
5580
+ TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 262144] = "ContainsBlockScopedBinding";
5581
+ TransformFlags[TransformFlags["ContainsBindingPattern"] = 524288] = "ContainsBindingPattern";
5582
+ TransformFlags[TransformFlags["ContainsYield"] = 1048576] = "ContainsYield";
5583
+ TransformFlags[TransformFlags["ContainsAwait"] = 2097152] = "ContainsAwait";
5584
+ TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 4194304] = "ContainsHoistedDeclarationOrCompletion";
5585
+ TransformFlags[TransformFlags["ContainsDynamicImport"] = 8388608] = "ContainsDynamicImport";
5586
+ TransformFlags[TransformFlags["ContainsClassFields"] = 16777216] = "ContainsClassFields";
5587
+ TransformFlags[TransformFlags["ContainsDecorators"] = 33554432] = "ContainsDecorators";
5588
+ TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5589
+ TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5590
+ TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5590
5591
  // Please leave this as 1 << 29.
5591
5592
  // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5592
5593
  // It is a good reminder of how much room we have left
@@ -5612,24 +5613,24 @@ var ts;
5612
5613
  TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5613
5614
  TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5614
5615
  TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5615
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes";
5616
- TransformFlags[TransformFlags["FunctionExcludes"] = 591310848] = "FunctionExcludes";
5617
- TransformFlags[TransformFlags["ConstructorExcludes"] = 591306752] = "ConstructorExcludes";
5618
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 574529536] = "MethodOrAccessorExcludes";
5619
- TransformFlags[TransformFlags["PropertyExcludes"] = 570433536] = "PropertyExcludes";
5620
- TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes";
5621
- TransformFlags[TransformFlags["ModuleExcludes"] = 589443072] = "ModuleExcludes";
5616
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5617
+ TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5618
+ TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5619
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5620
+ TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5621
+ TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5622
+ TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5622
5623
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5623
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes";
5624
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes";
5625
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes";
5624
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5625
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5626
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5626
5627
  TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5627
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes";
5628
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes";
5629
- TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 33562624] = "ContainsLexicalThisOrSuper";
5628
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5629
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5630
+ TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5630
5631
  // Propagating flags
5631
5632
  // - Bitmasks for flags that should propagate from a child
5632
- TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 33562624] = "PropertyNamePropagatingFlags";
5633
+ TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 134234112] = "PropertyNamePropagatingFlags";
5633
5634
  // Masks
5634
5635
  // - Additional bitmasks
5635
5636
  })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
@@ -17001,6 +17002,12 @@ var ts;
17001
17002
  return [child, node];
17002
17003
  }
17003
17004
  ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
17005
+ function skipTypeParentheses(node) {
17006
+ while (ts.isParenthesizedTypeNode(node))
17007
+ node = node.type;
17008
+ return node;
17009
+ }
17010
+ ts.skipTypeParentheses = skipTypeParentheses;
17004
17011
  function skipParentheses(node, excludeJSDocTypeAssertions) {
17005
17012
  var flags = excludeJSDocTypeAssertions ?
17006
17013
  1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ :
@@ -19235,7 +19242,7 @@ var ts;
19235
19242
  * Moves the start position of a range past any decorators.
19236
19243
  */
19237
19244
  function moveRangePastDecorators(node) {
19238
- return node.decorators && node.decorators.length > 0
19245
+ return node.decorators && !positionIsSynthesized(node.decorators.end)
19239
19246
  ? moveRangePos(node, node.decorators.end)
19240
19247
  : node;
19241
19248
  }
@@ -19244,7 +19251,7 @@ var ts;
19244
19251
  * Moves the start position of a range past any decorators or modifiers.
19245
19252
  */
19246
19253
  function moveRangePastModifiers(node) {
19247
- return node.modifiers && node.modifiers.length > 0
19254
+ return node.modifiers && !positionIsSynthesized(node.modifiers.end)
19248
19255
  ? moveRangePos(node, node.modifiers.end)
19249
19256
  : moveRangePastDecorators(node);
19250
19257
  }
@@ -22674,7 +22681,7 @@ var ts;
22674
22681
  function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
22675
22682
  var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
22676
22683
  node.body = body;
22677
- node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */;
22684
+ node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */;
22678
22685
  if (!body)
22679
22686
  node.transformFlags |= 1 /* ContainsTypeScript */;
22680
22687
  return node;
@@ -22802,7 +22809,7 @@ var ts;
22802
22809
  node.typeArguments = createNodeArray(typeArguments);
22803
22810
  }
22804
22811
  if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
22805
- node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */;
22812
+ node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */;
22806
22813
  }
22807
22814
  return node;
22808
22815
  }
@@ -22854,7 +22861,7 @@ var ts;
22854
22861
  ts.Debug.fail("First character of private identifier must be #: " + text);
22855
22862
  var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */);
22856
22863
  node.escapedText = ts.escapeLeadingUnderscores(text);
22857
- node.transformFlags |= 8388608 /* ContainsClassFields */;
22864
+ node.transformFlags |= 16777216 /* ContainsClassFields */;
22858
22865
  return node;
22859
22866
  }
22860
22867
  //
@@ -22901,14 +22908,14 @@ var ts;
22901
22908
  transformFlags = 1 /* ContainsTypeScript */;
22902
22909
  break;
22903
22910
  case 106 /* SuperKeyword */:
22904
- transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
22911
+ transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */;
22905
22912
  break;
22906
22913
  case 124 /* StaticKeyword */:
22907
22914
  transformFlags = 1024 /* ContainsES2015 */;
22908
22915
  break;
22909
22916
  case 108 /* ThisKeyword */:
22910
22917
  // 'this' indicates a lexical 'this'
22911
- transformFlags = 8192 /* ContainsLexicalThis */;
22918
+ transformFlags = 16384 /* ContainsLexicalThis */;
22912
22919
  break;
22913
22920
  }
22914
22921
  if (transformFlags) {
@@ -23006,7 +23013,7 @@ var ts;
23006
23013
  node.transformFlags |=
23007
23014
  propagateChildFlags(node.expression) |
23008
23015
  1024 /* ContainsES2015 */ |
23009
- 65536 /* ContainsComputedPropertyName */;
23016
+ 131072 /* ContainsComputedPropertyName */;
23010
23017
  return node;
23011
23018
  }
23012
23019
  // @api
@@ -23072,7 +23079,7 @@ var ts;
23072
23079
  if (questionToken)
23073
23080
  node.transformFlags |= 1 /* ContainsTypeScript */;
23074
23081
  if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
23075
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23082
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23076
23083
  if (initializer || dotDotDotToken)
23077
23084
  node.transformFlags |= 1024 /* ContainsES2015 */;
23078
23085
  }
@@ -23097,7 +23104,8 @@ var ts;
23097
23104
  node.transformFlags |=
23098
23105
  propagateChildFlags(node.expression) |
23099
23106
  1 /* ContainsTypeScript */ |
23100
- 4096 /* ContainsTypeScriptClassSyntax */;
23107
+ 8192 /* ContainsTypeScriptClassSyntax */ |
23108
+ 33554432 /* ContainsDecorators */;
23101
23109
  return node;
23102
23110
  }
23103
23111
  // @api
@@ -23135,9 +23143,9 @@ var ts;
23135
23143
  node.transformFlags |=
23136
23144
  propagateChildFlags(node.questionToken) |
23137
23145
  propagateChildFlags(node.exclamationToken) |
23138
- 8388608 /* ContainsClassFields */;
23146
+ 16777216 /* ContainsClassFields */;
23139
23147
  if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
23140
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23148
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23141
23149
  }
23142
23150
  if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
23143
23151
  node.transformFlags |= 1 /* ContainsTypeScript */;
@@ -23220,7 +23228,7 @@ var ts;
23220
23228
  /*name*/ undefined,
23221
23229
  /*typeParameters*/ undefined);
23222
23230
  node.body = body;
23223
- node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */;
23231
+ node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */;
23224
23232
  return node;
23225
23233
  }
23226
23234
  // @api
@@ -23744,11 +23752,11 @@ var ts;
23744
23752
  node.transformFlags |=
23745
23753
  propagateChildrenFlags(node.elements) |
23746
23754
  1024 /* ContainsES2015 */ |
23747
- 262144 /* ContainsBindingPattern */;
23748
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
23755
+ 524288 /* ContainsBindingPattern */;
23756
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
23749
23757
  node.transformFlags |=
23750
23758
  128 /* ContainsES2018 */ |
23751
- 32768 /* ContainsObjectRestOrSpread */;
23759
+ 65536 /* ContainsObjectRestOrSpread */;
23752
23760
  }
23753
23761
  return node;
23754
23762
  }
@@ -23765,7 +23773,7 @@ var ts;
23765
23773
  node.transformFlags |=
23766
23774
  propagateChildrenFlags(node.elements) |
23767
23775
  1024 /* ContainsES2015 */ |
23768
- 262144 /* ContainsBindingPattern */;
23776
+ 524288 /* ContainsBindingPattern */;
23769
23777
  return node;
23770
23778
  }
23771
23779
  // @api
@@ -23790,7 +23798,7 @@ var ts;
23790
23798
  propagateChildFlags(node.propertyName);
23791
23799
  }
23792
23800
  if (dotDotDotToken)
23793
- node.transformFlags |= 16384 /* ContainsRestOrSpread */;
23801
+ node.transformFlags |= 32768 /* ContainsRestOrSpread */;
23794
23802
  return node;
23795
23803
  }
23796
23804
  // @api
@@ -23965,10 +23973,10 @@ var ts;
23965
23973
  node.transformFlags |= 1 /* ContainsTypeScript */;
23966
23974
  }
23967
23975
  if (ts.isImportKeyword(node.expression)) {
23968
- node.transformFlags |= 4194304 /* ContainsDynamicImport */;
23976
+ node.transformFlags |= 8388608 /* ContainsDynamicImport */;
23969
23977
  }
23970
23978
  else if (ts.isSuperProperty(node.expression)) {
23971
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
23979
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
23972
23980
  }
23973
23981
  return node;
23974
23982
  }
@@ -24001,7 +24009,7 @@ var ts;
24001
24009
  node.transformFlags |= 1 /* ContainsTypeScript */;
24002
24010
  }
24003
24011
  if (ts.isSuperProperty(node.expression)) {
24004
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
24012
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
24005
24013
  }
24006
24014
  return node;
24007
24015
  }
@@ -24141,7 +24149,7 @@ var ts;
24141
24149
  propagateChildFlags(node.equalsGreaterThanToken) |
24142
24150
  1024 /* ContainsES2015 */;
24143
24151
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24144
- node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
24152
+ node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */;
24145
24153
  }
24146
24154
  return node;
24147
24155
  }
@@ -24203,7 +24211,7 @@ var ts;
24203
24211
  propagateChildFlags(node.expression) |
24204
24212
  256 /* ContainsES2017 */ |
24205
24213
  128 /* ContainsES2018 */ |
24206
- 1048576 /* ContainsAwait */;
24214
+ 2097152 /* ContainsAwait */;
24207
24215
  return node;
24208
24216
  }
24209
24217
  // @api
@@ -24224,7 +24232,7 @@ var ts;
24224
24232
  ts.isIdentifier(node.operand) &&
24225
24233
  !ts.isGeneratedIdentifier(node.operand) &&
24226
24234
  !ts.isLocalName(node.operand)) {
24227
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24235
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24228
24236
  }
24229
24237
  return node;
24230
24238
  }
@@ -24245,7 +24253,7 @@ var ts;
24245
24253
  if (ts.isIdentifier(node.operand) &&
24246
24254
  !ts.isGeneratedIdentifier(node.operand) &&
24247
24255
  !ts.isLocalName(node.operand)) {
24248
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24256
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24249
24257
  }
24250
24258
  return node;
24251
24259
  }
@@ -24294,8 +24302,8 @@ var ts;
24294
24302
  return node;
24295
24303
  }
24296
24304
  function propagateAssignmentPatternFlags(node) {
24297
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */)
24298
- return 32768 /* ContainsObjectRestOrSpread */;
24305
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */)
24306
+ return 65536 /* ContainsObjectRestOrSpread */;
24299
24307
  if (node.transformFlags & 128 /* ContainsES2018 */) {
24300
24308
  // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
24301
24309
  // will not be correctly interpreted by the ES2018 transformer
@@ -24303,8 +24311,8 @@ var ts;
24303
24311
  var element = _a[_i];
24304
24312
  var target = ts.getTargetOfBindingOrAssignmentElement(element);
24305
24313
  if (target && ts.isAssignmentPattern(target)) {
24306
- if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
24307
- return 32768 /* ContainsObjectRestOrSpread */;
24314
+ if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
24315
+ return 65536 /* ContainsObjectRestOrSpread */;
24308
24316
  }
24309
24317
  if (target.transformFlags & 128 /* ContainsES2018 */) {
24310
24318
  var flags_1 = propagateAssignmentPatternFlags(target);
@@ -24430,7 +24438,7 @@ var ts;
24430
24438
  propagateChildFlags(node.asteriskToken) |
24431
24439
  1024 /* ContainsES2015 */ |
24432
24440
  128 /* ContainsES2018 */ |
24433
- 524288 /* ContainsYield */;
24441
+ 1048576 /* ContainsYield */;
24434
24442
  return node;
24435
24443
  }
24436
24444
  // @api
@@ -24447,7 +24455,7 @@ var ts;
24447
24455
  node.transformFlags |=
24448
24456
  propagateChildFlags(node.expression) |
24449
24457
  1024 /* ContainsES2015 */ |
24450
- 16384 /* ContainsRestOrSpread */;
24458
+ 32768 /* ContainsRestOrSpread */;
24451
24459
  return node;
24452
24460
  }
24453
24461
  // @api
@@ -24780,7 +24788,7 @@ var ts;
24780
24788
  node.label = asName(label);
24781
24789
  node.transformFlags |=
24782
24790
  propagateChildFlags(node.label) |
24783
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24791
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24784
24792
  return node;
24785
24793
  }
24786
24794
  // @api
@@ -24795,7 +24803,7 @@ var ts;
24795
24803
  node.label = asName(label);
24796
24804
  node.transformFlags |=
24797
24805
  propagateChildFlags(node.label) |
24798
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24806
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24799
24807
  return node;
24800
24808
  }
24801
24809
  // @api
@@ -24812,7 +24820,7 @@ var ts;
24812
24820
  node.transformFlags |=
24813
24821
  propagateChildFlags(node.expression) |
24814
24822
  128 /* ContainsES2018 */ |
24815
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24823
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24816
24824
  return node;
24817
24825
  }
24818
24826
  // @api
@@ -24938,11 +24946,11 @@ var ts;
24938
24946
  node.declarations = createNodeArray(declarations);
24939
24947
  node.transformFlags |=
24940
24948
  propagateChildrenFlags(node.declarations) |
24941
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24949
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24942
24950
  if (flags & 3 /* BlockScoped */) {
24943
24951
  node.transformFlags |=
24944
24952
  1024 /* ContainsES2015 */ |
24945
- 131072 /* ContainsBlockScopedBinding */;
24953
+ 262144 /* ContainsBlockScopedBinding */;
24946
24954
  }
24947
24955
  return node;
24948
24956
  }
@@ -24962,7 +24970,7 @@ var ts;
24962
24970
  else {
24963
24971
  node.transformFlags |=
24964
24972
  propagateChildFlags(node.asteriskToken) |
24965
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24973
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24966
24974
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24967
24975
  if (node.asteriskToken) {
24968
24976
  node.transformFlags |= 128 /* ContainsES2018 */;
@@ -24998,7 +25006,7 @@ var ts;
24998
25006
  }
24999
25007
  else {
25000
25008
  node.transformFlags |= 1024 /* ContainsES2015 */;
25001
- if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) {
25009
+ if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) {
25002
25010
  node.transformFlags |= 1 /* ContainsTypeScript */;
25003
25011
  }
25004
25012
  }
@@ -25057,7 +25065,7 @@ var ts;
25057
25065
  node.transformFlags |=
25058
25066
  propagateChildrenFlags(node.members) |
25059
25067
  1 /* ContainsTypeScript */;
25060
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25068
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25061
25069
  return node;
25062
25070
  }
25063
25071
  // @api
@@ -25085,7 +25093,7 @@ var ts;
25085
25093
  propagateChildFlags(node.body) |
25086
25094
  1 /* ContainsTypeScript */;
25087
25095
  }
25088
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25096
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25089
25097
  return node;
25090
25098
  }
25091
25099
  // @api
@@ -25145,7 +25153,7 @@ var ts;
25145
25153
  node.transformFlags |= propagateChildFlags(node.moduleReference);
25146
25154
  if (!ts.isExternalModuleReference(node.moduleReference))
25147
25155
  node.transformFlags |= 1 /* ContainsTypeScript */;
25148
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25156
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25149
25157
  return node;
25150
25158
  }
25151
25159
  // @api
@@ -25167,7 +25175,7 @@ var ts;
25167
25175
  node.transformFlags |=
25168
25176
  propagateChildFlags(node.importClause) |
25169
25177
  propagateChildFlags(node.moduleSpecifier);
25170
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25178
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25171
25179
  return node;
25172
25180
  }
25173
25181
  // @api
@@ -25192,7 +25200,7 @@ var ts;
25192
25200
  if (isTypeOnly) {
25193
25201
  node.transformFlags |= 1 /* ContainsTypeScript */;
25194
25202
  }
25195
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25203
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25196
25204
  return node;
25197
25205
  }
25198
25206
  // @api
@@ -25252,7 +25260,7 @@ var ts;
25252
25260
  var node = createBaseNode(268 /* NamespaceImport */);
25253
25261
  node.name = name;
25254
25262
  node.transformFlags |= propagateChildFlags(node.name);
25255
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25263
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25256
25264
  return node;
25257
25265
  }
25258
25266
  // @api
@@ -25268,7 +25276,7 @@ var ts;
25268
25276
  node.transformFlags |=
25269
25277
  propagateChildFlags(node.name) |
25270
25278
  4 /* ContainsESNext */;
25271
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25279
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25272
25280
  return node;
25273
25281
  }
25274
25282
  // @api
@@ -25282,7 +25290,7 @@ var ts;
25282
25290
  var node = createBaseNode(269 /* NamedImports */);
25283
25291
  node.elements = createNodeArray(elements);
25284
25292
  node.transformFlags |= propagateChildrenFlags(node.elements);
25285
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25293
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25286
25294
  return node;
25287
25295
  }
25288
25296
  // @api
@@ -25300,7 +25308,7 @@ var ts;
25300
25308
  node.transformFlags |=
25301
25309
  propagateChildFlags(node.propertyName) |
25302
25310
  propagateChildFlags(node.name);
25303
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25311
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25304
25312
  return node;
25305
25313
  }
25306
25314
  // @api
@@ -25319,7 +25327,7 @@ var ts;
25319
25327
  ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression)
25320
25328
  : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
25321
25329
  node.transformFlags |= propagateChildFlags(node.expression);
25322
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25330
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25323
25331
  return node;
25324
25332
  }
25325
25333
  // @api
@@ -25340,7 +25348,7 @@ var ts;
25340
25348
  node.transformFlags |=
25341
25349
  propagateChildFlags(node.exportClause) |
25342
25350
  propagateChildFlags(node.moduleSpecifier);
25343
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25351
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25344
25352
  return node;
25345
25353
  }
25346
25354
  // @api
@@ -25359,7 +25367,7 @@ var ts;
25359
25367
  var node = createBaseNode(273 /* NamedExports */);
25360
25368
  node.elements = createNodeArray(elements);
25361
25369
  node.transformFlags |= propagateChildrenFlags(node.elements);
25362
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25370
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25363
25371
  return node;
25364
25372
  }
25365
25373
  // @api
@@ -25377,7 +25385,7 @@ var ts;
25377
25385
  node.transformFlags |=
25378
25386
  propagateChildFlags(node.propertyName) |
25379
25387
  propagateChildFlags(node.name);
25380
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25388
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25381
25389
  return node;
25382
25390
  }
25383
25391
  // @api
@@ -25403,7 +25411,7 @@ var ts;
25403
25411
  var node = createBaseNode(277 /* ExternalModuleReference */);
25404
25412
  node.expression = expression;
25405
25413
  node.transformFlags |= propagateChildFlags(node.expression);
25406
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25414
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25407
25415
  return node;
25408
25416
  }
25409
25417
  // @api
@@ -26177,7 +26185,7 @@ var ts;
26177
26185
  node.transformFlags |=
26178
26186
  propagateChildFlags(node.expression) |
26179
26187
  128 /* ContainsES2018 */ |
26180
- 32768 /* ContainsObjectRestOrSpread */;
26188
+ 65536 /* ContainsObjectRestOrSpread */;
26181
26189
  return node;
26182
26190
  }
26183
26191
  // @api
@@ -27134,10 +27142,10 @@ var ts;
27134
27142
  }
27135
27143
  function propagateIdentifierNameFlags(node) {
27136
27144
  // An IdentifierName is allowed to be `await`
27137
- return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */;
27145
+ return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
27138
27146
  }
27139
27147
  function propagatePropertyNameFlagsOfChild(node, transformFlags) {
27140
- return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */);
27148
+ return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */);
27141
27149
  }
27142
27150
  function propagateChildFlags(child) {
27143
27151
  if (!child)
@@ -27168,29 +27176,29 @@ var ts;
27168
27176
  case 208 /* CallExpression */:
27169
27177
  case 209 /* NewExpression */:
27170
27178
  case 204 /* ArrayLiteralExpression */:
27171
- return 536887296 /* ArrayLiteralOrCallOrNewExcludes */;
27179
+ return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27172
27180
  case 261 /* ModuleDeclaration */:
27173
- return 589443072 /* ModuleExcludes */;
27181
+ return 742678528 /* ModuleExcludes */;
27174
27182
  case 164 /* Parameter */:
27175
27183
  return 536870912 /* ParameterExcludes */;
27176
27184
  case 214 /* ArrowFunction */:
27177
- return 557748224 /* ArrowFunctionExcludes */;
27185
+ return 612179968 /* ArrowFunctionExcludes */;
27178
27186
  case 213 /* FunctionExpression */:
27179
27187
  case 256 /* FunctionDeclaration */:
27180
- return 591310848 /* FunctionExcludes */;
27188
+ return 746414080 /* FunctionExcludes */;
27181
27189
  case 255 /* VariableDeclarationList */:
27182
- return 537165824 /* VariableDeclarationListExcludes */;
27190
+ return 537460736 /* VariableDeclarationListExcludes */;
27183
27191
  case 257 /* ClassDeclaration */:
27184
27192
  case 226 /* ClassExpression */:
27185
- return 536940544 /* ClassExcludes */;
27193
+ return 537010176 /* ClassExcludes */;
27186
27194
  case 171 /* Constructor */:
27187
- return 591306752 /* ConstructorExcludes */;
27195
+ return 746405888 /* ConstructorExcludes */;
27188
27196
  case 167 /* PropertyDeclaration */:
27189
- return 570433536 /* PropertyExcludes */;
27197
+ return 671105024 /* PropertyExcludes */;
27190
27198
  case 169 /* MethodDeclaration */:
27191
27199
  case 172 /* GetAccessor */:
27192
27200
  case 173 /* SetAccessor */:
27193
- return 574529536 /* MethodOrAccessorExcludes */;
27201
+ return 679297024 /* MethodOrAccessorExcludes */;
27194
27202
  case 130 /* AnyKeyword */:
27195
27203
  case 147 /* NumberKeyword */:
27196
27204
  case 158 /* BigIntKeyword */:
@@ -27210,12 +27218,12 @@ var ts;
27210
27218
  case 259 /* TypeAliasDeclaration */:
27211
27219
  return -2 /* TypeExcludes */;
27212
27220
  case 205 /* ObjectLiteralExpression */:
27213
- return 536973312 /* ObjectLiteralExcludes */;
27221
+ return 537075712 /* ObjectLiteralExcludes */;
27214
27222
  case 292 /* CatchClause */:
27215
- return 536903680 /* CatchClauseExcludes */;
27223
+ return 536936448 /* CatchClauseExcludes */;
27216
27224
  case 201 /* ObjectBindingPattern */:
27217
27225
  case 202 /* ArrayBindingPattern */:
27218
- return 536887296 /* BindingPatternExcludes */;
27226
+ return 536903680 /* BindingPatternExcludes */;
27219
27227
  case 211 /* TypeAssertionExpression */:
27220
27228
  case 229 /* AsExpression */:
27221
27229
  case 350 /* PartiallyEmittedExpression */:
@@ -30449,6 +30457,14 @@ var ts;
30449
30457
  }
30450
30458
  }
30451
30459
  ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline;
30460
+ function elideNodes(factory, nodes) {
30461
+ if (nodes === undefined)
30462
+ return undefined;
30463
+ if (nodes.length === 0)
30464
+ return nodes;
30465
+ return ts.setTextRange(factory.createNodeArray([], nodes.hasTrailingComma), nodes);
30466
+ }
30467
+ ts.elideNodes = elideNodes;
30452
30468
  })(ts || (ts = {}));
30453
30469
  var ts;
30454
30470
  (function (ts) {
@@ -31620,7 +31636,7 @@ var ts;
31620
31636
  return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
31621
31637
  function containsPossibleTopLevelAwait(node) {
31622
31638
  return !(node.flags & 32768 /* AwaitContext */)
31623
- && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */);
31639
+ && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */);
31624
31640
  }
31625
31641
  function findNextStatementWithAwait(statements, start) {
31626
31642
  for (var i = start; i < statements.length; i++) {
@@ -31661,7 +31677,7 @@ var ts;
31661
31677
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31662
31678
  setFields(sourceFile);
31663
31679
  // If we parsed this as an external module, it may contain top-level await
31664
- if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31680
+ if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
31665
31681
  sourceFile = reparseTopLevelAwait(sourceFile);
31666
31682
  setFields(sourceFile);
31667
31683
  }
@@ -91059,6 +91075,124 @@ var ts;
91059
91075
  return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name);
91060
91076
  }
91061
91077
  ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName;
91078
+ /**
91079
+ * Gets an array of arrays of decorators for the parameters of a function-like node.
91080
+ * The offset into the result array should correspond to the offset of the parameter.
91081
+ *
91082
+ * @param node The function-like node.
91083
+ */
91084
+ function getDecoratorsOfParameters(node) {
91085
+ var decorators;
91086
+ if (node) {
91087
+ var parameters = node.parameters;
91088
+ var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
91089
+ var firstParameterOffset = firstParameterIsThis ? 1 : 0;
91090
+ var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
91091
+ for (var i = 0; i < numParameters; i++) {
91092
+ var parameter = parameters[i + firstParameterOffset];
91093
+ if (decorators || parameter.decorators) {
91094
+ if (!decorators) {
91095
+ decorators = new Array(numParameters);
91096
+ }
91097
+ decorators[i] = parameter.decorators;
91098
+ }
91099
+ }
91100
+ }
91101
+ return decorators;
91102
+ }
91103
+ /**
91104
+ * Gets an AllDecorators object containing the decorators for the class and the decorators for the
91105
+ * parameters of the constructor of the class.
91106
+ *
91107
+ * @param node The class node.
91108
+ */
91109
+ function getAllDecoratorsOfClass(node) {
91110
+ var decorators = node.decorators;
91111
+ var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
91112
+ if (!decorators && !parameters) {
91113
+ return undefined;
91114
+ }
91115
+ return {
91116
+ decorators: decorators,
91117
+ parameters: parameters
91118
+ };
91119
+ }
91120
+ ts.getAllDecoratorsOfClass = getAllDecoratorsOfClass;
91121
+ /**
91122
+ * Gets an AllDecorators object containing the decorators for the member and its parameters.
91123
+ *
91124
+ * @param parent The class node that contains the member.
91125
+ * @param member The class member.
91126
+ */
91127
+ function getAllDecoratorsOfClassElement(member, parent) {
91128
+ switch (member.kind) {
91129
+ case 172 /* GetAccessor */:
91130
+ case 173 /* SetAccessor */:
91131
+ return getAllDecoratorsOfAccessors(member, parent);
91132
+ case 169 /* MethodDeclaration */:
91133
+ return getAllDecoratorsOfMethod(member);
91134
+ case 167 /* PropertyDeclaration */:
91135
+ return getAllDecoratorsOfProperty(member);
91136
+ default:
91137
+ return undefined;
91138
+ }
91139
+ }
91140
+ ts.getAllDecoratorsOfClassElement = getAllDecoratorsOfClassElement;
91141
+ /**
91142
+ * Gets an AllDecorators object containing the decorators for the accessor and its parameters.
91143
+ *
91144
+ * @param parent The class node that contains the accessor.
91145
+ * @param accessor The class accessor member.
91146
+ */
91147
+ function getAllDecoratorsOfAccessors(accessor, parent) {
91148
+ if (!accessor.body) {
91149
+ return undefined;
91150
+ }
91151
+ var _a = ts.getAllAccessorDeclarations(parent.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
91152
+ var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
91153
+ if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
91154
+ return undefined;
91155
+ }
91156
+ var decorators = firstAccessorWithDecorators.decorators;
91157
+ var parameters = getDecoratorsOfParameters(setAccessor);
91158
+ if (!decorators && !parameters) {
91159
+ return undefined;
91160
+ }
91161
+ return {
91162
+ decorators: decorators,
91163
+ parameters: parameters,
91164
+ getDecorators: getAccessor === null || getAccessor === void 0 ? void 0 : getAccessor.decorators,
91165
+ setDecorators: setAccessor === null || setAccessor === void 0 ? void 0 : setAccessor.decorators
91166
+ };
91167
+ }
91168
+ /**
91169
+ * Gets an AllDecorators object containing the decorators for the method and its parameters.
91170
+ *
91171
+ * @param method The class method member.
91172
+ */
91173
+ function getAllDecoratorsOfMethod(method) {
91174
+ if (!method.body) {
91175
+ return undefined;
91176
+ }
91177
+ var decorators = method.decorators;
91178
+ var parameters = getDecoratorsOfParameters(method);
91179
+ if (!decorators && !parameters) {
91180
+ return undefined;
91181
+ }
91182
+ return { decorators: decorators, parameters: parameters };
91183
+ }
91184
+ /**
91185
+ * Gets an AllDecorators object containing the decorators for the property.
91186
+ *
91187
+ * @param property The class property member.
91188
+ */
91189
+ function getAllDecoratorsOfProperty(property) {
91190
+ var decorators = property.decorators;
91191
+ if (!decorators) {
91192
+ return undefined;
91193
+ }
91194
+ return { decorators: decorators };
91195
+ }
91062
91196
  })(ts || (ts = {}));
91063
91197
  /*@internal*/
91064
91198
  var ts;
@@ -91332,8 +91466,8 @@ var ts;
91332
91466
  if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
91333
91467
  var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
91334
91468
  if (flattenContext.level >= 1 /* ObjectRest */
91335
- && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91336
- && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91469
+ && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91470
+ && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91337
91471
  && !ts.isComputedPropertyName(propertyName)) {
91338
91472
  bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
91339
91473
  }
@@ -91399,7 +91533,7 @@ var ts;
91399
91533
  if (flattenContext.level >= 1 /* ObjectRest */) {
91400
91534
  // If an array pattern contains an ObjectRest, we must cache the result so that we
91401
91535
  // can perform the ObjectRest destructuring in a different declaration
91402
- if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91536
+ if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91403
91537
  flattenContext.hasTransformedPriorElement = true;
91404
91538
  var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
91405
91539
  if (flattenContext.hoistTempVariables) {
@@ -91621,8 +91755,6 @@ var ts;
91621
91755
  var USE_NEW_TYPE_METADATA_FORMAT = false;
91622
91756
  var TypeScriptSubstitutionFlags;
91623
91757
  (function (TypeScriptSubstitutionFlags) {
91624
- /** Enables substitutions for decorated classes. */
91625
- TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases";
91626
91758
  /** Enables substitutions for namespace exports. */
91627
91759
  TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports";
91628
91760
  /* Enables substitutions for unqualified enum members */
@@ -91648,9 +91780,9 @@ var ts;
91648
91780
  var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
91649
91781
  var resolver = context.getEmitResolver();
91650
91782
  var compilerOptions = context.getCompilerOptions();
91651
- var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
91652
91783
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
91653
91784
  var moduleKind = ts.getEmitModuleKind(compilerOptions);
91785
+ var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined;
91654
91786
  // Save the previous transformation hooks.
91655
91787
  var previousOnEmitNode = context.onEmitNode;
91656
91788
  var previousOnSubstituteNode = context.onSubstituteNode;
@@ -91665,7 +91797,6 @@ var ts;
91665
91797
  var currentNamespace;
91666
91798
  var currentNamespaceContainerName;
91667
91799
  var currentLexicalScope;
91668
- var currentNameScope;
91669
91800
  var currentScopeFirstDeclarationsOfName;
91670
91801
  var currentClassHasParameterProperties;
91671
91802
  /**
@@ -91673,11 +91804,6 @@ var ts;
91673
91804
  * They are persisted between each SourceFile transformation and should not be reset.
91674
91805
  */
91675
91806
  var enabledSubstitutions;
91676
- /**
91677
- * A map that keeps track of aliases created for classes with decorators to avoid issues
91678
- * with the double-binding behavior of classes.
91679
- */
91680
- var classAliases;
91681
91807
  /**
91682
91808
  * Keeps track of whether we are within any containing namespaces when performing
91683
91809
  * just-in-time substitution while printing an expression identifier.
@@ -91721,7 +91847,6 @@ var ts;
91721
91847
  function saveStateAndInvoke(node, f) {
91722
91848
  // Save state
91723
91849
  var savedCurrentScope = currentLexicalScope;
91724
- var savedCurrentNameScope = currentNameScope;
91725
91850
  var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
91726
91851
  var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
91727
91852
  // Handle state changes before visiting a node.
@@ -91732,7 +91857,6 @@ var ts;
91732
91857
  currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
91733
91858
  }
91734
91859
  currentLexicalScope = savedCurrentScope;
91735
- currentNameScope = savedCurrentNameScope;
91736
91860
  currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
91737
91861
  return visited;
91738
91862
  }
@@ -91748,7 +91872,6 @@ var ts;
91748
91872
  case 262 /* ModuleBlock */:
91749
91873
  case 235 /* Block */:
91750
91874
  currentLexicalScope = node;
91751
- currentNameScope = undefined;
91752
91875
  currentScopeFirstDeclarationsOfName = undefined;
91753
91876
  break;
91754
91877
  case 257 /* ClassDeclaration */:
@@ -91766,10 +91889,6 @@ var ts;
91766
91889
  // programs may also have an undefined name.
91767
91890
  ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
91768
91891
  }
91769
- if (ts.isClassDeclaration(node)) {
91770
- // XXX: should probably also cover interfaces and type aliases that can have type variables?
91771
- currentNameScope = node;
91772
- }
91773
91892
  break;
91774
91893
  }
91775
91894
  }
@@ -91871,35 +91990,66 @@ var ts;
91871
91990
  return node;
91872
91991
  }
91873
91992
  /**
91874
- * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
91993
+ * Gets a specialized visitor that visits the immediate children of a class with TypeScript syntax.
91875
91994
  *
91876
- * @param node The node to visit.
91995
+ * @param parent The class containing the elements to visit.
91877
91996
  */
91878
- function classElementVisitor(node) {
91879
- return saveStateAndInvoke(node, classElementVisitorWorker);
91997
+ function getClassElementVisitor(parent) {
91998
+ return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); };
91880
91999
  }
91881
92000
  /**
91882
92001
  * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
91883
92002
  *
91884
92003
  * @param node The node to visit.
91885
92004
  */
91886
- function classElementVisitorWorker(node) {
92005
+ function classElementVisitorWorker(node, parent) {
91887
92006
  switch (node.kind) {
91888
92007
  case 171 /* Constructor */:
91889
92008
  return visitConstructor(node);
91890
92009
  case 167 /* PropertyDeclaration */:
91891
92010
  // Property declarations are not TypeScript syntax, but they must be visited
91892
92011
  // for the decorator transformation.
91893
- return visitPropertyDeclaration(node);
91894
- case 176 /* IndexSignature */:
92012
+ return visitPropertyDeclaration(node, parent);
91895
92013
  case 172 /* GetAccessor */:
92014
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92015
+ return visitGetAccessor(node, parent);
91896
92016
  case 173 /* SetAccessor */:
92017
+ // Set Accessors can have TypeScript modifiers and type annotations.
92018
+ return visitSetAccessor(node, parent);
91897
92019
  case 169 /* MethodDeclaration */:
92020
+ // TypeScript method declarations may have decorators, modifiers
92021
+ // or type annotations.
92022
+ return visitMethodDeclaration(node, parent);
91898
92023
  case 170 /* ClassStaticBlockDeclaration */:
91899
- // Fallback to the default visit behavior.
91900
- return visitorWorker(node);
92024
+ return ts.visitEachChild(node, visitor, context);
91901
92025
  case 234 /* SemicolonClassElement */:
91902
92026
  return node;
92027
+ case 176 /* IndexSignature */:
92028
+ // Index signatures are elided
92029
+ return;
92030
+ default:
92031
+ return ts.Debug.failBadSyntaxKind(node);
92032
+ }
92033
+ }
92034
+ function getObjectLiteralElementVisitor(parent) {
92035
+ return function (node) { return saveStateAndInvoke(node, function (n) { return objectLiteralElementVisitorWorker(n, parent); }); };
92036
+ }
92037
+ function objectLiteralElementVisitorWorker(node, parent) {
92038
+ switch (node.kind) {
92039
+ case 296 /* PropertyAssignment */:
92040
+ case 297 /* ShorthandPropertyAssignment */:
92041
+ case 298 /* SpreadAssignment */:
92042
+ return visitor(node);
92043
+ case 172 /* GetAccessor */:
92044
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92045
+ return visitGetAccessor(node, parent);
92046
+ case 173 /* SetAccessor */:
92047
+ // Set Accessors can have TypeScript modifiers and type annotations.
92048
+ return visitSetAccessor(node, parent);
92049
+ case 169 /* MethodDeclaration */:
92050
+ // TypeScript method declarations may have decorators, modifiers
92051
+ // or type annotations.
92052
+ return visitMethodDeclaration(node, parent);
91903
92053
  default:
91904
92054
  return ts.Debug.failBadSyntaxKind(node);
91905
92055
  }
@@ -91972,22 +92122,14 @@ var ts;
91972
92122
  // TypeScript type nodes are elided.
91973
92123
  // falls through
91974
92124
  case 176 /* IndexSignature */:
91975
- // TypeScript index signatures are elided.
91976
- // falls through
91977
- case 165 /* Decorator */:
91978
- // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
92125
+ // TypeScript index signatures are elided.
91979
92126
  return undefined;
91980
92127
  case 259 /* TypeAliasDeclaration */:
91981
92128
  // TypeScript type-only declarations are elided.
91982
92129
  return factory.createNotEmittedStatement(node);
91983
- case 167 /* PropertyDeclaration */:
91984
- // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
91985
- return visitPropertyDeclaration(node);
91986
92130
  case 264 /* NamespaceExportDeclaration */:
91987
92131
  // TypeScript namespace export declarations are elided.
91988
92132
  return undefined;
91989
- case 171 /* Constructor */:
91990
- return visitConstructor(node);
91991
92133
  case 258 /* InterfaceDeclaration */:
91992
92134
  // TypeScript interfaces are elided, but some comments may be preserved.
91993
92135
  // See the implementation of `getLeadingComments` in comments.ts for more details.
@@ -92021,16 +92163,15 @@ var ts;
92021
92163
  case 228 /* ExpressionWithTypeArguments */:
92022
92164
  // TypeScript supports type arguments on an expression in an `extends` heritage clause.
92023
92165
  return visitExpressionWithTypeArguments(node);
92166
+ case 205 /* ObjectLiteralExpression */:
92167
+ return visitObjectLiteralExpression(node);
92168
+ case 171 /* Constructor */:
92169
+ case 167 /* PropertyDeclaration */:
92024
92170
  case 169 /* MethodDeclaration */:
92025
- // TypeScript method declarations may have decorators, modifiers
92026
- // or type annotations.
92027
- return visitMethodDeclaration(node);
92028
92171
  case 172 /* GetAccessor */:
92029
- // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92030
- return visitGetAccessor(node);
92031
92172
  case 173 /* SetAccessor */:
92032
- // Set Accessors can have TypeScript modifiers and type annotations.
92033
- return visitSetAccessor(node);
92173
+ case 170 /* ClassStaticBlockDeclaration */:
92174
+ return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors");
92034
92175
  case 256 /* FunctionDeclaration */:
92035
92176
  // Typescript function declarations can have modifiers, decorators, and type annotations.
92036
92177
  return visitFunctionDeclaration(node);
@@ -92096,6 +92237,9 @@ var ts;
92096
92237
  !ts.isJsonSourceFile(node);
92097
92238
  return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
92098
92239
  }
92240
+ function visitObjectLiteralExpression(node) {
92241
+ return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement));
92242
+ }
92099
92243
  function getClassFacts(node, staticProperties) {
92100
92244
  var facts = 0 /* None */;
92101
92245
  if (ts.some(staticProperties))
@@ -92118,7 +92262,7 @@ var ts;
92118
92262
  return facts;
92119
92263
  }
92120
92264
  function hasTypeScriptClassSyntax(node) {
92121
- return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */);
92265
+ return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */);
92122
92266
  }
92123
92267
  function isClassLikeDeclarationWithTypeScriptSyntax(node) {
92124
92268
  return ts.some(node.decorators)
@@ -92128,7 +92272,9 @@ var ts;
92128
92272
  }
92129
92273
  function visitClassDeclaration(node) {
92130
92274
  if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
92131
- return ts.visitEachChild(node, visitor, context);
92275
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92276
+ ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name,
92277
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92132
92278
  }
92133
92279
  var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
92134
92280
  var facts = getClassFacts(node, staticProperties);
@@ -92136,14 +92282,25 @@ var ts;
92136
92282
  context.startLexicalEnvironment();
92137
92283
  }
92138
92284
  var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
92139
- var classStatement = facts & 2 /* HasConstructorDecorators */
92140
- ? createClassDeclarationHeadWithDecorators(node, name)
92141
- : createClassDeclarationHeadWithoutDecorators(node, name, facts);
92285
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92286
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92287
+ // we do not emit modifiers on the declaration if we are emitting an IIFE
92288
+ var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92289
+ ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92290
+ : ts.elideNodes(factory, node.modifiers); // preserve positions, if available
92291
+ // ${modifiers} class ${name} ${heritageClauses} {
92292
+ // ${members}
92293
+ // }
92294
+ var classStatement = factory.updateClassDeclaration(node, decorators, modifiers, name,
92295
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92296
+ // To better align with the old emitter, we should not emit a trailing source map
92297
+ // entry if the class has static properties.
92298
+ var emitFlags = ts.getEmitFlags(node);
92299
+ if (facts & 1 /* HasStaticInitializedProperties */) {
92300
+ emitFlags |= 32 /* NoTrailingSourceMap */;
92301
+ }
92302
+ ts.setEmitFlags(classStatement, emitFlags);
92142
92303
  var statements = [classStatement];
92143
- // Write any decorators of the node.
92144
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
92145
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
92146
- addConstructorDecorationStatement(statements, node);
92147
92304
  if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
92148
92305
  // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
92149
92306
  // 'es2015' transformer can properly nest static initializers and decorators. The result
@@ -92203,164 +92360,14 @@ var ts;
92203
92360
  }
92204
92361
  return ts.singleOrMany(statements);
92205
92362
  }
92206
- /**
92207
- * Transforms a non-decorated class declaration and appends the resulting statements.
92208
- *
92209
- * @param node A ClassDeclaration node.
92210
- * @param name The name of the class.
92211
- * @param facts Precomputed facts about the class.
92212
- */
92213
- function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
92214
- // ${modifiers} class ${name} ${heritageClauses} {
92215
- // ${members}
92216
- // }
92217
- // we do not emit modifiers on the declaration if we are emitting an IIFE
92218
- var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92219
- ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92220
- : undefined;
92221
- var classDeclaration = factory.createClassDeclaration(
92222
- /*decorators*/ undefined, modifiers, name,
92223
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92224
- // To better align with the old emitter, we should not emit a trailing source map
92225
- // entry if the class has static properties.
92226
- var emitFlags = ts.getEmitFlags(node);
92227
- if (facts & 1 /* HasStaticInitializedProperties */) {
92228
- emitFlags |= 32 /* NoTrailingSourceMap */;
92229
- }
92230
- ts.setTextRange(classDeclaration, node);
92231
- ts.setOriginalNode(classDeclaration, node);
92232
- ts.setEmitFlags(classDeclaration, emitFlags);
92233
- return classDeclaration;
92234
- }
92235
- /**
92236
- * Transforms a decorated class declaration and appends the resulting statements. If
92237
- * the class requires an alias to avoid issues with double-binding, the alias is returned.
92238
- */
92239
- function createClassDeclarationHeadWithDecorators(node, name) {
92240
- // When we emit an ES6 class that has a class decorator, we must tailor the
92241
- // emit to certain specific cases.
92242
- //
92243
- // In the simplest case, we emit the class declaration as a let declaration, and
92244
- // evaluate decorators after the close of the class body:
92245
- //
92246
- // [Example 1]
92247
- // ---------------------------------------------------------------------
92248
- // TypeScript | Javascript
92249
- // ---------------------------------------------------------------------
92250
- // @dec | let C = class C {
92251
- // class C { | }
92252
- // } | C = __decorate([dec], C);
92253
- // ---------------------------------------------------------------------
92254
- // @dec | let C = class C {
92255
- // export class C { | }
92256
- // } | C = __decorate([dec], C);
92257
- // | export { C };
92258
- // ---------------------------------------------------------------------
92259
- //
92260
- // If a class declaration contains a reference to itself *inside* of the class body,
92261
- // this introduces two bindings to the class: One outside of the class body, and one
92262
- // inside of the class body. If we apply decorators as in [Example 1] above, there
92263
- // is the possibility that the decorator `dec` will return a new value for the
92264
- // constructor, which would result in the binding inside of the class no longer
92265
- // pointing to the same reference as the binding outside of the class.
92266
- //
92267
- // As a result, we must instead rewrite all references to the class *inside* of the
92268
- // class body to instead point to a local temporary alias for the class:
92269
- //
92270
- // [Example 2]
92271
- // ---------------------------------------------------------------------
92272
- // TypeScript | Javascript
92273
- // ---------------------------------------------------------------------
92274
- // @dec | let C = C_1 = class C {
92275
- // class C { | static x() { return C_1.y; }
92276
- // static x() { return C.y; } | }
92277
- // static y = 1; | C.y = 1;
92278
- // } | C = C_1 = __decorate([dec], C);
92279
- // | var C_1;
92280
- // ---------------------------------------------------------------------
92281
- // @dec | let C = class C {
92282
- // export class C { | static x() { return C_1.y; }
92283
- // static x() { return C.y; } | }
92284
- // static y = 1; | C.y = 1;
92285
- // } | C = C_1 = __decorate([dec], C);
92286
- // | export { C };
92287
- // | var C_1;
92288
- // ---------------------------------------------------------------------
92289
- //
92290
- // If a class declaration is the default export of a module, we instead emit
92291
- // the export after the decorated declaration:
92292
- //
92293
- // [Example 3]
92294
- // ---------------------------------------------------------------------
92295
- // TypeScript | Javascript
92296
- // ---------------------------------------------------------------------
92297
- // @dec | let default_1 = class {
92298
- // export default class { | }
92299
- // } | default_1 = __decorate([dec], default_1);
92300
- // | export default default_1;
92301
- // ---------------------------------------------------------------------
92302
- // @dec | let C = class C {
92303
- // export default class C { | }
92304
- // } | C = __decorate([dec], C);
92305
- // | export default C;
92306
- // ---------------------------------------------------------------------
92307
- //
92308
- // If the class declaration is the default export and a reference to itself
92309
- // inside of the class body, we must emit both an alias for the class *and*
92310
- // move the export after the declaration:
92311
- //
92312
- // [Example 4]
92313
- // ---------------------------------------------------------------------
92314
- // TypeScript | Javascript
92315
- // ---------------------------------------------------------------------
92316
- // @dec | let C = class C {
92317
- // export default class C { | static x() { return C_1.y; }
92318
- // static x() { return C.y; } | }
92319
- // static y = 1; | C.y = 1;
92320
- // } | C = C_1 = __decorate([dec], C);
92321
- // | export default C;
92322
- // | var C_1;
92323
- // ---------------------------------------------------------------------
92324
- //
92325
- var location = ts.moveRangePastDecorators(node);
92326
- var classAlias = getClassAliasIfNeeded(node);
92327
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92328
- // without any block-scoped variable collision handling
92329
- var declName = languageVersion <= 2 /* ES2015 */ ?
92330
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92331
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92332
- // ... = class ${name} ${heritageClauses} {
92333
- // ${members}
92334
- // }
92335
- var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
92336
- var members = transformClassMembers(node);
92337
- var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
92338
- ts.setOriginalNode(classExpression, node);
92339
- ts.setTextRange(classExpression, location);
92340
- // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
92341
- // or decoratedClassAlias if the class contain self-reference.
92342
- var statement = factory.createVariableStatement(
92343
- /*modifiers*/ undefined, factory.createVariableDeclarationList([
92344
- factory.createVariableDeclaration(declName,
92345
- /*exclamationToken*/ undefined,
92346
- /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
92347
- ], 1 /* Let */));
92348
- ts.setOriginalNode(statement, node);
92349
- ts.setTextRange(statement, location);
92350
- ts.setCommentRange(statement, node);
92351
- return statement;
92352
- }
92353
92363
  function visitClassExpression(node) {
92354
- if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
92355
- return ts.visitEachChild(node, visitor, context);
92356
- }
92357
- var classExpression = factory.createClassExpression(
92358
- /*decorators*/ undefined,
92364
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92365
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92366
+ return factory.updateClassExpression(node, decorators,
92359
92367
  /*modifiers*/ undefined, node.name,
92360
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92361
- ts.setOriginalNode(classExpression, node);
92362
- ts.setTextRange(classExpression, node);
92363
- return classExpression;
92368
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), isClassLikeDeclarationWithTypeScriptSyntax(node) ?
92369
+ transformClassMembers(node) :
92370
+ ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92364
92371
  }
92365
92372
  /**
92366
92373
  * Transforms the members of a class.
@@ -92385,48 +92392,9 @@ var ts;
92385
92392
  }
92386
92393
  }
92387
92394
  }
92388
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
92395
+ ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92389
92396
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
92390
92397
  }
92391
- /**
92392
- * Gets either the static or instance members of a class that are decorated, or have
92393
- * parameters that are decorated.
92394
- *
92395
- * @param node The class containing the member.
92396
- * @param isStatic A value indicating whether to retrieve static or instance members of
92397
- * the class.
92398
- */
92399
- function getDecoratedClassElements(node, isStatic) {
92400
- return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
92401
- }
92402
- /**
92403
- * Determines whether a class member is a static member of a class that is decorated, or
92404
- * has parameters that are decorated.
92405
- *
92406
- * @param member The class member.
92407
- */
92408
- function isStaticDecoratedClassElement(member, parent) {
92409
- return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
92410
- }
92411
- /**
92412
- * Determines whether a class member is an instance member of a class that is decorated,
92413
- * or has parameters that are decorated.
92414
- *
92415
- * @param member The class member.
92416
- */
92417
- function isInstanceDecoratedClassElement(member, parent) {
92418
- return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
92419
- }
92420
- /**
92421
- * Determines whether a class member is either a static or an instance member of a class
92422
- * that is decorated, or has parameters that are decorated.
92423
- *
92424
- * @param member The class member.
92425
- */
92426
- function isDecoratedClassElement(member, isStaticElement, parent) {
92427
- return ts.nodeOrChildIsDecorated(member, parent)
92428
- && isStaticElement === ts.isStatic(member);
92429
- }
92430
92398
  /**
92431
92399
  * Gets an array of arrays of decorators for the parameters of a function-like node.
92432
92400
  * The offset into the result array should correspond to the offset of the parameter.
@@ -92472,14 +92440,14 @@ var ts;
92472
92440
  /**
92473
92441
  * Gets an AllDecorators object containing the decorators for the member and its parameters.
92474
92442
  *
92475
- * @param node The class node that contains the member.
92443
+ * @param parent The class node that contains the member.
92476
92444
  * @param member The class member.
92477
92445
  */
92478
- function getAllDecoratorsOfClassElement(node, member) {
92446
+ function getAllDecoratorsOfClassElement(member, parent) {
92479
92447
  switch (member.kind) {
92480
92448
  case 172 /* GetAccessor */:
92481
92449
  case 173 /* SetAccessor */:
92482
- return getAllDecoratorsOfAccessors(node, member);
92450
+ return getAllDecoratorsOfAccessors(parent, member);
92483
92451
  case 169 /* MethodDeclaration */:
92484
92452
  return getAllDecoratorsOfMethod(member);
92485
92453
  case 167 /* PropertyDeclaration */:
@@ -92548,209 +92516,82 @@ var ts;
92548
92516
  if (!allDecorators) {
92549
92517
  return undefined;
92550
92518
  }
92551
- var decoratorExpressions = [];
92552
- ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
92553
- ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
92554
- addTypeMetadata(node, container, decoratorExpressions);
92555
- return decoratorExpressions;
92556
- }
92557
- /**
92558
- * Generates statements used to apply decorators to either the static or instance members
92559
- * of a class.
92560
- *
92561
- * @param node The class node.
92562
- * @param isStatic A value indicating whether to generate statements for static or
92563
- * instance members.
92564
- */
92565
- function addClassElementDecorationStatements(statements, node, isStatic) {
92566
- ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
92567
- }
92568
- /**
92569
- * Generates expressions used to apply decorators to either the static or instance members
92570
- * of a class.
92571
- *
92572
- * @param node The class node.
92573
- * @param isStatic A value indicating whether to generate expressions for static or
92574
- * instance members.
92575
- */
92576
- function generateClassElementDecorationExpressions(node, isStatic) {
92577
- var members = getDecoratedClassElements(node, isStatic);
92578
- var expressions;
92579
- for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
92580
- var member = members_8[_i];
92581
- var expression = generateClassElementDecorationExpression(node, member);
92582
- if (expression) {
92583
- if (!expressions) {
92584
- expressions = [expression];
92585
- }
92586
- else {
92587
- expressions.push(expression);
92588
- }
92589
- }
92590
- }
92591
- return expressions;
92592
- }
92593
- /**
92594
- * Generates an expression used to evaluate class element decorators at runtime.
92595
- *
92596
- * @param node The class node that contains the member.
92597
- * @param member The class member.
92598
- */
92599
- function generateClassElementDecorationExpression(node, member) {
92600
- var allDecorators = getAllDecoratorsOfClassElement(node, member);
92601
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
92602
- if (!decoratorExpressions) {
92603
- return undefined;
92604
- }
92605
- // Emit the call to __decorate. Given the following:
92606
- //
92607
- // class C {
92608
- // @dec method(@dec2 x) {}
92609
- // @dec get accessor() {}
92610
- // @dec prop;
92611
- // }
92612
- //
92613
- // The emit for a method is:
92614
- //
92615
- // __decorate([
92616
- // dec,
92617
- // __param(0, dec2),
92618
- // __metadata("design:type", Function),
92619
- // __metadata("design:paramtypes", [Object]),
92620
- // __metadata("design:returntype", void 0)
92621
- // ], C.prototype, "method", null);
92622
- //
92623
- // The emit for an accessor is:
92624
- //
92625
- // __decorate([
92626
- // dec
92627
- // ], C.prototype, "accessor", null);
92628
- //
92629
- // The emit for a property is:
92630
- //
92631
- // __decorate([
92632
- // dec
92633
- // ], C.prototype, "prop");
92634
- //
92635
- var prefix = getClassMemberPrefix(node, member);
92636
- var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
92637
- var descriptor = languageVersion > 0 /* ES3 */
92638
- ? member.kind === 167 /* PropertyDeclaration */
92639
- // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
92640
- // should not invoke `Object.getOwnPropertyDescriptor`.
92641
- ? factory.createVoidZero()
92642
- // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
92643
- // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
92644
- : factory.createNull()
92645
- : undefined;
92646
- var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
92647
- ts.setTextRange(helper, ts.moveRangePastDecorators(member));
92648
- ts.setEmitFlags(helper, 1536 /* NoComments */);
92649
- return helper;
92650
- }
92651
- /**
92652
- * Generates a __decorate helper call for a class constructor.
92653
- *
92654
- * @param node The class node.
92655
- */
92656
- function addConstructorDecorationStatement(statements, node) {
92657
- var expression = generateConstructorDecorationExpression(node);
92658
- if (expression) {
92659
- statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
92660
- }
92661
- }
92662
- /**
92663
- * Generates a __decorate helper call for a class constructor.
92664
- *
92665
- * @param node The class node.
92666
- */
92667
- function generateConstructorDecorationExpression(node) {
92668
- var allDecorators = getAllDecoratorsOfConstructor(node);
92669
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92670
- if (!decoratorExpressions) {
92671
- return undefined;
92672
- }
92673
- var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
92674
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92675
- // without any block-scoped variable collision handling
92676
- var localName = languageVersion <= 2 /* ES2015 */ ?
92677
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92678
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92679
- var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
92680
- var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
92681
- ts.setEmitFlags(expression, 1536 /* NoComments */);
92682
- ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
92683
- return expression;
92684
- }
92685
- /**
92686
- * Transforms a decorator into an expression.
92687
- *
92688
- * @param decorator The decorator node.
92689
- */
92690
- function transformDecorator(decorator) {
92691
- return ts.visitNode(decorator.expression, visitor, ts.isExpression);
92519
+ var decorators = ts.visitNodes(allDecorators.decorators, visitor, ts.isDecorator);
92520
+ var parameterDecorators = ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter);
92521
+ var metadataDecorators = ts.some(decorators) || ts.some(parameterDecorators) ? getTypeMetadata(node, container) : undefined;
92522
+ var result = factory.createNodeArray(ts.concatenate(ts.concatenate(decorators, parameterDecorators), metadataDecorators));
92523
+ ts.setTextRange(result, decorators);
92524
+ return result;
92692
92525
  }
92693
92526
  /**
92694
- * Transforms the decorators of a parameter.
92527
+ * Transforms the decorators of a parameter into decorators of the class/method.
92695
92528
  *
92696
- * @param decorators The decorators for the parameter at the provided offset.
92529
+ * @param parameterDecorators The decorators for the parameter at the provided offset.
92697
92530
  * @param parameterOffset The offset of the parameter.
92698
92531
  */
92699
- function transformDecoratorsOfParameter(decorators, parameterOffset) {
92700
- var expressions;
92701
- if (decorators) {
92702
- expressions = [];
92703
- for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
92704
- var decorator = decorators_1[_i];
92705
- var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
92706
- ts.setTextRange(helper, decorator.expression);
92532
+ function transformDecoratorsOfParameter(parameterDecorators, parameterOffset) {
92533
+ if (parameterDecorators) {
92534
+ var decorators = [];
92535
+ for (var _i = 0, parameterDecorators_1 = parameterDecorators; _i < parameterDecorators_1.length; _i++) {
92536
+ var parameterDecorator = parameterDecorators_1[_i];
92537
+ var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression);
92538
+ var helper = emitHelpers().createParamHelper(expression, parameterOffset);
92539
+ ts.setTextRange(helper, parameterDecorator.expression);
92707
92540
  ts.setEmitFlags(helper, 1536 /* NoComments */);
92708
- expressions.push(helper);
92541
+ var decorator = factory.createDecorator(helper);
92542
+ ts.setTextRange(decorator, parameterDecorator.expression);
92543
+ ts.setEmitFlags(decorator, 1536 /* NoComments */);
92544
+ decorators.push(decorator);
92709
92545
  }
92546
+ return decorators;
92710
92547
  }
92711
- return expressions;
92712
92548
  }
92713
92549
  /**
92714
- * Adds optional type metadata for a declaration.
92550
+ * Gets optional type metadata for a declaration.
92715
92551
  *
92716
92552
  * @param node The declaration node.
92717
- * @param decoratorExpressions The destination array to which to add new decorator expressions.
92718
92553
  */
92719
- function addTypeMetadata(node, container, decoratorExpressions) {
92720
- if (USE_NEW_TYPE_METADATA_FORMAT) {
92721
- addNewTypeMetadata(node, container, decoratorExpressions);
92722
- }
92723
- else {
92724
- addOldTypeMetadata(node, container, decoratorExpressions);
92725
- }
92554
+ function getTypeMetadata(node, container) {
92555
+ return USE_NEW_TYPE_METADATA_FORMAT ?
92556
+ getNewTypeMetadata(node, container) :
92557
+ getOldTypeMetadata(node, container);
92726
92558
  }
92727
- function addOldTypeMetadata(node, container, decoratorExpressions) {
92728
- if (compilerOptions.emitDecoratorMetadata) {
92559
+ function getOldTypeMetadata(node, container) {
92560
+ if (typeSerializer) {
92561
+ var decorators = void 0;
92729
92562
  if (shouldAddTypeMetadata(node)) {
92730
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
92563
+ var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92564
+ decorators = ts.append(decorators, factory.createDecorator(typeMetadata));
92731
92565
  }
92732
92566
  if (shouldAddParamTypesMetadata(node)) {
92733
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
92567
+ var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container));
92568
+ decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata));
92734
92569
  }
92735
92570
  if (shouldAddReturnTypeMetadata(node)) {
92736
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
92571
+ var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92572
+ decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata));
92737
92573
  }
92574
+ return decorators;
92738
92575
  }
92739
92576
  }
92740
- function addNewTypeMetadata(node, container, decoratorExpressions) {
92741
- if (compilerOptions.emitDecoratorMetadata) {
92577
+ function getNewTypeMetadata(node, container) {
92578
+ if (typeSerializer) {
92742
92579
  var properties = void 0;
92743
92580
  if (shouldAddTypeMetadata(node)) {
92744
- (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node))));
92581
+ var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92582
+ properties = ts.append(properties, typeProperty);
92745
92583
  }
92746
92584
  if (shouldAddParamTypesMetadata(node)) {
92747
- (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container))));
92585
+ var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container)));
92586
+ properties = ts.append(properties, paramTypeProperty);
92748
92587
  }
92749
92588
  if (shouldAddReturnTypeMetadata(node)) {
92750
- (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node))));
92589
+ var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92590
+ properties = ts.append(properties, returnTypeProperty);
92751
92591
  }
92752
92592
  if (properties) {
92753
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true)));
92593
+ var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true));
92594
+ return [factory.createDecorator(typeInfoMetadata)];
92754
92595
  }
92755
92596
  }
92756
92597
  }
@@ -92797,347 +92638,6 @@ var ts;
92797
92638
  }
92798
92639
  return false;
92799
92640
  }
92800
- function getAccessorTypeNode(node) {
92801
- var accessors = resolver.getAllAccessorDeclarations(node);
92802
- return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
92803
- || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
92804
- }
92805
- /**
92806
- * Serializes the type of a node for use with decorator type metadata.
92807
- *
92808
- * @param node The node that should have its type serialized.
92809
- */
92810
- function serializeTypeOfNode(node) {
92811
- switch (node.kind) {
92812
- case 167 /* PropertyDeclaration */:
92813
- case 164 /* Parameter */:
92814
- return serializeTypeNode(node.type);
92815
- case 173 /* SetAccessor */:
92816
- case 172 /* GetAccessor */:
92817
- return serializeTypeNode(getAccessorTypeNode(node));
92818
- case 257 /* ClassDeclaration */:
92819
- case 226 /* ClassExpression */:
92820
- case 169 /* MethodDeclaration */:
92821
- return factory.createIdentifier("Function");
92822
- default:
92823
- return factory.createVoidZero();
92824
- }
92825
- }
92826
- /**
92827
- * Serializes the types of the parameters of a node for use with decorator type metadata.
92828
- *
92829
- * @param node The node that should have its parameter types serialized.
92830
- */
92831
- function serializeParameterTypesOfNode(node, container) {
92832
- var valueDeclaration = ts.isClassLike(node)
92833
- ? ts.getFirstConstructorWithBody(node)
92834
- : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
92835
- ? node
92836
- : undefined;
92837
- var expressions = [];
92838
- if (valueDeclaration) {
92839
- var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
92840
- var numParameters = parameters.length;
92841
- for (var i = 0; i < numParameters; i++) {
92842
- var parameter = parameters[i];
92843
- if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
92844
- continue;
92845
- }
92846
- if (parameter.dotDotDotToken) {
92847
- expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
92848
- }
92849
- else {
92850
- expressions.push(serializeTypeOfNode(parameter));
92851
- }
92852
- }
92853
- }
92854
- return factory.createArrayLiteralExpression(expressions);
92855
- }
92856
- function getParametersOfDecoratedDeclaration(node, container) {
92857
- if (container && node.kind === 172 /* GetAccessor */) {
92858
- var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
92859
- if (setAccessor) {
92860
- return setAccessor.parameters;
92861
- }
92862
- }
92863
- return node.parameters;
92864
- }
92865
- /**
92866
- * Serializes the return type of a node for use with decorator type metadata.
92867
- *
92868
- * @param node The node that should have its return type serialized.
92869
- */
92870
- function serializeReturnTypeOfNode(node) {
92871
- if (ts.isFunctionLike(node) && node.type) {
92872
- return serializeTypeNode(node.type);
92873
- }
92874
- else if (ts.isAsyncFunction(node)) {
92875
- return factory.createIdentifier("Promise");
92876
- }
92877
- return factory.createVoidZero();
92878
- }
92879
- /**
92880
- * Serializes a type node for use with decorator type metadata.
92881
- *
92882
- * Types are serialized in the following fashion:
92883
- * - Void types point to "undefined" (e.g. "void 0")
92884
- * - Function and Constructor types point to the global "Function" constructor.
92885
- * - Interface types with a call or construct signature types point to the global
92886
- * "Function" constructor.
92887
- * - Array and Tuple types point to the global "Array" constructor.
92888
- * - Type predicates and booleans point to the global "Boolean" constructor.
92889
- * - String literal types and strings point to the global "String" constructor.
92890
- * - Enum and number types point to the global "Number" constructor.
92891
- * - Symbol types point to the global "Symbol" constructor.
92892
- * - Type references to classes (or class-like variables) point to the constructor for the class.
92893
- * - Anything else points to the global "Object" constructor.
92894
- *
92895
- * @param node The type node to serialize.
92896
- */
92897
- function serializeTypeNode(node) {
92898
- if (node === undefined) {
92899
- return factory.createIdentifier("Object");
92900
- }
92901
- switch (node.kind) {
92902
- case 114 /* VoidKeyword */:
92903
- case 153 /* UndefinedKeyword */:
92904
- case 143 /* NeverKeyword */:
92905
- return factory.createVoidZero();
92906
- case 191 /* ParenthesizedType */:
92907
- return serializeTypeNode(node.type);
92908
- case 179 /* FunctionType */:
92909
- case 180 /* ConstructorType */:
92910
- return factory.createIdentifier("Function");
92911
- case 183 /* ArrayType */:
92912
- case 184 /* TupleType */:
92913
- return factory.createIdentifier("Array");
92914
- case 177 /* TypePredicate */:
92915
- case 133 /* BooleanKeyword */:
92916
- return factory.createIdentifier("Boolean");
92917
- case 198 /* TemplateLiteralType */:
92918
- case 150 /* StringKeyword */:
92919
- return factory.createIdentifier("String");
92920
- case 148 /* ObjectKeyword */:
92921
- return factory.createIdentifier("Object");
92922
- case 196 /* LiteralType */:
92923
- switch (node.literal.kind) {
92924
- case 10 /* StringLiteral */:
92925
- case 14 /* NoSubstitutionTemplateLiteral */:
92926
- return factory.createIdentifier("String");
92927
- case 219 /* PrefixUnaryExpression */:
92928
- case 8 /* NumericLiteral */:
92929
- return factory.createIdentifier("Number");
92930
- case 9 /* BigIntLiteral */:
92931
- return getGlobalBigIntNameWithFallback();
92932
- case 110 /* TrueKeyword */:
92933
- case 95 /* FalseKeyword */:
92934
- return factory.createIdentifier("Boolean");
92935
- case 104 /* NullKeyword */:
92936
- return factory.createVoidZero();
92937
- default:
92938
- return ts.Debug.failBadSyntaxKind(node.literal);
92939
- }
92940
- case 147 /* NumberKeyword */:
92941
- return factory.createIdentifier("Number");
92942
- case 158 /* BigIntKeyword */:
92943
- return getGlobalBigIntNameWithFallback();
92944
- case 151 /* SymbolKeyword */:
92945
- return languageVersion < 2 /* ES2015 */
92946
- ? getGlobalSymbolNameWithFallback()
92947
- : factory.createIdentifier("Symbol");
92948
- case 178 /* TypeReference */:
92949
- return serializeTypeReferenceNode(node);
92950
- case 188 /* IntersectionType */:
92951
- case 187 /* UnionType */:
92952
- return serializeTypeList(node.types);
92953
- case 189 /* ConditionalType */:
92954
- return serializeTypeList([node.trueType, node.falseType]);
92955
- case 193 /* TypeOperator */:
92956
- if (node.operator === 145 /* ReadonlyKeyword */) {
92957
- return serializeTypeNode(node.type);
92958
- }
92959
- break;
92960
- case 181 /* TypeQuery */:
92961
- case 194 /* IndexedAccessType */:
92962
- case 195 /* MappedType */:
92963
- case 182 /* TypeLiteral */:
92964
- case 130 /* AnyKeyword */:
92965
- case 155 /* UnknownKeyword */:
92966
- case 192 /* ThisType */:
92967
- case 200 /* ImportType */:
92968
- break;
92969
- // handle JSDoc types from an invalid parse
92970
- case 312 /* JSDocAllType */:
92971
- case 313 /* JSDocUnknownType */:
92972
- case 317 /* JSDocFunctionType */:
92973
- case 318 /* JSDocVariadicType */:
92974
- case 319 /* JSDocNamepathType */:
92975
- break;
92976
- case 314 /* JSDocNullableType */:
92977
- case 315 /* JSDocNonNullableType */:
92978
- case 316 /* JSDocOptionalType */:
92979
- return serializeTypeNode(node.type);
92980
- default:
92981
- return ts.Debug.failBadSyntaxKind(node);
92982
- }
92983
- return factory.createIdentifier("Object");
92984
- }
92985
- function serializeTypeList(types) {
92986
- // Note when updating logic here also update getEntityNameForDecoratorMetadata
92987
- // so that aliases can be marked as referenced
92988
- var serializedUnion;
92989
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
92990
- var typeNode = types_22[_i];
92991
- while (typeNode.kind === 191 /* ParenthesizedType */) {
92992
- typeNode = typeNode.type; // Skip parens if need be
92993
- }
92994
- if (typeNode.kind === 143 /* NeverKeyword */) {
92995
- continue; // Always elide `never` from the union/intersection if possible
92996
- }
92997
- if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) {
92998
- continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
92999
- }
93000
- var serializedIndividual = serializeTypeNode(typeNode);
93001
- if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
93002
- // One of the individual is global object, return immediately
93003
- return serializedIndividual;
93004
- }
93005
- // If there exists union that is not void 0 expression, check if the the common type is identifier.
93006
- // anything more complex and we will just default to Object
93007
- else if (serializedUnion) {
93008
- // Different types
93009
- if (!ts.isIdentifier(serializedUnion) ||
93010
- !ts.isIdentifier(serializedIndividual) ||
93011
- serializedUnion.escapedText !== serializedIndividual.escapedText) {
93012
- return factory.createIdentifier("Object");
93013
- }
93014
- }
93015
- else {
93016
- // Initialize the union type
93017
- serializedUnion = serializedIndividual;
93018
- }
93019
- }
93020
- // If we were able to find common type, use it
93021
- return serializedUnion || factory.createVoidZero(); // Fallback is only hit if all union constituients are null/undefined/never
93022
- }
93023
- /**
93024
- * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with
93025
- * decorator type metadata.
93026
- *
93027
- * @param node The type reference node.
93028
- */
93029
- function serializeTypeReferenceNode(node) {
93030
- var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
93031
- switch (kind) {
93032
- case ts.TypeReferenceSerializationKind.Unknown:
93033
- // From conditional type type reference that cannot be resolved is Similar to any or unknown
93034
- if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
93035
- return factory.createIdentifier("Object");
93036
- }
93037
- var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
93038
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93039
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"),
93040
- /*questionToken*/ undefined, temp,
93041
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93042
- case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
93043
- return serializeEntityNameAsExpression(node.typeName);
93044
- case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
93045
- return factory.createVoidZero();
93046
- case ts.TypeReferenceSerializationKind.BigIntLikeType:
93047
- return getGlobalBigIntNameWithFallback();
93048
- case ts.TypeReferenceSerializationKind.BooleanType:
93049
- return factory.createIdentifier("Boolean");
93050
- case ts.TypeReferenceSerializationKind.NumberLikeType:
93051
- return factory.createIdentifier("Number");
93052
- case ts.TypeReferenceSerializationKind.StringLikeType:
93053
- return factory.createIdentifier("String");
93054
- case ts.TypeReferenceSerializationKind.ArrayLikeType:
93055
- return factory.createIdentifier("Array");
93056
- case ts.TypeReferenceSerializationKind.ESSymbolType:
93057
- return languageVersion < 2 /* ES2015 */
93058
- ? getGlobalSymbolNameWithFallback()
93059
- : factory.createIdentifier("Symbol");
93060
- case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
93061
- return factory.createIdentifier("Function");
93062
- case ts.TypeReferenceSerializationKind.Promise:
93063
- return factory.createIdentifier("Promise");
93064
- case ts.TypeReferenceSerializationKind.ObjectType:
93065
- return factory.createIdentifier("Object");
93066
- default:
93067
- return ts.Debug.assertNever(kind);
93068
- }
93069
- }
93070
- function createCheckedValue(left, right) {
93071
- return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
93072
- }
93073
- /**
93074
- * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
93075
- *
93076
- * @param node The entity name to serialize.
93077
- */
93078
- function serializeEntityNameAsExpressionFallback(node) {
93079
- if (node.kind === 79 /* Identifier */) {
93080
- // A -> typeof A !== undefined && A
93081
- var copied = serializeEntityNameAsExpression(node);
93082
- return createCheckedValue(copied, copied);
93083
- }
93084
- if (node.left.kind === 79 /* Identifier */) {
93085
- // A.B -> typeof A !== undefined && A.B
93086
- return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
93087
- }
93088
- // A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C
93089
- var left = serializeEntityNameAsExpressionFallback(node.left);
93090
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93091
- return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
93092
- }
93093
- /**
93094
- * Serializes an entity name as an expression for decorator type metadata.
93095
- *
93096
- * @param node The entity name to serialize.
93097
- */
93098
- function serializeEntityNameAsExpression(node) {
93099
- switch (node.kind) {
93100
- case 79 /* Identifier */:
93101
- // Create a clone of the name with a new parent, and treat it as if it were
93102
- // a source tree node for the purposes of the checker.
93103
- var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
93104
- name.original = undefined;
93105
- ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
93106
- return name;
93107
- case 161 /* QualifiedName */:
93108
- return serializeQualifiedNameAsExpression(node);
93109
- }
93110
- }
93111
- /**
93112
- * Serializes an qualified name as an expression for decorator type metadata.
93113
- *
93114
- * @param node The qualified name to serialize.
93115
- * @param useFallback A value indicating whether to use logical operators to test for the
93116
- * qualified name at runtime.
93117
- */
93118
- function serializeQualifiedNameAsExpression(node) {
93119
- return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
93120
- }
93121
- /**
93122
- * Gets an expression that points to the global "Symbol" constructor at runtime if it is
93123
- * available.
93124
- */
93125
- function getGlobalSymbolNameWithFallback() {
93126
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"),
93127
- /*questionToken*/ undefined, factory.createIdentifier("Symbol"),
93128
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93129
- }
93130
- /**
93131
- * Gets an expression that points to the global "BigInt" constructor at runtime if it is
93132
- * available.
93133
- */
93134
- function getGlobalBigIntNameWithFallback() {
93135
- return languageVersion < 99 /* ESNext */
93136
- ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
93137
- /*questionToken*/ undefined, factory.createIdentifier("BigInt"),
93138
- /*colonToken*/ undefined, factory.createIdentifier("Object"))
93139
- : factory.createIdentifier("BigInt");
93140
- }
93141
92641
  /**
93142
92642
  * Gets an expression that represents a property name (for decorated properties or enums).
93143
92643
  * For a computed property, a name is generated for the node.
@@ -93222,21 +92722,23 @@ var ts;
93222
92722
  function shouldEmitFunctionLikeDeclaration(node) {
93223
92723
  return !ts.nodeIsMissing(node.body);
93224
92724
  }
93225
- function visitPropertyDeclaration(node) {
93226
- if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92725
+ function visitPropertyDeclaration(node, parent) {
92726
+ var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */);
92727
+ if (isAmbient && !ts.some(node.decorators)) {
93227
92728
  return undefined;
93228
92729
  }
93229
- var updated = factory.updatePropertyDeclaration(node,
93230
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
92730
+ var allDecorators = getAllDecoratorsOfClassElement(node, parent);
92731
+ var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators);
92732
+ // Preserve a `declare x` property with decorators to be handled by the decorators transform
92733
+ if (isAmbient) {
92734
+ return factory.updatePropertyDeclaration(node, decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */), ts.visitNode(node.name, visitor, ts.isPropertyName),
92735
+ /*questionOrExclamationToken*/ undefined,
92736
+ /*type*/ undefined,
92737
+ /*initializer*/ undefined);
92738
+ }
92739
+ return factory.updatePropertyDeclaration(node, decorators, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
93231
92740
  /*questionOrExclamationToken*/ undefined,
93232
92741
  /*type*/ undefined, ts.visitNode(node.initializer, visitor));
93233
- if (updated !== node) {
93234
- // While we emit the source map for the node after skipping decorators and modifiers,
93235
- // we need to emit the comments for the original range.
93236
- ts.setCommentRange(updated, node);
93237
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93238
- }
93239
- return updated;
93240
92742
  }
93241
92743
  function visitConstructor(node) {
93242
92744
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93244,7 +92746,7 @@ var ts;
93244
92746
  }
93245
92747
  return factory.updateConstructorDeclaration(node,
93246
92748
  /*decorators*/ undefined,
93247
- /*modifiers*/ undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
92749
+ /*modifiers*/ ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
93248
92750
  }
93249
92751
  function transformConstructorBody(body, constructor) {
93250
92752
  var parametersWithPropertyAssignments = constructor &&
@@ -93308,22 +92810,19 @@ var ts;
93308
92810
  ts.setEmitFlags(localName, 1536 /* NoComments */);
93309
92811
  return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1))));
93310
92812
  }
93311
- function visitMethodDeclaration(node) {
92813
+ function visitMethodDeclaration(node, parent) {
92814
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92815
+ return node;
92816
+ }
93312
92817
  if (!shouldEmitFunctionLikeDeclaration(node)) {
93313
92818
  return undefined;
93314
92819
  }
93315
- var updated = factory.updateMethodDeclaration(node,
93316
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
92820
+ var allDecorators = ts.isClassLike(parent) ? getAllDecoratorsOfClassElement(node, parent) : undefined;
92821
+ var decorators = ts.isClassLike(parent) ? transformAllDecoratorsOfDeclaration(node, parent, allDecorators) : undefined;
92822
+ return factory.updateMethodDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
93317
92823
  /*questionToken*/ undefined,
93318
92824
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
93319
92825
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context));
93320
- if (updated !== node) {
93321
- // While we emit the source map for the node after skipping decorators and modifiers,
93322
- // we need to emit the comments for the original range.
93323
- ts.setCommentRange(updated, node);
93324
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93325
- }
93326
- return updated;
93327
92826
  }
93328
92827
  /**
93329
92828
  * Determines whether to emit an accessor declaration. We should not emit the
@@ -93334,34 +92833,30 @@ var ts;
93334
92833
  function shouldEmitAccessorDeclaration(node) {
93335
92834
  return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
93336
92835
  }
93337
- function visitGetAccessor(node) {
92836
+ function visitGetAccessor(node, parent) {
92837
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92838
+ return node;
92839
+ }
93338
92840
  if (!shouldEmitAccessorDeclaration(node)) {
93339
92841
  return undefined;
93340
92842
  }
93341
- var updated = factory.updateGetAccessorDeclaration(node,
93342
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
92843
+ var decorators = ts.isClassLike(parent) ?
92844
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
92845
+ undefined;
92846
+ return factory.updateGetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
93343
92847
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93344
- if (updated !== node) {
93345
- // While we emit the source map for the node after skipping decorators and modifiers,
93346
- // we need to emit the comments for the original range.
93347
- ts.setCommentRange(updated, node);
93348
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93349
- }
93350
- return updated;
93351
92848
  }
93352
- function visitSetAccessor(node) {
92849
+ function visitSetAccessor(node, parent) {
92850
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92851
+ return node;
92852
+ }
93353
92853
  if (!shouldEmitAccessorDeclaration(node)) {
93354
92854
  return undefined;
93355
92855
  }
93356
- var updated = factory.updateSetAccessorDeclaration(node,
93357
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93358
- if (updated !== node) {
93359
- // While we emit the source map for the node after skipping decorators and modifiers,
93360
- // we need to emit the comments for the original range.
93361
- ts.setCommentRange(updated, node);
93362
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93363
- }
93364
- return updated;
92856
+ var decorators = ts.isClassLike(parent) ?
92857
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
92858
+ undefined;
92859
+ return factory.updateSetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93365
92860
  }
93366
92861
  function visitFunctionDeclaration(node) {
93367
92862
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93397,9 +92892,9 @@ var ts;
93397
92892
  if (ts.parameterIsThisKeyword(node)) {
93398
92893
  return undefined;
93399
92894
  }
93400
- var updated = factory.updateParameterDeclaration(node,
93401
- /*decorators*/ undefined,
93402
- /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
92895
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92896
+ ts.elideNodes(factory, node.modifiers), // preserve positions, if available
92897
+ node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
93403
92898
  /*questionToken*/ undefined,
93404
92899
  /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
93405
92900
  if (updated !== node) {
@@ -94095,12 +93590,6 @@ var ts;
94095
93590
  return isExternalModuleExport(node)
94096
93591
  && ts.hasSyntacticModifier(node, 512 /* Default */);
94097
93592
  }
94098
- /**
94099
- * Creates a statement for the provided expression. This is used in calls to `map`.
94100
- */
94101
- function expressionToStatement(expression) {
94102
- return factory.createExpressionStatement(expression);
94103
- }
94104
93593
  function addExportMemberAssignment(statements, node) {
94105
93594
  var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node));
94106
93595
  ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
@@ -94132,44 +93621,12 @@ var ts;
94132
93621
  function getNamespaceContainerName(node) {
94133
93622
  return factory.getGeneratedNameForNode(node);
94134
93623
  }
94135
- /**
94136
- * Gets a local alias for a class declaration if it is a decorated class with an internal
94137
- * reference to the static side of the class. This is necessary to avoid issues with
94138
- * double-binding semantics for the class name.
94139
- */
94140
- function getClassAliasIfNeeded(node) {
94141
- if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
94142
- enableSubstitutionForClassAliases();
94143
- var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
94144
- classAliases[ts.getOriginalNodeId(node)] = classAlias;
94145
- hoistVariableDeclaration(classAlias);
94146
- return classAlias;
94147
- }
94148
- }
94149
- function getClassPrototype(node) {
94150
- return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
94151
- }
94152
- function getClassMemberPrefix(node, member) {
94153
- return ts.isStatic(member)
94154
- ? factory.getDeclarationName(node)
94155
- : getClassPrototype(node);
94156
- }
94157
93624
  function enableSubstitutionForNonQualifiedEnumMembers() {
94158
93625
  if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
94159
93626
  enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
94160
93627
  context.enableSubstitution(79 /* Identifier */);
94161
93628
  }
94162
93629
  }
94163
- function enableSubstitutionForClassAliases() {
94164
- if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
94165
- enabledSubstitutions |= 1 /* ClassAliases */;
94166
- // We need to enable substitutions for identifiers. This allows us to
94167
- // substitute class names inside of a class declaration.
94168
- context.enableSubstitution(79 /* Identifier */);
94169
- // Keep track of class aliases.
94170
- classAliases = [];
94171
- }
94172
- }
94173
93630
  function enableSubstitutionForNamespaceExports() {
94174
93631
  if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
94175
93632
  enabledSubstitutions |= 2 /* NamespaceExports */;
@@ -94254,32 +93711,9 @@ var ts;
94254
93711
  return node;
94255
93712
  }
94256
93713
  function substituteExpressionIdentifier(node) {
94257
- return trySubstituteClassAlias(node)
94258
- || trySubstituteNamespaceExportedName(node)
93714
+ return trySubstituteNamespaceExportedName(node)
94259
93715
  || node;
94260
93716
  }
94261
- function trySubstituteClassAlias(node) {
94262
- if (enabledSubstitutions & 1 /* ClassAliases */) {
94263
- if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
94264
- // Due to the emit for class decorators, any reference to the class from inside of the class body
94265
- // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
94266
- // behavior of class names in ES6.
94267
- // Also, when emitting statics for class expressions, we must substitute a class alias for
94268
- // constructor references in static property initializers.
94269
- var declaration = resolver.getReferencedValueDeclaration(node);
94270
- if (declaration) {
94271
- var classAlias = classAliases[declaration.id]; // TODO: GH#18217
94272
- if (classAlias) {
94273
- var clone_2 = factory.cloneNode(classAlias);
94274
- ts.setSourceMapRange(clone_2, node);
94275
- ts.setCommentRange(clone_2, node);
94276
- return clone_2;
94277
- }
94278
- }
94279
- }
94280
- }
94281
- return undefined;
94282
- }
94283
93717
  function trySubstituteNamespaceExportedName(node) {
94284
93718
  // If this is explicitly a local name, do not substitute.
94285
93719
  if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
@@ -94417,7 +93851,7 @@ var ts;
94417
93851
  return visited;
94418
93852
  }
94419
93853
  function visitorWorker(node, valueIsDiscarded) {
94420
- if (node.transformFlags & 8388608 /* ContainsClassFields */) {
93854
+ if (node.transformFlags & 16777216 /* ContainsClassFields */) {
94421
93855
  switch (node.kind) {
94422
93856
  case 226 /* ClassExpression */:
94423
93857
  case 257 /* ClassDeclaration */:
@@ -94432,8 +93866,8 @@ var ts;
94432
93866
  return visitClassStaticBlockDeclaration(node);
94433
93867
  }
94434
93868
  }
94435
- if (node.transformFlags & 8388608 /* ContainsClassFields */ ||
94436
- node.transformFlags & 33554432 /* ContainsLexicalSuper */ &&
93869
+ if (node.transformFlags & 16777216 /* ContainsClassFields */ ||
93870
+ node.transformFlags & 134217728 /* ContainsLexicalSuper */ &&
94437
93871
  shouldTransformSuperInStaticInitializers &&
94438
93872
  currentStaticPropertyDeclarationOrStaticBlock &&
94439
93873
  currentClassLexicalEnvironment) {
@@ -95007,13 +94441,13 @@ var ts;
95007
94441
  facts |= 2 /* NeedsClassConstructorReference */;
95008
94442
  }
95009
94443
  if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
95010
- if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) {
94444
+ if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
95011
94445
  facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
95012
94446
  if (!(facts & 1 /* ClassWasDecorated */)) {
95013
94447
  facts |= 2 /* NeedsClassConstructorReference */;
95014
94448
  }
95015
94449
  }
95016
- if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) {
94450
+ if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) {
95017
94451
  if (!(facts & 1 /* ClassWasDecorated */)) {
95018
94452
  facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
95019
94453
  }
@@ -95598,10 +95032,10 @@ var ts;
95598
95032
  if (declaration) {
95599
95033
  var classAlias = classAliases[declaration.id]; // TODO: GH#18217
95600
95034
  if (classAlias) {
95601
- var clone_3 = factory.cloneNode(classAlias);
95602
- ts.setSourceMapRange(clone_3, node);
95603
- ts.setCommentRange(clone_3, node);
95604
- return clone_3;
95035
+ var clone_2 = factory.cloneNode(classAlias);
95036
+ ts.setSourceMapRange(clone_2, node);
95037
+ ts.setCommentRange(clone_2, node);
95038
+ return clone_2;
95605
95039
  }
95606
95040
  }
95607
95041
  }
@@ -95963,6 +95397,965 @@ var ts;
95963
95397
  })(ts || (ts = {}));
95964
95398
  /*@internal*/
95965
95399
  var ts;
95400
+ (function (ts) {
95401
+ function createRuntimeTypeSerializer(context) {
95402
+ var hoistVariableDeclaration = context.hoistVariableDeclaration;
95403
+ var resolver = context.getEmitResolver();
95404
+ var compilerOptions = context.getCompilerOptions();
95405
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95406
+ var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
95407
+ var currentLexicalScope;
95408
+ var currentNameScope;
95409
+ return {
95410
+ serializeTypeNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeNode, node); },
95411
+ serializeTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeOfNode, node); },
95412
+ serializeParameterTypesOfNode: function (serializerContext, node, container) { return setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container); },
95413
+ serializeReturnTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node); },
95414
+ };
95415
+ function setSerializerContextAnd(serializerContext, cb, node, arg) {
95416
+ var savedCurrentLexicalScope = currentLexicalScope;
95417
+ var savedCurrentNameScope = currentNameScope;
95418
+ currentLexicalScope = serializerContext.currentLexicalScope;
95419
+ currentNameScope = serializerContext.currentNameScope;
95420
+ var result = arg === undefined ? cb(node) : cb(node, arg);
95421
+ currentLexicalScope = savedCurrentLexicalScope;
95422
+ currentNameScope = savedCurrentNameScope;
95423
+ return result;
95424
+ }
95425
+ function getAccessorTypeNode(node) {
95426
+ var accessors = resolver.getAllAccessorDeclarations(node);
95427
+ return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
95428
+ || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
95429
+ }
95430
+ /**
95431
+ * Serializes the type of a node for use with decorator type metadata.
95432
+ * @param node The node that should have its type serialized.
95433
+ */
95434
+ function serializeTypeOfNode(node) {
95435
+ switch (node.kind) {
95436
+ case 167 /* PropertyDeclaration */:
95437
+ case 164 /* Parameter */:
95438
+ return serializeTypeNode(node.type);
95439
+ case 173 /* SetAccessor */:
95440
+ case 172 /* GetAccessor */:
95441
+ return serializeTypeNode(getAccessorTypeNode(node));
95442
+ case 257 /* ClassDeclaration */:
95443
+ case 226 /* ClassExpression */:
95444
+ case 169 /* MethodDeclaration */:
95445
+ return ts.factory.createIdentifier("Function");
95446
+ default:
95447
+ return ts.factory.createVoidZero();
95448
+ }
95449
+ }
95450
+ /**
95451
+ * Serializes the type of a node for use with decorator type metadata.
95452
+ * @param node The node that should have its type serialized.
95453
+ */
95454
+ function serializeParameterTypesOfNode(node, container) {
95455
+ var valueDeclaration = ts.isClassLike(node)
95456
+ ? ts.getFirstConstructorWithBody(node)
95457
+ : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
95458
+ ? node
95459
+ : undefined;
95460
+ var expressions = [];
95461
+ if (valueDeclaration) {
95462
+ var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
95463
+ var numParameters = parameters.length;
95464
+ for (var i = 0; i < numParameters; i++) {
95465
+ var parameter = parameters[i];
95466
+ if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
95467
+ continue;
95468
+ }
95469
+ if (parameter.dotDotDotToken) {
95470
+ expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
95471
+ }
95472
+ else {
95473
+ expressions.push(serializeTypeOfNode(parameter));
95474
+ }
95475
+ }
95476
+ }
95477
+ return ts.factory.createArrayLiteralExpression(expressions);
95478
+ }
95479
+ function getParametersOfDecoratedDeclaration(node, container) {
95480
+ if (container && node.kind === 172 /* GetAccessor */) {
95481
+ var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
95482
+ if (setAccessor) {
95483
+ return setAccessor.parameters;
95484
+ }
95485
+ }
95486
+ return node.parameters;
95487
+ }
95488
+ /**
95489
+ * Serializes the return type of a node for use with decorator type metadata.
95490
+ * @param node The node that should have its return type serialized.
95491
+ */
95492
+ function serializeReturnTypeOfNode(node) {
95493
+ if (ts.isFunctionLike(node) && node.type) {
95494
+ return serializeTypeNode(node.type);
95495
+ }
95496
+ else if (ts.isAsyncFunction(node)) {
95497
+ return ts.factory.createIdentifier("Promise");
95498
+ }
95499
+ return ts.factory.createVoidZero();
95500
+ }
95501
+ /**
95502
+ * Serializes a type node for use with decorator type metadata.
95503
+ *
95504
+ * Types are serialized in the following fashion:
95505
+ * - Void types point to "undefined" (e.g. "void 0")
95506
+ * - Function and Constructor types point to the global "Function" constructor.
95507
+ * - Interface types with a call or construct signature types point to the global
95508
+ * "Function" constructor.
95509
+ * - Array and Tuple types point to the global "Array" constructor.
95510
+ * - Type predicates and booleans point to the global "Boolean" constructor.
95511
+ * - String literal types and strings point to the global "String" constructor.
95512
+ * - Enum and number types point to the global "Number" constructor.
95513
+ * - Symbol types point to the global "Symbol" constructor.
95514
+ * - Type references to classes (or class-like variables) point to the constructor for the class.
95515
+ * - Anything else points to the global "Object" constructor.
95516
+ *
95517
+ * @param node The type node to serialize.
95518
+ */
95519
+ function serializeTypeNode(node) {
95520
+ if (node === undefined) {
95521
+ return ts.factory.createIdentifier("Object");
95522
+ }
95523
+ node = ts.skipTypeParentheses(node);
95524
+ switch (node.kind) {
95525
+ case 114 /* VoidKeyword */:
95526
+ case 153 /* UndefinedKeyword */:
95527
+ case 143 /* NeverKeyword */:
95528
+ return ts.factory.createVoidZero();
95529
+ case 179 /* FunctionType */:
95530
+ case 180 /* ConstructorType */:
95531
+ return ts.factory.createIdentifier("Function");
95532
+ case 183 /* ArrayType */:
95533
+ case 184 /* TupleType */:
95534
+ return ts.factory.createIdentifier("Array");
95535
+ case 177 /* TypePredicate */:
95536
+ return node.assertsModifier ?
95537
+ ts.factory.createVoidZero() :
95538
+ ts.factory.createIdentifier("Boolean");
95539
+ case 133 /* BooleanKeyword */:
95540
+ return ts.factory.createIdentifier("Boolean");
95541
+ case 198 /* TemplateLiteralType */:
95542
+ case 150 /* StringKeyword */:
95543
+ return ts.factory.createIdentifier("String");
95544
+ case 148 /* ObjectKeyword */:
95545
+ return ts.factory.createIdentifier("Object");
95546
+ case 196 /* LiteralType */:
95547
+ return serializeLiteralOfLiteralTypeNode(node.literal);
95548
+ case 147 /* NumberKeyword */:
95549
+ return ts.factory.createIdentifier("Number");
95550
+ case 158 /* BigIntKeyword */:
95551
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95552
+ case 151 /* SymbolKeyword */:
95553
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95554
+ case 178 /* TypeReference */:
95555
+ return serializeTypeReferenceNode(node);
95556
+ case 188 /* IntersectionType */:
95557
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true);
95558
+ case 187 /* UnionType */:
95559
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false);
95560
+ case 189 /* ConditionalType */:
95561
+ return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false);
95562
+ case 193 /* TypeOperator */:
95563
+ if (node.operator === 145 /* ReadonlyKeyword */) {
95564
+ return serializeTypeNode(node.type);
95565
+ }
95566
+ break;
95567
+ case 181 /* TypeQuery */:
95568
+ case 194 /* IndexedAccessType */:
95569
+ case 195 /* MappedType */:
95570
+ case 182 /* TypeLiteral */:
95571
+ case 130 /* AnyKeyword */:
95572
+ case 155 /* UnknownKeyword */:
95573
+ case 192 /* ThisType */:
95574
+ case 200 /* ImportType */:
95575
+ break;
95576
+ // handle JSDoc types from an invalid parse
95577
+ case 312 /* JSDocAllType */:
95578
+ case 313 /* JSDocUnknownType */:
95579
+ case 317 /* JSDocFunctionType */:
95580
+ case 318 /* JSDocVariadicType */:
95581
+ case 319 /* JSDocNamepathType */:
95582
+ break;
95583
+ case 314 /* JSDocNullableType */:
95584
+ case 315 /* JSDocNonNullableType */:
95585
+ case 316 /* JSDocOptionalType */:
95586
+ return serializeTypeNode(node.type);
95587
+ default:
95588
+ return ts.Debug.failBadSyntaxKind(node);
95589
+ }
95590
+ return ts.factory.createIdentifier("Object");
95591
+ }
95592
+ function serializeLiteralOfLiteralTypeNode(node) {
95593
+ switch (node.kind) {
95594
+ case 10 /* StringLiteral */:
95595
+ case 14 /* NoSubstitutionTemplateLiteral */:
95596
+ return ts.factory.createIdentifier("String");
95597
+ case 219 /* PrefixUnaryExpression */: {
95598
+ var operand = node.operand;
95599
+ switch (operand.kind) {
95600
+ case 8 /* NumericLiteral */:
95601
+ case 9 /* BigIntLiteral */:
95602
+ return serializeLiteralOfLiteralTypeNode(operand);
95603
+ default:
95604
+ return ts.Debug.failBadSyntaxKind(operand);
95605
+ }
95606
+ }
95607
+ case 8 /* NumericLiteral */:
95608
+ return ts.factory.createIdentifier("Number");
95609
+ case 9 /* BigIntLiteral */:
95610
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95611
+ case 110 /* TrueKeyword */:
95612
+ case 95 /* FalseKeyword */:
95613
+ return ts.factory.createIdentifier("Boolean");
95614
+ case 104 /* NullKeyword */:
95615
+ return ts.factory.createVoidZero();
95616
+ default:
95617
+ return ts.Debug.failBadSyntaxKind(node);
95618
+ }
95619
+ }
95620
+ function serializeUnionOrIntersectionConstituents(types, isIntersection) {
95621
+ // Note when updating logic here also update `getEntityNameForDecoratorMetadata` in checker.ts so that aliases can be marked as referenced
95622
+ var serializedType;
95623
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
95624
+ var typeNode = types_22[_i];
95625
+ typeNode = ts.skipTypeParentheses(typeNode);
95626
+ if (typeNode.kind === 143 /* NeverKeyword */) {
95627
+ if (isIntersection)
95628
+ return ts.factory.createVoidZero(); // Reduce to `never` in an intersection
95629
+ continue; // Elide `never` in a union
95630
+ }
95631
+ if (typeNode.kind === 155 /* UnknownKeyword */) {
95632
+ if (!isIntersection)
95633
+ return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union
95634
+ continue; // Elide `unknown` in an intersection
95635
+ }
95636
+ if (typeNode.kind === 130 /* AnyKeyword */) {
95637
+ return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection
95638
+ }
95639
+ if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) {
95640
+ continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
95641
+ }
95642
+ var serializedConstituent = serializeTypeNode(typeNode);
95643
+ if (ts.isIdentifier(serializedConstituent) && serializedConstituent.escapedText === "Object") {
95644
+ // One of the individual is global object, return immediately
95645
+ return serializedConstituent;
95646
+ }
95647
+ // If there exists union that is not `void 0` expression, check if the the common type is identifier.
95648
+ // anything more complex and we will just default to Object
95649
+ if (serializedType) {
95650
+ // Different types
95651
+ if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
95652
+ return ts.factory.createIdentifier("Object");
95653
+ }
95654
+ }
95655
+ else {
95656
+ // Initialize the union type
95657
+ serializedType = serializedConstituent;
95658
+ }
95659
+ }
95660
+ // If we were able to find common type, use it
95661
+ return serializedType !== null && serializedType !== void 0 ? serializedType : (ts.factory.createVoidZero()); // Fallback is only hit if all union constituents are null/undefined/never
95662
+ }
95663
+ function equateSerializedTypeNodes(left, right) {
95664
+ return (
95665
+ // temp vars used in fallback
95666
+ ts.isGeneratedIdentifier(left) ? ts.isGeneratedIdentifier(right) :
95667
+ // entity names
95668
+ ts.isIdentifier(left) ? ts.isIdentifier(right)
95669
+ && left.escapedText === right.escapedText :
95670
+ ts.isPropertyAccessExpression(left) ? ts.isPropertyAccessExpression(right)
95671
+ && equateSerializedTypeNodes(left.expression, right.expression)
95672
+ && equateSerializedTypeNodes(left.name, right.name) :
95673
+ // `void 0`
95674
+ ts.isVoidExpression(left) ? ts.isVoidExpression(right)
95675
+ && ts.isNumericLiteral(left.expression) && left.expression.text === "0"
95676
+ && ts.isNumericLiteral(right.expression) && right.expression.text === "0" :
95677
+ // `"undefined"` or `"function"` in `typeof` checks
95678
+ ts.isStringLiteral(left) ? ts.isStringLiteral(right)
95679
+ && left.text === right.text :
95680
+ // used in `typeof` checks for fallback
95681
+ ts.isTypeOfExpression(left) ? ts.isTypeOfExpression(right)
95682
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95683
+ // parens in `typeof` checks with temps
95684
+ ts.isParenthesizedExpression(left) ? ts.isParenthesizedExpression(right)
95685
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95686
+ // conditionals used in fallback
95687
+ ts.isConditionalExpression(left) ? ts.isConditionalExpression(right)
95688
+ && equateSerializedTypeNodes(left.condition, right.condition)
95689
+ && equateSerializedTypeNodes(left.whenTrue, right.whenTrue)
95690
+ && equateSerializedTypeNodes(left.whenFalse, right.whenFalse) :
95691
+ // logical binary and assignments used in fallback
95692
+ ts.isBinaryExpression(left) ? ts.isBinaryExpression(right)
95693
+ && left.operatorToken.kind === right.operatorToken.kind
95694
+ && equateSerializedTypeNodes(left.left, right.left)
95695
+ && equateSerializedTypeNodes(left.right, right.right) :
95696
+ false);
95697
+ }
95698
+ /**
95699
+ * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with decorator type metadata.
95700
+ * @param node The type reference node.
95701
+ */
95702
+ function serializeTypeReferenceNode(node) {
95703
+ var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope !== null && currentNameScope !== void 0 ? currentNameScope : currentLexicalScope);
95704
+ switch (kind) {
95705
+ case ts.TypeReferenceSerializationKind.Unknown:
95706
+ // From conditional type type reference that cannot be resolved is Similar to any or unknown
95707
+ if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
95708
+ return ts.factory.createIdentifier("Object");
95709
+ }
95710
+ var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
95711
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95712
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createAssignment(temp, serialized), "function"),
95713
+ /*questionToken*/ undefined, temp,
95714
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95715
+ case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
95716
+ return serializeEntityNameAsExpression(node.typeName);
95717
+ case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
95718
+ return ts.factory.createVoidZero();
95719
+ case ts.TypeReferenceSerializationKind.BigIntLikeType:
95720
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95721
+ case ts.TypeReferenceSerializationKind.BooleanType:
95722
+ return ts.factory.createIdentifier("Boolean");
95723
+ case ts.TypeReferenceSerializationKind.NumberLikeType:
95724
+ return ts.factory.createIdentifier("Number");
95725
+ case ts.TypeReferenceSerializationKind.StringLikeType:
95726
+ return ts.factory.createIdentifier("String");
95727
+ case ts.TypeReferenceSerializationKind.ArrayLikeType:
95728
+ return ts.factory.createIdentifier("Array");
95729
+ case ts.TypeReferenceSerializationKind.ESSymbolType:
95730
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95731
+ case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
95732
+ return ts.factory.createIdentifier("Function");
95733
+ case ts.TypeReferenceSerializationKind.Promise:
95734
+ return ts.factory.createIdentifier("Promise");
95735
+ case ts.TypeReferenceSerializationKind.ObjectType:
95736
+ return ts.factory.createIdentifier("Object");
95737
+ default:
95738
+ return ts.Debug.assertNever(kind);
95739
+ }
95740
+ }
95741
+ /**
95742
+ * Produces an expression that results in `right` if `left` is not undefined at runtime:
95743
+ *
95744
+ * ```
95745
+ * typeof left !== "undefined" && right
95746
+ * ```
95747
+ *
95748
+ * We use `typeof L !== "undefined"` (rather than `L !== undefined`) since `L` may not be declared.
95749
+ * It's acceptable for this expression to result in `false` at runtime, as the result is intended to be
95750
+ * further checked by any containing expression.
95751
+ */
95752
+ function createCheckedValue(left, right) {
95753
+ return ts.factory.createLogicalAnd(ts.factory.createStrictInequality(ts.factory.createTypeOfExpression(left), ts.factory.createStringLiteral("undefined")), right);
95754
+ }
95755
+ /**
95756
+ * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
95757
+ * @param node The entity name to serialize.
95758
+ */
95759
+ function serializeEntityNameAsExpressionFallback(node) {
95760
+ if (node.kind === 79 /* Identifier */) {
95761
+ // A -> typeof A !== "undefined" && A
95762
+ var copied = serializeEntityNameAsExpression(node);
95763
+ return createCheckedValue(copied, copied);
95764
+ }
95765
+ if (node.left.kind === 79 /* Identifier */) {
95766
+ // A.B -> typeof A !== "undefined" && A.B
95767
+ return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
95768
+ }
95769
+ // A.B.C -> typeof A !== "undefined" && (_a = A.B) !== void 0 && _a.C
95770
+ var left = serializeEntityNameAsExpressionFallback(node.left);
95771
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95772
+ return ts.factory.createLogicalAnd(ts.factory.createLogicalAnd(left.left, ts.factory.createStrictInequality(ts.factory.createAssignment(temp, left.right), ts.factory.createVoidZero())), ts.factory.createPropertyAccessExpression(temp, node.right));
95773
+ }
95774
+ /**
95775
+ * Serializes an entity name as an expression for decorator type metadata.
95776
+ * @param node The entity name to serialize.
95777
+ */
95778
+ function serializeEntityNameAsExpression(node) {
95779
+ switch (node.kind) {
95780
+ case 79 /* Identifier */:
95781
+ // Create a clone of the name with a new parent, and treat it as if it were
95782
+ // a source tree node for the purposes of the checker.
95783
+ var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
95784
+ name.original = undefined;
95785
+ ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
95786
+ return name;
95787
+ case 161 /* QualifiedName */:
95788
+ return serializeQualifiedNameAsExpression(node);
95789
+ }
95790
+ }
95791
+ /**
95792
+ * Serializes an qualified name as an expression for decorator type metadata.
95793
+ * @param node The qualified name to serialize.
95794
+ */
95795
+ function serializeQualifiedNameAsExpression(node) {
95796
+ return ts.factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
95797
+ }
95798
+ function getGlobalConstructorWithFallback(name) {
95799
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createIdentifier(name), "function"),
95800
+ /*questionToken*/ undefined, ts.factory.createIdentifier(name),
95801
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95802
+ }
95803
+ function getGlobalConstructor(name, minLanguageVersion) {
95804
+ return languageVersion < minLanguageVersion ?
95805
+ getGlobalConstructorWithFallback(name) :
95806
+ ts.factory.createIdentifier(name);
95807
+ }
95808
+ }
95809
+ ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer;
95810
+ })(ts || (ts = {}));
95811
+ /*@internal*/
95812
+ var ts;
95813
+ (function (ts) {
95814
+ function transformLegacyDecorators(context) {
95815
+ var factory = context.factory, emitHelpers = context.getEmitHelperFactory, hoistVariableDeclaration = context.hoistVariableDeclaration;
95816
+ var resolver = context.getEmitResolver();
95817
+ var compilerOptions = context.getCompilerOptions();
95818
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95819
+ // Save the previous transformation hooks.
95820
+ var previousOnSubstituteNode = context.onSubstituteNode;
95821
+ // Set new transformation hooks.
95822
+ context.onSubstituteNode = onSubstituteNode;
95823
+ /**
95824
+ * A map that keeps track of aliases created for classes with decorators to avoid issues
95825
+ * with the double-binding behavior of classes.
95826
+ */
95827
+ var classAliases;
95828
+ return ts.chainBundle(context, transformSourceFile);
95829
+ function transformSourceFile(node) {
95830
+ var visited = ts.visitEachChild(node, visitor, context);
95831
+ ts.addEmitHelpers(visited, context.readEmitHelpers());
95832
+ return visited;
95833
+ }
95834
+ function visitor(node) {
95835
+ if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) {
95836
+ return node;
95837
+ }
95838
+ switch (node.kind) {
95839
+ case 165 /* Decorator */:
95840
+ // Decorators are elided. They will be emitted as part of `visitClassDeclaration`.
95841
+ return undefined;
95842
+ case 257 /* ClassDeclaration */:
95843
+ return visitClassDeclaration(node);
95844
+ case 226 /* ClassExpression */:
95845
+ return visitClassExpression(node);
95846
+ case 171 /* Constructor */:
95847
+ return visitConstructorDeclaration(node);
95848
+ case 169 /* MethodDeclaration */:
95849
+ return visitMethodDeclaration(node);
95850
+ case 173 /* SetAccessor */:
95851
+ return visitSetAccessorDeclaration(node);
95852
+ case 172 /* GetAccessor */:
95853
+ return visitGetAccessorDeclaration(node);
95854
+ case 170 /* ClassStaticBlockDeclaration */:
95855
+ return visitClassStaticBlockDeclaration(node);
95856
+ case 167 /* PropertyDeclaration */:
95857
+ return visitPropertyDeclaration(node);
95858
+ case 164 /* Parameter */:
95859
+ return visitParameterDeclaration(node);
95860
+ default:
95861
+ return ts.visitEachChild(node, visitor, context);
95862
+ }
95863
+ }
95864
+ function visitClassDeclaration(node) {
95865
+ if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
95866
+ return ts.visitEachChild(node, visitor, context);
95867
+ var classStatement = ts.some(node.decorators) ?
95868
+ createClassDeclarationHeadWithDecorators(node, node.name) :
95869
+ createClassDeclarationHeadWithoutDecorators(node, node.name);
95870
+ var statements = [classStatement];
95871
+ // Write any decorators of the node.
95872
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
95873
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
95874
+ addConstructorDecorationStatement(statements, node);
95875
+ if (statements.length > 1) {
95876
+ // Add a DeclarationMarker as a marker for the end of the declaration
95877
+ statements.push(factory.createEndOfDeclarationMarker(node));
95878
+ ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
95879
+ }
95880
+ return ts.singleOrMany(statements);
95881
+ }
95882
+ /**
95883
+ * Transforms a non-decorated class declaration.
95884
+ *
95885
+ * @param node A ClassDeclaration node.
95886
+ * @param name The name of the class.
95887
+ */
95888
+ function createClassDeclarationHeadWithoutDecorators(node, name) {
95889
+ // ${modifiers} class ${name} ${heritageClauses} {
95890
+ // ${members}
95891
+ // }
95892
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, name,
95893
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
95894
+ }
95895
+ /**
95896
+ * Transforms a decorated class declaration and appends the resulting statements. If
95897
+ * the class requires an alias to avoid issues with double-binding, the alias is returned.
95898
+ */
95899
+ function createClassDeclarationHeadWithDecorators(node, name) {
95900
+ // When we emit an ES6 class that has a class decorator, we must tailor the
95901
+ // emit to certain specific cases.
95902
+ //
95903
+ // In the simplest case, we emit the class declaration as a let declaration, and
95904
+ // evaluate decorators after the close of the class body:
95905
+ //
95906
+ // [Example 1]
95907
+ // ---------------------------------------------------------------------
95908
+ // TypeScript | Javascript
95909
+ // ---------------------------------------------------------------------
95910
+ // @dec | let C = class C {
95911
+ // class C { | }
95912
+ // } | C = __decorate([dec], C);
95913
+ // ---------------------------------------------------------------------
95914
+ // @dec | let C = class C {
95915
+ // export class C { | }
95916
+ // } | C = __decorate([dec], C);
95917
+ // | export { C };
95918
+ // ---------------------------------------------------------------------
95919
+ //
95920
+ // If a class declaration contains a reference to itself *inside* of the class body,
95921
+ // this introduces two bindings to the class: One outside of the class body, and one
95922
+ // inside of the class body. If we apply decorators as in [Example 1] above, there
95923
+ // is the possibility that the decorator `dec` will return a new value for the
95924
+ // constructor, which would result in the binding inside of the class no longer
95925
+ // pointing to the same reference as the binding outside of the class.
95926
+ //
95927
+ // As a result, we must instead rewrite all references to the class *inside* of the
95928
+ // class body to instead point to a local temporary alias for the class:
95929
+ //
95930
+ // [Example 2]
95931
+ // ---------------------------------------------------------------------
95932
+ // TypeScript | Javascript
95933
+ // ---------------------------------------------------------------------
95934
+ // @dec | let C = C_1 = class C {
95935
+ // class C { | static x() { return C_1.y; }
95936
+ // static x() { return C.y; } | }
95937
+ // static y = 1; | C.y = 1;
95938
+ // } | C = C_1 = __decorate([dec], C);
95939
+ // | var C_1;
95940
+ // ---------------------------------------------------------------------
95941
+ // @dec | let C = class C {
95942
+ // export class C { | static x() { return C_1.y; }
95943
+ // static x() { return C.y; } | }
95944
+ // static y = 1; | C.y = 1;
95945
+ // } | C = C_1 = __decorate([dec], C);
95946
+ // | export { C };
95947
+ // | var C_1;
95948
+ // ---------------------------------------------------------------------
95949
+ //
95950
+ // If a class declaration is the default export of a module, we instead emit
95951
+ // the export after the decorated declaration:
95952
+ //
95953
+ // [Example 3]
95954
+ // ---------------------------------------------------------------------
95955
+ // TypeScript | Javascript
95956
+ // ---------------------------------------------------------------------
95957
+ // @dec | let default_1 = class {
95958
+ // export default class { | }
95959
+ // } | default_1 = __decorate([dec], default_1);
95960
+ // | export default default_1;
95961
+ // ---------------------------------------------------------------------
95962
+ // @dec | let C = class C {
95963
+ // export default class C { | }
95964
+ // } | C = __decorate([dec], C);
95965
+ // | export default C;
95966
+ // ---------------------------------------------------------------------
95967
+ //
95968
+ // If the class declaration is the default export and a reference to itself
95969
+ // inside of the class body, we must emit both an alias for the class *and*
95970
+ // move the export after the declaration:
95971
+ //
95972
+ // [Example 4]
95973
+ // ---------------------------------------------------------------------
95974
+ // TypeScript | Javascript
95975
+ // ---------------------------------------------------------------------
95976
+ // @dec | let C = class C {
95977
+ // export default class C { | static x() { return C_1.y; }
95978
+ // static x() { return C.y; } | }
95979
+ // static y = 1; | C.y = 1;
95980
+ // } | C = C_1 = __decorate([dec], C);
95981
+ // | export default C;
95982
+ // | var C_1;
95983
+ // ---------------------------------------------------------------------
95984
+ //
95985
+ var location = ts.moveRangePastModifiers(node);
95986
+ var classAlias = getClassAliasIfNeeded(node);
95987
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
95988
+ // without any block-scoped variable collision handling
95989
+ var declName = languageVersion <= 2 /* ES2015 */ ?
95990
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
95991
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
95992
+ // ... = class ${name} ${heritageClauses} {
95993
+ // ${members}
95994
+ // }
95995
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
95996
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
95997
+ var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
95998
+ ts.setOriginalNode(classExpression, node);
95999
+ ts.setTextRange(classExpression, location);
96000
+ // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
96001
+ // or decoratedClassAlias if the class contain self-reference.
96002
+ var statement = factory.createVariableStatement(
96003
+ /*modifiers*/ undefined, factory.createVariableDeclarationList([
96004
+ factory.createVariableDeclaration(declName,
96005
+ /*exclamationToken*/ undefined,
96006
+ /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
96007
+ ], 1 /* Let */));
96008
+ ts.setOriginalNode(statement, node);
96009
+ ts.setTextRange(statement, location);
96010
+ ts.setCommentRange(statement, node);
96011
+ return statement;
96012
+ }
96013
+ function visitClassExpression(node) {
96014
+ // Legacy decorators were not supported on class expressions
96015
+ return factory.updateClassExpression(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.name,
96016
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96017
+ }
96018
+ function visitConstructorDeclaration(node) {
96019
+ return factory.updateConstructorDeclaration(node,
96020
+ /*decorators*/ undefined, node.modifiers, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock));
96021
+ }
96022
+ function finishClassElement(updated, original) {
96023
+ if (updated !== original) {
96024
+ // While we emit the source map for the node after skipping decorators and modifiers,
96025
+ // we need to emit the comments for the original range.
96026
+ ts.setCommentRange(updated, original);
96027
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(original));
96028
+ }
96029
+ return updated;
96030
+ }
96031
+ function visitMethodDeclaration(node) {
96032
+ return finishClassElement(factory.updateMethodDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName),
96033
+ /*questionToken*/ undefined,
96034
+ /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
96035
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96036
+ }
96037
+ function visitGetAccessorDeclaration(node) {
96038
+ return finishClassElement(factory.updateGetAccessorDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
96039
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96040
+ }
96041
+ function visitSetAccessorDeclaration(node) {
96042
+ return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node);
96043
+ }
96044
+ function visitClassStaticBlockDeclaration(node) {
96045
+ return factory.updateClassStaticBlockDeclaration(node,
96046
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.body, visitor, ts.isBlock));
96047
+ }
96048
+ function visitPropertyDeclaration(node) {
96049
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
96050
+ return undefined;
96051
+ }
96052
+ return finishClassElement(factory.updatePropertyDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName),
96053
+ /*questionOrExclamationToken*/ undefined,
96054
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
96055
+ }
96056
+ function visitParameterDeclaration(node) {
96057
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators),
96058
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
96059
+ /*questionToken*/ undefined,
96060
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
96061
+ if (updated !== node) {
96062
+ // While we emit the source map for the node after skipping decorators and modifiers,
96063
+ // we need to emit the comments for the original range.
96064
+ ts.setCommentRange(updated, node);
96065
+ ts.setTextRange(updated, ts.moveRangePastModifiers(node));
96066
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
96067
+ ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */);
96068
+ }
96069
+ return updated;
96070
+ }
96071
+ /**
96072
+ * Transforms all of the decorators for a declaration into an array of expressions.
96073
+ *
96074
+ * @param allDecorators An object containing all of the decorators for the declaration.
96075
+ */
96076
+ function transformAllDecoratorsOfDeclaration(allDecorators) {
96077
+ if (!allDecorators) {
96078
+ return undefined;
96079
+ }
96080
+ var decoratorExpressions = [];
96081
+ ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
96082
+ ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
96083
+ return decoratorExpressions;
96084
+ }
96085
+ /**
96086
+ * Generates statements used to apply decorators to either the static or instance members
96087
+ * of a class.
96088
+ *
96089
+ * @param node The class node.
96090
+ * @param isStatic A value indicating whether to generate statements for static or
96091
+ * instance members.
96092
+ */
96093
+ function addClassElementDecorationStatements(statements, node, isStatic) {
96094
+ ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), function (expr) { return factory.createExpressionStatement(expr); }));
96095
+ }
96096
+ /**
96097
+ * Determines whether a class member is either a static or an instance member of a class
96098
+ * that is decorated, or has parameters that are decorated.
96099
+ *
96100
+ * @param member The class member.
96101
+ */
96102
+ function isDecoratedClassElement(member, isStaticElement, parent) {
96103
+ return ts.nodeOrChildIsDecorated(member, parent)
96104
+ && isStaticElement === ts.isStatic(member);
96105
+ }
96106
+ /**
96107
+ * Gets either the static or instance members of a class that are decorated, or have
96108
+ * parameters that are decorated.
96109
+ *
96110
+ * @param node The class containing the member.
96111
+ * @param isStatic A value indicating whether to retrieve static or instance members of
96112
+ * the class.
96113
+ */
96114
+ function getDecoratedClassElements(node, isStatic) {
96115
+ return ts.filter(node.members, function (m) { return isDecoratedClassElement(m, isStatic, node); });
96116
+ }
96117
+ /**
96118
+ * Generates expressions used to apply decorators to either the static or instance members
96119
+ * of a class.
96120
+ *
96121
+ * @param node The class node.
96122
+ * @param isStatic A value indicating whether to generate expressions for static or
96123
+ * instance members.
96124
+ */
96125
+ function generateClassElementDecorationExpressions(node, isStatic) {
96126
+ var members = getDecoratedClassElements(node, isStatic);
96127
+ var expressions;
96128
+ for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
96129
+ var member = members_8[_i];
96130
+ expressions = ts.append(expressions, generateClassElementDecorationExpression(node, member));
96131
+ }
96132
+ return expressions;
96133
+ }
96134
+ /**
96135
+ * Generates an expression used to evaluate class element decorators at runtime.
96136
+ *
96137
+ * @param node The class node that contains the member.
96138
+ * @param member The class member.
96139
+ */
96140
+ function generateClassElementDecorationExpression(node, member) {
96141
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96142
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96143
+ if (!decoratorExpressions) {
96144
+ return undefined;
96145
+ }
96146
+ // Emit the call to __decorate. Given the following:
96147
+ //
96148
+ // class C {
96149
+ // @dec method(@dec2 x) {}
96150
+ // @dec get accessor() {}
96151
+ // @dec prop;
96152
+ // }
96153
+ //
96154
+ // The emit for a method is:
96155
+ //
96156
+ // __decorate([
96157
+ // dec,
96158
+ // __param(0, dec2),
96159
+ // __metadata("design:type", Function),
96160
+ // __metadata("design:paramtypes", [Object]),
96161
+ // __metadata("design:returntype", void 0)
96162
+ // ], C.prototype, "method", null);
96163
+ //
96164
+ // The emit for an accessor is:
96165
+ //
96166
+ // __decorate([
96167
+ // dec
96168
+ // ], C.prototype, "accessor", null);
96169
+ //
96170
+ // The emit for a property is:
96171
+ //
96172
+ // __decorate([
96173
+ // dec
96174
+ // ], C.prototype, "prop");
96175
+ //
96176
+ var prefix = getClassMemberPrefix(node, member);
96177
+ var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
96178
+ var descriptor = languageVersion > 0 /* ES3 */
96179
+ ? member.kind === 167 /* PropertyDeclaration */
96180
+ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
96181
+ // should not invoke `Object.getOwnPropertyDescriptor`.
96182
+ ? factory.createVoidZero()
96183
+ // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
96184
+ // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
96185
+ : factory.createNull()
96186
+ : undefined;
96187
+ var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
96188
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96189
+ ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member));
96190
+ return helper;
96191
+ }
96192
+ /**
96193
+ * Generates a __decorate helper call for a class constructor.
96194
+ *
96195
+ * @param node The class node.
96196
+ */
96197
+ function addConstructorDecorationStatement(statements, node) {
96198
+ var expression = generateConstructorDecorationExpression(node);
96199
+ if (expression) {
96200
+ statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
96201
+ }
96202
+ }
96203
+ /**
96204
+ * Generates a __decorate helper call for a class constructor.
96205
+ *
96206
+ * @param node The class node.
96207
+ */
96208
+ function generateConstructorDecorationExpression(node) {
96209
+ var allDecorators = ts.getAllDecoratorsOfClass(node);
96210
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96211
+ if (!decoratorExpressions) {
96212
+ return undefined;
96213
+ }
96214
+ var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
96215
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
96216
+ // without any block-scoped variable collision handling
96217
+ var localName = languageVersion <= 2 /* ES2015 */ ?
96218
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
96219
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
96220
+ var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
96221
+ var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
96222
+ ts.setEmitFlags(expression, 1536 /* NoComments */);
96223
+ ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node));
96224
+ return expression;
96225
+ }
96226
+ /**
96227
+ * Transforms a decorator into an expression.
96228
+ *
96229
+ * @param decorator The decorator node.
96230
+ */
96231
+ function transformDecorator(decorator) {
96232
+ return ts.visitNode(decorator.expression, visitor, ts.isExpression);
96233
+ }
96234
+ /**
96235
+ * Transforms the decorators of a parameter.
96236
+ *
96237
+ * @param decorators The decorators for the parameter at the provided offset.
96238
+ * @param parameterOffset The offset of the parameter.
96239
+ */
96240
+ function transformDecoratorsOfParameter(decorators, parameterOffset) {
96241
+ var expressions;
96242
+ if (decorators) {
96243
+ expressions = [];
96244
+ for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
96245
+ var decorator = decorators_1[_i];
96246
+ var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
96247
+ ts.setTextRange(helper, decorator.expression);
96248
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96249
+ expressions.push(helper);
96250
+ }
96251
+ }
96252
+ return expressions;
96253
+ }
96254
+ /**
96255
+ * Gets an expression that represents a property name (for decorated properties or enums).
96256
+ * For a computed property, a name is generated for the node.
96257
+ *
96258
+ * @param member The member whose name should be converted into an expression.
96259
+ */
96260
+ function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
96261
+ var name = member.name;
96262
+ if (ts.isPrivateIdentifier(name)) {
96263
+ return factory.createIdentifier("");
96264
+ }
96265
+ else if (ts.isComputedPropertyName(name)) {
96266
+ return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
96267
+ ? factory.getGeneratedNameForNode(name)
96268
+ : name.expression;
96269
+ }
96270
+ else if (ts.isIdentifier(name)) {
96271
+ return factory.createStringLiteral(ts.idText(name));
96272
+ }
96273
+ else {
96274
+ return factory.cloneNode(name);
96275
+ }
96276
+ }
96277
+ function enableSubstitutionForClassAliases() {
96278
+ if (!classAliases) {
96279
+ // We need to enable substitutions for identifiers. This allows us to
96280
+ // substitute class names inside of a class declaration.
96281
+ context.enableSubstitution(79 /* Identifier */);
96282
+ // Keep track of class aliases.
96283
+ classAliases = [];
96284
+ }
96285
+ }
96286
+ /**
96287
+ * Gets a local alias for a class declaration if it is a decorated class with an internal
96288
+ * reference to the static side of the class. This is necessary to avoid issues with
96289
+ * double-binding semantics for the class name.
96290
+ */
96291
+ function getClassAliasIfNeeded(node) {
96292
+ if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
96293
+ enableSubstitutionForClassAliases();
96294
+ var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
96295
+ classAliases[ts.getOriginalNodeId(node)] = classAlias;
96296
+ hoistVariableDeclaration(classAlias);
96297
+ return classAlias;
96298
+ }
96299
+ }
96300
+ function getClassPrototype(node) {
96301
+ return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
96302
+ }
96303
+ function getClassMemberPrefix(node, member) {
96304
+ return ts.isStatic(member)
96305
+ ? factory.getDeclarationName(node)
96306
+ : getClassPrototype(node);
96307
+ }
96308
+ /**
96309
+ * Hooks node substitutions.
96310
+ *
96311
+ * @param hint A hint as to the intended usage of the node.
96312
+ * @param node The node to substitute.
96313
+ */
96314
+ function onSubstituteNode(hint, node) {
96315
+ node = previousOnSubstituteNode(hint, node);
96316
+ if (hint === 1 /* Expression */) {
96317
+ return substituteExpression(node);
96318
+ }
96319
+ return node;
96320
+ }
96321
+ function substituteExpression(node) {
96322
+ switch (node.kind) {
96323
+ case 79 /* Identifier */:
96324
+ return substituteExpressionIdentifier(node);
96325
+ }
96326
+ return node;
96327
+ }
96328
+ function substituteExpressionIdentifier(node) {
96329
+ var _a;
96330
+ return (_a = trySubstituteClassAlias(node)) !== null && _a !== void 0 ? _a : node;
96331
+ }
96332
+ function trySubstituteClassAlias(node) {
96333
+ if (classAliases) {
96334
+ if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
96335
+ // Due to the emit for class decorators, any reference to the class from inside of the class body
96336
+ // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
96337
+ // behavior of class names in ES6.
96338
+ // Also, when emitting statics for class expressions, we must substitute a class alias for
96339
+ // constructor references in static property initializers.
96340
+ var declaration = resolver.getReferencedValueDeclaration(node);
96341
+ if (declaration) {
96342
+ var classAlias = classAliases[declaration.id]; // TODO: GH#18217
96343
+ if (classAlias) {
96344
+ var clone_3 = factory.cloneNode(classAlias);
96345
+ ts.setSourceMapRange(clone_3, node);
96346
+ ts.setCommentRange(clone_3, node);
96347
+ return clone_3;
96348
+ }
96349
+ }
96350
+ }
96351
+ }
96352
+ return undefined;
96353
+ }
96354
+ }
96355
+ ts.transformLegacyDecorators = transformLegacyDecorators;
96356
+ })(ts || (ts = {}));
96357
+ /*@internal*/
96358
+ var ts;
95966
96359
  (function (ts) {
95967
96360
  var ES2017SubstitutionFlags;
95968
96361
  (function (ES2017SubstitutionFlags) {
@@ -96811,7 +97204,7 @@ var ts;
96811
97204
  return objects;
96812
97205
  }
96813
97206
  function visitObjectLiteralExpression(node) {
96814
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97207
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96815
97208
  // spread elements emit like so:
96816
97209
  // non-spread elements are chunked together into object literals, and then all are passed to __assign:
96817
97210
  // { a, ...o, b } => __assign(__assign({a}, o), {b});
@@ -96884,7 +97277,7 @@ var ts;
96884
97277
  * expression of an `ExpressionStatement`).
96885
97278
  */
96886
97279
  function visitBinaryExpression(node, expressionResultIsUnused) {
96887
- if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97280
+ if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96888
97281
  return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
96889
97282
  }
96890
97283
  if (node.operatorToken.kind === 27 /* CommaToken */) {
@@ -96915,7 +97308,7 @@ var ts;
96915
97308
  function visitCatchClause(node) {
96916
97309
  if (node.variableDeclaration &&
96917
97310
  ts.isBindingPattern(node.variableDeclaration.name) &&
96918
- node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97311
+ node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96919
97312
  var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
96920
97313
  var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
96921
97314
  var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
@@ -96956,7 +97349,7 @@ var ts;
96956
97349
  }
96957
97350
  function visitVariableDeclarationWorker(node, exportedVariableStatement) {
96958
97351
  // If we are here it is because the name contains a binding pattern with a rest somewhere in it.
96959
- if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97352
+ if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96960
97353
  return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
96961
97354
  /*rval*/ undefined, exportedVariableStatement);
96962
97355
  }
@@ -96975,7 +97368,7 @@ var ts;
96975
97368
  */
96976
97369
  function visitForOfStatement(node, outermostLabeledStatement) {
96977
97370
  var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
96978
- if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97371
+ if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96979
97372
  node = transformForOfStatementWithObjectRest(node);
96980
97373
  }
96981
97374
  var result = node.awaitModifier ?
@@ -97088,7 +97481,7 @@ var ts;
97088
97481
  /*type*/ undefined,
97089
97482
  /*initializer*/ undefined);
97090
97483
  }
97091
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97484
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97092
97485
  // Binding patterns are converted into a generated name and are
97093
97486
  // evaluated inside the function body.
97094
97487
  return factory.updateParameterDeclaration(node,
@@ -97106,7 +97499,7 @@ var ts;
97106
97499
  if (parameters) {
97107
97500
  parameters.add(parameter);
97108
97501
  }
97109
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97502
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97110
97503
  parameters = new ts.Set();
97111
97504
  }
97112
97505
  }
@@ -97329,7 +97722,7 @@ var ts;
97329
97722
  statements = ts.append(statements, statement);
97330
97723
  }
97331
97724
  }
97332
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97725
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97333
97726
  containsPrecedingObjectRestOrSpread = true;
97334
97727
  var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
97335
97728
  /*doNotRecordTempVariablesInLine*/ false,
@@ -98701,7 +99094,7 @@ var ts;
98701
99094
  && !node.expression;
98702
99095
  }
98703
99096
  function isOrMayContainReturnCompletion(node) {
98704
- return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */
99097
+ return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */
98705
99098
  && (ts.isReturnStatement(node)
98706
99099
  || ts.isIfStatement(node)
98707
99100
  || ts.isWithStatement(node)
@@ -99265,7 +99658,7 @@ var ts;
99265
99658
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
99266
99659
  insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
99267
99660
  if (isDerivedClass || superCallExpression) {
99268
- if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
99661
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
99269
99662
  // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
99270
99663
  // following representation:
99271
99664
  //
@@ -99810,7 +100203,7 @@ var ts;
99810
100203
  * @param node An ArrowFunction node.
99811
100204
  */
99812
100205
  function visitArrowFunction(node) {
99813
- if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
100206
+ if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
99814
100207
  hierarchyFacts |= 65536 /* CapturedLexicalThis */;
99815
100208
  }
99816
100209
  var savedConvertedLoopState = convertedLoopState;
@@ -100096,7 +100489,7 @@ var ts;
100096
100489
  * @param node A VariableDeclarationList node.
100097
100490
  */
100098
100491
  function visitVariableDeclarationList(node) {
100099
- if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) {
100492
+ if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) {
100100
100493
  if (node.flags & 3 /* BlockScoped */) {
100101
100494
  enableSubstitutionsForBlockScopedBindings();
100102
100495
  }
@@ -100109,7 +100502,7 @@ var ts;
100109
100502
  ts.setCommentRange(declarationList, node);
100110
100503
  // If the first or last declaration is a binding pattern, we need to modify
100111
100504
  // the source map range for the declaration list.
100112
- if (node.transformFlags & 262144 /* ContainsBindingPattern */
100505
+ if (node.transformFlags & 524288 /* ContainsBindingPattern */
100113
100506
  && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
100114
100507
  ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
100115
100508
  }
@@ -100433,7 +100826,7 @@ var ts;
100433
100826
  var numInitialProperties = -1, hasComputed = false;
100434
100827
  for (var i = 0; i < properties.length; i++) {
100435
100828
  var property = properties[i];
100436
- if ((property.transformFlags & 524288 /* ContainsYield */ &&
100829
+ if ((property.transformFlags & 1048576 /* ContainsYield */ &&
100437
100830
  hierarchyFacts & 4 /* AsyncFunctionBody */)
100438
100831
  || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) {
100439
100832
  numInitialProperties = i;
@@ -100706,7 +101099,7 @@ var ts;
100706
101099
  */
100707
101100
  function createFunctionForInitializerOfForStatement(node, currentState) {
100708
101101
  var functionName = factory.createUniqueName("_loop_init");
100709
- var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0;
101102
+ var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0;
100710
101103
  var emitFlags = 0 /* None */;
100711
101104
  if (currentState.containsLexicalThis)
100712
101105
  emitFlags |= 8 /* CapturesThis */;
@@ -100821,7 +101214,7 @@ var ts;
100821
101214
  var loopBody = factory.createBlock(statements, /*multiLine*/ true);
100822
101215
  if (ts.isBlock(statement))
100823
101216
  ts.setOriginalNode(loopBody, statement);
100824
- var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0;
101217
+ var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0;
100825
101218
  var emitFlags = 524288 /* ReuseTempVariableScope */;
100826
101219
  if (currentState.containsLexicalThis)
100827
101220
  emitFlags |= 8 /* CapturesThis */;
@@ -101303,7 +101696,7 @@ var ts;
101303
101696
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
101304
101697
  // We are here either because SuperKeyword was used somewhere in the expression, or
101305
101698
  // because we contain a SpreadElementExpression.
101306
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */ ||
101699
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */ ||
101307
101700
  node.expression.kind === 106 /* SuperKeyword */ ||
101308
101701
  ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
101309
101702
  var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
@@ -101311,7 +101704,7 @@ var ts;
101311
101704
  ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
101312
101705
  }
101313
101706
  var resultingCall = void 0;
101314
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
101707
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
101315
101708
  // [source]
101316
101709
  // f(...a, b)
101317
101710
  // x.m(...a, b)
@@ -102153,10 +102546,10 @@ var ts;
102153
102546
  case 247 /* ReturnStatement */:
102154
102547
  return visitReturnStatement(node);
102155
102548
  default:
102156
- if (node.transformFlags & 524288 /* ContainsYield */) {
102549
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102157
102550
  return visitJavaScriptContainingYield(node);
102158
102551
  }
102159
- else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
102552
+ else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) {
102160
102553
  return ts.visitEachChild(node, visitor, context);
102161
102554
  }
102162
102555
  else {
@@ -102361,7 +102754,7 @@ var ts;
102361
102754
  * @param node The node to visit.
102362
102755
  */
102363
102756
  function visitVariableStatement(node) {
102364
- if (node.transformFlags & 524288 /* ContainsYield */) {
102757
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102365
102758
  transformAndEmitVariableDeclarationList(node.declarationList);
102366
102759
  return undefined;
102367
102760
  }
@@ -103419,7 +103812,7 @@ var ts;
103419
103812
  }
103420
103813
  }
103421
103814
  function containsYield(node) {
103422
- return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0;
103815
+ return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0;
103423
103816
  }
103424
103817
  function countInitialNodesWithoutYield(nodes) {
103425
103818
  var numNodes = nodes.length;
@@ -104468,7 +104861,7 @@ var ts;
104468
104861
  function transformSourceFile(node) {
104469
104862
  if (node.isDeclarationFile ||
104470
104863
  !(ts.isEffectiveExternalModule(node, compilerOptions) ||
104471
- node.transformFlags & 4194304 /* ContainsDynamicImport */ ||
104864
+ node.transformFlags & 8388608 /* ContainsDynamicImport */ ||
104472
104865
  (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
104473
104866
  return node;
104474
104867
  }
@@ -104805,7 +105198,7 @@ var ts;
104805
105198
  function visitorWorker(node, valueIsDiscarded) {
104806
105199
  // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
104807
105200
  // as export/import statements are only transformed at the top level of a file.
104808
- if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
105201
+ if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
104809
105202
  return node;
104810
105203
  }
104811
105204
  switch (node.kind) {
@@ -104956,7 +105349,7 @@ var ts;
104956
105349
  var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
104957
105350
  // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output.
104958
105351
  var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
104959
- var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */);
105352
+ var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
104960
105353
  switch (compilerOptions.module) {
104961
105354
  case ts.ModuleKind.AMD:
104962
105355
  return createImportCallExpressionAMD(argument, containsLexicalThis);
@@ -105943,7 +106336,7 @@ var ts;
105943
106336
  * @param node The SourceFile node.
105944
106337
  */
105945
106338
  function transformSourceFile(node) {
105946
- if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) {
106339
+ if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) {
105947
106340
  return node;
105948
106341
  }
105949
106342
  var id = ts.getOriginalNodeId(node);
@@ -106112,7 +106505,7 @@ var ts;
106112
106505
  // - Temporary variables will appear at the top rather than at the bottom of the file
106113
106506
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
106114
106507
  var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
106115
- var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ?
106508
+ var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ?
106116
106509
  factory.createModifiersFromModifierFlags(256 /* Async */) :
106117
106510
  undefined;
106118
106511
  var moduleObject = factory.createObjectLiteralExpression([
@@ -107021,7 +107414,7 @@ var ts;
107021
107414
  * @param node The node to visit.
107022
107415
  */
107023
107416
  function visitorWorker(node, valueIsDiscarded) {
107024
- if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
107417
+ if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
107025
107418
  return node;
107026
107419
  }
107027
107420
  switch (node.kind) {
@@ -109564,6 +109957,7 @@ var ts;
109564
109957
  var transformers = [];
109565
109958
  ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
109566
109959
  transformers.push(ts.transformTypeScript);
109960
+ transformers.push(ts.transformLegacyDecorators);
109567
109961
  transformers.push(ts.transformClassFields);
109568
109962
  if (ts.getJSXTransformEnabled(compilerOptions)) {
109569
109963
  transformers.push(ts.transformJsx);
@@ -167468,7 +167862,7 @@ var ts;
167468
167862
  if (_this.safeList === undefined) {
167469
167863
  _this.safeList = ts.JsTyping.loadSafeList(_this.host, ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
167470
167864
  }
167471
- return ts.JsTyping.discoverTypings(_this.host, function (msg) { return _this.logger.log(msg); }, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), _this.safeList, info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports, info.typesRegistry);
167865
+ return ts.JsTyping.discoverTypings(_this.host, function (msg) { return _this.logger.log(msg); }, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), _this.safeList, info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports, info.typesRegistry, ts.emptyOptions);
167472
167866
  });
167473
167867
  };
167474
167868
  return CoreServicesShimObject;
@@ -167737,7 +168131,7 @@ var ts;
167737
168131
  * @param typeAcquisition is used to customize the typing acquisition process
167738
168132
  * @param compilerOptions are used as a source for typing inference
167739
168133
  */
167740
- function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
168134
+ function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
167741
168135
  if (!typeAcquisition || !typeAcquisition.enable) {
167742
168136
  return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
167743
168137
  }
@@ -167755,12 +168149,14 @@ var ts;
167755
168149
  addInferredTypings(typeAcquisition.include, "Explicitly included types");
167756
168150
  var exclude = typeAcquisition.exclude || [];
167757
168151
  // Directories to search for package.json, bower.json and other typing information
167758
- var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
167759
- possibleSearchDirs.add(projectRootPath);
167760
- possibleSearchDirs.forEach(function (searchDir) {
167761
- getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
167762
- getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
167763
- });
168152
+ if (!compilerOptions.types) {
168153
+ var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
168154
+ possibleSearchDirs.add(projectRootPath);
168155
+ possibleSearchDirs.forEach(function (searchDir) {
168156
+ getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
168157
+ getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
168158
+ });
168159
+ }
167764
168160
  if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
167765
168161
  getTypingNamesFromSourceFileNames(fileNames);
167766
168162
  }