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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220603";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220604";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5766,21 +5766,22 @@ var ts;
5766
5766
  TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 4096] = "ContainsDestructuringAssignment";
5767
5767
  // Markers
5768
5768
  // - Flags used to indicate that a subtree contains a specific transformation.
5769
- TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax";
5770
- TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis";
5771
- TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread";
5772
- TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread";
5773
- TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName";
5774
- TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding";
5775
- TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern";
5776
- TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield";
5777
- TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait";
5778
- TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion";
5779
- TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport";
5780
- TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields";
5781
- TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait";
5782
- TransformFlags[TransformFlags["ContainsLexicalSuper"] = 33554432] = "ContainsLexicalSuper";
5783
- TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 67108864] = "ContainsUpdateExpressionForIdentifier";
5769
+ TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 8192] = "ContainsTypeScriptClassSyntax";
5770
+ TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis";
5771
+ TransformFlags[TransformFlags["ContainsRestOrSpread"] = 32768] = "ContainsRestOrSpread";
5772
+ TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 65536] = "ContainsObjectRestOrSpread";
5773
+ TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 131072] = "ContainsComputedPropertyName";
5774
+ TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 262144] = "ContainsBlockScopedBinding";
5775
+ TransformFlags[TransformFlags["ContainsBindingPattern"] = 524288] = "ContainsBindingPattern";
5776
+ TransformFlags[TransformFlags["ContainsYield"] = 1048576] = "ContainsYield";
5777
+ TransformFlags[TransformFlags["ContainsAwait"] = 2097152] = "ContainsAwait";
5778
+ TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 4194304] = "ContainsHoistedDeclarationOrCompletion";
5779
+ TransformFlags[TransformFlags["ContainsDynamicImport"] = 8388608] = "ContainsDynamicImport";
5780
+ TransformFlags[TransformFlags["ContainsClassFields"] = 16777216] = "ContainsClassFields";
5781
+ TransformFlags[TransformFlags["ContainsDecorators"] = 33554432] = "ContainsDecorators";
5782
+ TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5783
+ TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5784
+ TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5784
5785
  // Please leave this as 1 << 29.
5785
5786
  // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5786
5787
  // It is a good reminder of how much room we have left
@@ -5806,24 +5807,24 @@ var ts;
5806
5807
  TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5807
5808
  TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5808
5809
  TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5809
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes";
5810
- TransformFlags[TransformFlags["FunctionExcludes"] = 591310848] = "FunctionExcludes";
5811
- TransformFlags[TransformFlags["ConstructorExcludes"] = 591306752] = "ConstructorExcludes";
5812
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 574529536] = "MethodOrAccessorExcludes";
5813
- TransformFlags[TransformFlags["PropertyExcludes"] = 570433536] = "PropertyExcludes";
5814
- TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes";
5815
- TransformFlags[TransformFlags["ModuleExcludes"] = 589443072] = "ModuleExcludes";
5810
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5811
+ TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5812
+ TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5813
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5814
+ TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5815
+ TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5816
+ TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5816
5817
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5817
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes";
5818
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes";
5819
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes";
5818
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5819
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5820
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5820
5821
  TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5821
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes";
5822
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes";
5823
- TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 33562624] = "ContainsLexicalThisOrSuper";
5822
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5823
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5824
+ TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5824
5825
  // Propagating flags
5825
5826
  // - Bitmasks for flags that should propagate from a child
5826
- TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 33562624] = "PropertyNamePropagatingFlags";
5827
+ TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 134234112] = "PropertyNamePropagatingFlags";
5827
5828
  // Masks
5828
5829
  // - Additional bitmasks
5829
5830
  })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
@@ -17195,6 +17196,12 @@ var ts;
17195
17196
  return [child, node];
17196
17197
  }
17197
17198
  ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
17199
+ function skipTypeParentheses(node) {
17200
+ while (ts.isParenthesizedTypeNode(node))
17201
+ node = node.type;
17202
+ return node;
17203
+ }
17204
+ ts.skipTypeParentheses = skipTypeParentheses;
17198
17205
  function skipParentheses(node, excludeJSDocTypeAssertions) {
17199
17206
  var flags = excludeJSDocTypeAssertions ?
17200
17207
  1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ :
@@ -19429,7 +19436,7 @@ var ts;
19429
19436
  * Moves the start position of a range past any decorators.
19430
19437
  */
19431
19438
  function moveRangePastDecorators(node) {
19432
- return node.decorators && node.decorators.length > 0
19439
+ return node.decorators && !positionIsSynthesized(node.decorators.end)
19433
19440
  ? moveRangePos(node, node.decorators.end)
19434
19441
  : node;
19435
19442
  }
@@ -19438,7 +19445,7 @@ var ts;
19438
19445
  * Moves the start position of a range past any decorators or modifiers.
19439
19446
  */
19440
19447
  function moveRangePastModifiers(node) {
19441
- return node.modifiers && node.modifiers.length > 0
19448
+ return node.modifiers && !positionIsSynthesized(node.modifiers.end)
19442
19449
  ? moveRangePos(node, node.modifiers.end)
19443
19450
  : moveRangePastDecorators(node);
19444
19451
  }
@@ -22868,7 +22875,7 @@ var ts;
22868
22875
  function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
22869
22876
  var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
22870
22877
  node.body = body;
22871
- node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */;
22878
+ node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */;
22872
22879
  if (!body)
22873
22880
  node.transformFlags |= 1 /* ContainsTypeScript */;
22874
22881
  return node;
@@ -22996,7 +23003,7 @@ var ts;
22996
23003
  node.typeArguments = createNodeArray(typeArguments);
22997
23004
  }
22998
23005
  if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
22999
- node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */;
23006
+ node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */;
23000
23007
  }
23001
23008
  return node;
23002
23009
  }
@@ -23048,7 +23055,7 @@ var ts;
23048
23055
  ts.Debug.fail("First character of private identifier must be #: " + text);
23049
23056
  var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */);
23050
23057
  node.escapedText = ts.escapeLeadingUnderscores(text);
23051
- node.transformFlags |= 8388608 /* ContainsClassFields */;
23058
+ node.transformFlags |= 16777216 /* ContainsClassFields */;
23052
23059
  return node;
23053
23060
  }
23054
23061
  //
@@ -23095,14 +23102,14 @@ var ts;
23095
23102
  transformFlags = 1 /* ContainsTypeScript */;
23096
23103
  break;
23097
23104
  case 106 /* SuperKeyword */:
23098
- transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
23105
+ transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */;
23099
23106
  break;
23100
23107
  case 124 /* StaticKeyword */:
23101
23108
  transformFlags = 1024 /* ContainsES2015 */;
23102
23109
  break;
23103
23110
  case 108 /* ThisKeyword */:
23104
23111
  // 'this' indicates a lexical 'this'
23105
- transformFlags = 8192 /* ContainsLexicalThis */;
23112
+ transformFlags = 16384 /* ContainsLexicalThis */;
23106
23113
  break;
23107
23114
  }
23108
23115
  if (transformFlags) {
@@ -23200,7 +23207,7 @@ var ts;
23200
23207
  node.transformFlags |=
23201
23208
  propagateChildFlags(node.expression) |
23202
23209
  1024 /* ContainsES2015 */ |
23203
- 65536 /* ContainsComputedPropertyName */;
23210
+ 131072 /* ContainsComputedPropertyName */;
23204
23211
  return node;
23205
23212
  }
23206
23213
  // @api
@@ -23266,7 +23273,7 @@ var ts;
23266
23273
  if (questionToken)
23267
23274
  node.transformFlags |= 1 /* ContainsTypeScript */;
23268
23275
  if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
23269
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23276
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23270
23277
  if (initializer || dotDotDotToken)
23271
23278
  node.transformFlags |= 1024 /* ContainsES2015 */;
23272
23279
  }
@@ -23291,7 +23298,8 @@ var ts;
23291
23298
  node.transformFlags |=
23292
23299
  propagateChildFlags(node.expression) |
23293
23300
  1 /* ContainsTypeScript */ |
23294
- 4096 /* ContainsTypeScriptClassSyntax */;
23301
+ 8192 /* ContainsTypeScriptClassSyntax */ |
23302
+ 33554432 /* ContainsDecorators */;
23295
23303
  return node;
23296
23304
  }
23297
23305
  // @api
@@ -23329,9 +23337,9 @@ var ts;
23329
23337
  node.transformFlags |=
23330
23338
  propagateChildFlags(node.questionToken) |
23331
23339
  propagateChildFlags(node.exclamationToken) |
23332
- 8388608 /* ContainsClassFields */;
23340
+ 16777216 /* ContainsClassFields */;
23333
23341
  if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
23334
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23342
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23335
23343
  }
23336
23344
  if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
23337
23345
  node.transformFlags |= 1 /* ContainsTypeScript */;
@@ -23414,7 +23422,7 @@ var ts;
23414
23422
  /*name*/ undefined,
23415
23423
  /*typeParameters*/ undefined);
23416
23424
  node.body = body;
23417
- node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */;
23425
+ node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */;
23418
23426
  return node;
23419
23427
  }
23420
23428
  // @api
@@ -23938,11 +23946,11 @@ var ts;
23938
23946
  node.transformFlags |=
23939
23947
  propagateChildrenFlags(node.elements) |
23940
23948
  1024 /* ContainsES2015 */ |
23941
- 262144 /* ContainsBindingPattern */;
23942
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
23949
+ 524288 /* ContainsBindingPattern */;
23950
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
23943
23951
  node.transformFlags |=
23944
23952
  128 /* ContainsES2018 */ |
23945
- 32768 /* ContainsObjectRestOrSpread */;
23953
+ 65536 /* ContainsObjectRestOrSpread */;
23946
23954
  }
23947
23955
  return node;
23948
23956
  }
@@ -23959,7 +23967,7 @@ var ts;
23959
23967
  node.transformFlags |=
23960
23968
  propagateChildrenFlags(node.elements) |
23961
23969
  1024 /* ContainsES2015 */ |
23962
- 262144 /* ContainsBindingPattern */;
23970
+ 524288 /* ContainsBindingPattern */;
23963
23971
  return node;
23964
23972
  }
23965
23973
  // @api
@@ -23984,7 +23992,7 @@ var ts;
23984
23992
  propagateChildFlags(node.propertyName);
23985
23993
  }
23986
23994
  if (dotDotDotToken)
23987
- node.transformFlags |= 16384 /* ContainsRestOrSpread */;
23995
+ node.transformFlags |= 32768 /* ContainsRestOrSpread */;
23988
23996
  return node;
23989
23997
  }
23990
23998
  // @api
@@ -24159,10 +24167,10 @@ var ts;
24159
24167
  node.transformFlags |= 1 /* ContainsTypeScript */;
24160
24168
  }
24161
24169
  if (ts.isImportKeyword(node.expression)) {
24162
- node.transformFlags |= 4194304 /* ContainsDynamicImport */;
24170
+ node.transformFlags |= 8388608 /* ContainsDynamicImport */;
24163
24171
  }
24164
24172
  else if (ts.isSuperProperty(node.expression)) {
24165
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
24173
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
24166
24174
  }
24167
24175
  return node;
24168
24176
  }
@@ -24195,7 +24203,7 @@ var ts;
24195
24203
  node.transformFlags |= 1 /* ContainsTypeScript */;
24196
24204
  }
24197
24205
  if (ts.isSuperProperty(node.expression)) {
24198
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
24206
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
24199
24207
  }
24200
24208
  return node;
24201
24209
  }
@@ -24335,7 +24343,7 @@ var ts;
24335
24343
  propagateChildFlags(node.equalsGreaterThanToken) |
24336
24344
  1024 /* ContainsES2015 */;
24337
24345
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24338
- node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
24346
+ node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */;
24339
24347
  }
24340
24348
  return node;
24341
24349
  }
@@ -24397,7 +24405,7 @@ var ts;
24397
24405
  propagateChildFlags(node.expression) |
24398
24406
  256 /* ContainsES2017 */ |
24399
24407
  128 /* ContainsES2018 */ |
24400
- 1048576 /* ContainsAwait */;
24408
+ 2097152 /* ContainsAwait */;
24401
24409
  return node;
24402
24410
  }
24403
24411
  // @api
@@ -24418,7 +24426,7 @@ var ts;
24418
24426
  ts.isIdentifier(node.operand) &&
24419
24427
  !ts.isGeneratedIdentifier(node.operand) &&
24420
24428
  !ts.isLocalName(node.operand)) {
24421
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24429
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24422
24430
  }
24423
24431
  return node;
24424
24432
  }
@@ -24439,7 +24447,7 @@ var ts;
24439
24447
  if (ts.isIdentifier(node.operand) &&
24440
24448
  !ts.isGeneratedIdentifier(node.operand) &&
24441
24449
  !ts.isLocalName(node.operand)) {
24442
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24450
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24443
24451
  }
24444
24452
  return node;
24445
24453
  }
@@ -24488,8 +24496,8 @@ var ts;
24488
24496
  return node;
24489
24497
  }
24490
24498
  function propagateAssignmentPatternFlags(node) {
24491
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */)
24492
- return 32768 /* ContainsObjectRestOrSpread */;
24499
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */)
24500
+ return 65536 /* ContainsObjectRestOrSpread */;
24493
24501
  if (node.transformFlags & 128 /* ContainsES2018 */) {
24494
24502
  // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
24495
24503
  // will not be correctly interpreted by the ES2018 transformer
@@ -24497,8 +24505,8 @@ var ts;
24497
24505
  var element = _a[_i];
24498
24506
  var target = ts.getTargetOfBindingOrAssignmentElement(element);
24499
24507
  if (target && ts.isAssignmentPattern(target)) {
24500
- if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
24501
- return 32768 /* ContainsObjectRestOrSpread */;
24508
+ if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
24509
+ return 65536 /* ContainsObjectRestOrSpread */;
24502
24510
  }
24503
24511
  if (target.transformFlags & 128 /* ContainsES2018 */) {
24504
24512
  var flags_1 = propagateAssignmentPatternFlags(target);
@@ -24624,7 +24632,7 @@ var ts;
24624
24632
  propagateChildFlags(node.asteriskToken) |
24625
24633
  1024 /* ContainsES2015 */ |
24626
24634
  128 /* ContainsES2018 */ |
24627
- 524288 /* ContainsYield */;
24635
+ 1048576 /* ContainsYield */;
24628
24636
  return node;
24629
24637
  }
24630
24638
  // @api
@@ -24641,7 +24649,7 @@ var ts;
24641
24649
  node.transformFlags |=
24642
24650
  propagateChildFlags(node.expression) |
24643
24651
  1024 /* ContainsES2015 */ |
24644
- 16384 /* ContainsRestOrSpread */;
24652
+ 32768 /* ContainsRestOrSpread */;
24645
24653
  return node;
24646
24654
  }
24647
24655
  // @api
@@ -24974,7 +24982,7 @@ var ts;
24974
24982
  node.label = asName(label);
24975
24983
  node.transformFlags |=
24976
24984
  propagateChildFlags(node.label) |
24977
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24985
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24978
24986
  return node;
24979
24987
  }
24980
24988
  // @api
@@ -24989,7 +24997,7 @@ var ts;
24989
24997
  node.label = asName(label);
24990
24998
  node.transformFlags |=
24991
24999
  propagateChildFlags(node.label) |
24992
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25000
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24993
25001
  return node;
24994
25002
  }
24995
25003
  // @api
@@ -25006,7 +25014,7 @@ var ts;
25006
25014
  node.transformFlags |=
25007
25015
  propagateChildFlags(node.expression) |
25008
25016
  128 /* ContainsES2018 */ |
25009
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25017
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
25010
25018
  return node;
25011
25019
  }
25012
25020
  // @api
@@ -25132,11 +25140,11 @@ var ts;
25132
25140
  node.declarations = createNodeArray(declarations);
25133
25141
  node.transformFlags |=
25134
25142
  propagateChildrenFlags(node.declarations) |
25135
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25143
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
25136
25144
  if (flags & 3 /* BlockScoped */) {
25137
25145
  node.transformFlags |=
25138
25146
  1024 /* ContainsES2015 */ |
25139
- 131072 /* ContainsBlockScopedBinding */;
25147
+ 262144 /* ContainsBlockScopedBinding */;
25140
25148
  }
25141
25149
  return node;
25142
25150
  }
@@ -25156,7 +25164,7 @@ var ts;
25156
25164
  else {
25157
25165
  node.transformFlags |=
25158
25166
  propagateChildFlags(node.asteriskToken) |
25159
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25167
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
25160
25168
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
25161
25169
  if (node.asteriskToken) {
25162
25170
  node.transformFlags |= 128 /* ContainsES2018 */;
@@ -25192,7 +25200,7 @@ var ts;
25192
25200
  }
25193
25201
  else {
25194
25202
  node.transformFlags |= 1024 /* ContainsES2015 */;
25195
- if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) {
25203
+ if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) {
25196
25204
  node.transformFlags |= 1 /* ContainsTypeScript */;
25197
25205
  }
25198
25206
  }
@@ -25251,7 +25259,7 @@ var ts;
25251
25259
  node.transformFlags |=
25252
25260
  propagateChildrenFlags(node.members) |
25253
25261
  1 /* ContainsTypeScript */;
25254
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25262
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25255
25263
  return node;
25256
25264
  }
25257
25265
  // @api
@@ -25279,7 +25287,7 @@ var ts;
25279
25287
  propagateChildFlags(node.body) |
25280
25288
  1 /* ContainsTypeScript */;
25281
25289
  }
25282
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25290
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25283
25291
  return node;
25284
25292
  }
25285
25293
  // @api
@@ -25339,7 +25347,7 @@ var ts;
25339
25347
  node.transformFlags |= propagateChildFlags(node.moduleReference);
25340
25348
  if (!ts.isExternalModuleReference(node.moduleReference))
25341
25349
  node.transformFlags |= 1 /* ContainsTypeScript */;
25342
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25350
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25343
25351
  return node;
25344
25352
  }
25345
25353
  // @api
@@ -25361,7 +25369,7 @@ var ts;
25361
25369
  node.transformFlags |=
25362
25370
  propagateChildFlags(node.importClause) |
25363
25371
  propagateChildFlags(node.moduleSpecifier);
25364
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25372
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25365
25373
  return node;
25366
25374
  }
25367
25375
  // @api
@@ -25386,7 +25394,7 @@ var ts;
25386
25394
  if (isTypeOnly) {
25387
25395
  node.transformFlags |= 1 /* ContainsTypeScript */;
25388
25396
  }
25389
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25397
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25390
25398
  return node;
25391
25399
  }
25392
25400
  // @api
@@ -25446,7 +25454,7 @@ var ts;
25446
25454
  var node = createBaseNode(268 /* NamespaceImport */);
25447
25455
  node.name = name;
25448
25456
  node.transformFlags |= propagateChildFlags(node.name);
25449
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25457
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25450
25458
  return node;
25451
25459
  }
25452
25460
  // @api
@@ -25462,7 +25470,7 @@ var ts;
25462
25470
  node.transformFlags |=
25463
25471
  propagateChildFlags(node.name) |
25464
25472
  4 /* ContainsESNext */;
25465
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25473
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25466
25474
  return node;
25467
25475
  }
25468
25476
  // @api
@@ -25476,7 +25484,7 @@ var ts;
25476
25484
  var node = createBaseNode(269 /* NamedImports */);
25477
25485
  node.elements = createNodeArray(elements);
25478
25486
  node.transformFlags |= propagateChildrenFlags(node.elements);
25479
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25487
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25480
25488
  return node;
25481
25489
  }
25482
25490
  // @api
@@ -25494,7 +25502,7 @@ var ts;
25494
25502
  node.transformFlags |=
25495
25503
  propagateChildFlags(node.propertyName) |
25496
25504
  propagateChildFlags(node.name);
25497
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25505
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25498
25506
  return node;
25499
25507
  }
25500
25508
  // @api
@@ -25513,7 +25521,7 @@ var ts;
25513
25521
  ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression)
25514
25522
  : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
25515
25523
  node.transformFlags |= propagateChildFlags(node.expression);
25516
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25524
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25517
25525
  return node;
25518
25526
  }
25519
25527
  // @api
@@ -25534,7 +25542,7 @@ var ts;
25534
25542
  node.transformFlags |=
25535
25543
  propagateChildFlags(node.exportClause) |
25536
25544
  propagateChildFlags(node.moduleSpecifier);
25537
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25545
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25538
25546
  return node;
25539
25547
  }
25540
25548
  // @api
@@ -25553,7 +25561,7 @@ var ts;
25553
25561
  var node = createBaseNode(273 /* NamedExports */);
25554
25562
  node.elements = createNodeArray(elements);
25555
25563
  node.transformFlags |= propagateChildrenFlags(node.elements);
25556
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25564
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25557
25565
  return node;
25558
25566
  }
25559
25567
  // @api
@@ -25571,7 +25579,7 @@ var ts;
25571
25579
  node.transformFlags |=
25572
25580
  propagateChildFlags(node.propertyName) |
25573
25581
  propagateChildFlags(node.name);
25574
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25582
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25575
25583
  return node;
25576
25584
  }
25577
25585
  // @api
@@ -25597,7 +25605,7 @@ var ts;
25597
25605
  var node = createBaseNode(277 /* ExternalModuleReference */);
25598
25606
  node.expression = expression;
25599
25607
  node.transformFlags |= propagateChildFlags(node.expression);
25600
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25608
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25601
25609
  return node;
25602
25610
  }
25603
25611
  // @api
@@ -26371,7 +26379,7 @@ var ts;
26371
26379
  node.transformFlags |=
26372
26380
  propagateChildFlags(node.expression) |
26373
26381
  128 /* ContainsES2018 */ |
26374
- 32768 /* ContainsObjectRestOrSpread */;
26382
+ 65536 /* ContainsObjectRestOrSpread */;
26375
26383
  return node;
26376
26384
  }
26377
26385
  // @api
@@ -27328,10 +27336,10 @@ var ts;
27328
27336
  }
27329
27337
  function propagateIdentifierNameFlags(node) {
27330
27338
  // An IdentifierName is allowed to be `await`
27331
- return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */;
27339
+ return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
27332
27340
  }
27333
27341
  function propagatePropertyNameFlagsOfChild(node, transformFlags) {
27334
- return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */);
27342
+ return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */);
27335
27343
  }
27336
27344
  function propagateChildFlags(child) {
27337
27345
  if (!child)
@@ -27362,29 +27370,29 @@ var ts;
27362
27370
  case 208 /* CallExpression */:
27363
27371
  case 209 /* NewExpression */:
27364
27372
  case 204 /* ArrayLiteralExpression */:
27365
- return 536887296 /* ArrayLiteralOrCallOrNewExcludes */;
27373
+ return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27366
27374
  case 261 /* ModuleDeclaration */:
27367
- return 589443072 /* ModuleExcludes */;
27375
+ return 742678528 /* ModuleExcludes */;
27368
27376
  case 164 /* Parameter */:
27369
27377
  return 536870912 /* ParameterExcludes */;
27370
27378
  case 214 /* ArrowFunction */:
27371
- return 557748224 /* ArrowFunctionExcludes */;
27379
+ return 612179968 /* ArrowFunctionExcludes */;
27372
27380
  case 213 /* FunctionExpression */:
27373
27381
  case 256 /* FunctionDeclaration */:
27374
- return 591310848 /* FunctionExcludes */;
27382
+ return 746414080 /* FunctionExcludes */;
27375
27383
  case 255 /* VariableDeclarationList */:
27376
- return 537165824 /* VariableDeclarationListExcludes */;
27384
+ return 537460736 /* VariableDeclarationListExcludes */;
27377
27385
  case 257 /* ClassDeclaration */:
27378
27386
  case 226 /* ClassExpression */:
27379
- return 536940544 /* ClassExcludes */;
27387
+ return 537010176 /* ClassExcludes */;
27380
27388
  case 171 /* Constructor */:
27381
- return 591306752 /* ConstructorExcludes */;
27389
+ return 746405888 /* ConstructorExcludes */;
27382
27390
  case 167 /* PropertyDeclaration */:
27383
- return 570433536 /* PropertyExcludes */;
27391
+ return 671105024 /* PropertyExcludes */;
27384
27392
  case 169 /* MethodDeclaration */:
27385
27393
  case 172 /* GetAccessor */:
27386
27394
  case 173 /* SetAccessor */:
27387
- return 574529536 /* MethodOrAccessorExcludes */;
27395
+ return 679297024 /* MethodOrAccessorExcludes */;
27388
27396
  case 130 /* AnyKeyword */:
27389
27397
  case 147 /* NumberKeyword */:
27390
27398
  case 158 /* BigIntKeyword */:
@@ -27404,12 +27412,12 @@ var ts;
27404
27412
  case 259 /* TypeAliasDeclaration */:
27405
27413
  return -2 /* TypeExcludes */;
27406
27414
  case 205 /* ObjectLiteralExpression */:
27407
- return 536973312 /* ObjectLiteralExcludes */;
27415
+ return 537075712 /* ObjectLiteralExcludes */;
27408
27416
  case 292 /* CatchClause */:
27409
- return 536903680 /* CatchClauseExcludes */;
27417
+ return 536936448 /* CatchClauseExcludes */;
27410
27418
  case 201 /* ObjectBindingPattern */:
27411
27419
  case 202 /* ArrayBindingPattern */:
27412
- return 536887296 /* BindingPatternExcludes */;
27420
+ return 536903680 /* BindingPatternExcludes */;
27413
27421
  case 211 /* TypeAssertionExpression */:
27414
27422
  case 229 /* AsExpression */:
27415
27423
  case 350 /* PartiallyEmittedExpression */:
@@ -30643,6 +30651,14 @@ var ts;
30643
30651
  }
30644
30652
  }
30645
30653
  ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline;
30654
+ function elideNodes(factory, nodes) {
30655
+ if (nodes === undefined)
30656
+ return undefined;
30657
+ if (nodes.length === 0)
30658
+ return nodes;
30659
+ return ts.setTextRange(factory.createNodeArray([], nodes.hasTrailingComma), nodes);
30660
+ }
30661
+ ts.elideNodes = elideNodes;
30646
30662
  })(ts || (ts = {}));
30647
30663
  var ts;
30648
30664
  (function (ts) {
@@ -31814,7 +31830,7 @@ var ts;
31814
31830
  return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
31815
31831
  function containsPossibleTopLevelAwait(node) {
31816
31832
  return !(node.flags & 32768 /* AwaitContext */)
31817
- && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */);
31833
+ && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */);
31818
31834
  }
31819
31835
  function findNextStatementWithAwait(statements, start) {
31820
31836
  for (var i = start; i < statements.length; i++) {
@@ -31855,7 +31871,7 @@ var ts;
31855
31871
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31856
31872
  setFields(sourceFile);
31857
31873
  // If we parsed this as an external module, it may contain top-level await
31858
- if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31874
+ if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
31859
31875
  sourceFile = reparseTopLevelAwait(sourceFile);
31860
31876
  setFields(sourceFile);
31861
31877
  }
@@ -91253,6 +91269,124 @@ var ts;
91253
91269
  return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name);
91254
91270
  }
91255
91271
  ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName;
91272
+ /**
91273
+ * Gets an array of arrays of decorators for the parameters of a function-like node.
91274
+ * The offset into the result array should correspond to the offset of the parameter.
91275
+ *
91276
+ * @param node The function-like node.
91277
+ */
91278
+ function getDecoratorsOfParameters(node) {
91279
+ var decorators;
91280
+ if (node) {
91281
+ var parameters = node.parameters;
91282
+ var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
91283
+ var firstParameterOffset = firstParameterIsThis ? 1 : 0;
91284
+ var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
91285
+ for (var i = 0; i < numParameters; i++) {
91286
+ var parameter = parameters[i + firstParameterOffset];
91287
+ if (decorators || parameter.decorators) {
91288
+ if (!decorators) {
91289
+ decorators = new Array(numParameters);
91290
+ }
91291
+ decorators[i] = parameter.decorators;
91292
+ }
91293
+ }
91294
+ }
91295
+ return decorators;
91296
+ }
91297
+ /**
91298
+ * Gets an AllDecorators object containing the decorators for the class and the decorators for the
91299
+ * parameters of the constructor of the class.
91300
+ *
91301
+ * @param node The class node.
91302
+ */
91303
+ function getAllDecoratorsOfClass(node) {
91304
+ var decorators = node.decorators;
91305
+ var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
91306
+ if (!decorators && !parameters) {
91307
+ return undefined;
91308
+ }
91309
+ return {
91310
+ decorators: decorators,
91311
+ parameters: parameters
91312
+ };
91313
+ }
91314
+ ts.getAllDecoratorsOfClass = getAllDecoratorsOfClass;
91315
+ /**
91316
+ * Gets an AllDecorators object containing the decorators for the member and its parameters.
91317
+ *
91318
+ * @param parent The class node that contains the member.
91319
+ * @param member The class member.
91320
+ */
91321
+ function getAllDecoratorsOfClassElement(member, parent) {
91322
+ switch (member.kind) {
91323
+ case 172 /* GetAccessor */:
91324
+ case 173 /* SetAccessor */:
91325
+ return getAllDecoratorsOfAccessors(member, parent);
91326
+ case 169 /* MethodDeclaration */:
91327
+ return getAllDecoratorsOfMethod(member);
91328
+ case 167 /* PropertyDeclaration */:
91329
+ return getAllDecoratorsOfProperty(member);
91330
+ default:
91331
+ return undefined;
91332
+ }
91333
+ }
91334
+ ts.getAllDecoratorsOfClassElement = getAllDecoratorsOfClassElement;
91335
+ /**
91336
+ * Gets an AllDecorators object containing the decorators for the accessor and its parameters.
91337
+ *
91338
+ * @param parent The class node that contains the accessor.
91339
+ * @param accessor The class accessor member.
91340
+ */
91341
+ function getAllDecoratorsOfAccessors(accessor, parent) {
91342
+ if (!accessor.body) {
91343
+ return undefined;
91344
+ }
91345
+ var _a = ts.getAllAccessorDeclarations(parent.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
91346
+ var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
91347
+ if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
91348
+ return undefined;
91349
+ }
91350
+ var decorators = firstAccessorWithDecorators.decorators;
91351
+ var parameters = getDecoratorsOfParameters(setAccessor);
91352
+ if (!decorators && !parameters) {
91353
+ return undefined;
91354
+ }
91355
+ return {
91356
+ decorators: decorators,
91357
+ parameters: parameters,
91358
+ getDecorators: getAccessor === null || getAccessor === void 0 ? void 0 : getAccessor.decorators,
91359
+ setDecorators: setAccessor === null || setAccessor === void 0 ? void 0 : setAccessor.decorators
91360
+ };
91361
+ }
91362
+ /**
91363
+ * Gets an AllDecorators object containing the decorators for the method and its parameters.
91364
+ *
91365
+ * @param method The class method member.
91366
+ */
91367
+ function getAllDecoratorsOfMethod(method) {
91368
+ if (!method.body) {
91369
+ return undefined;
91370
+ }
91371
+ var decorators = method.decorators;
91372
+ var parameters = getDecoratorsOfParameters(method);
91373
+ if (!decorators && !parameters) {
91374
+ return undefined;
91375
+ }
91376
+ return { decorators: decorators, parameters: parameters };
91377
+ }
91378
+ /**
91379
+ * Gets an AllDecorators object containing the decorators for the property.
91380
+ *
91381
+ * @param property The class property member.
91382
+ */
91383
+ function getAllDecoratorsOfProperty(property) {
91384
+ var decorators = property.decorators;
91385
+ if (!decorators) {
91386
+ return undefined;
91387
+ }
91388
+ return { decorators: decorators };
91389
+ }
91256
91390
  })(ts || (ts = {}));
91257
91391
  /*@internal*/
91258
91392
  var ts;
@@ -91526,8 +91660,8 @@ var ts;
91526
91660
  if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
91527
91661
  var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
91528
91662
  if (flattenContext.level >= 1 /* ObjectRest */
91529
- && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91530
- && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91663
+ && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91664
+ && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91531
91665
  && !ts.isComputedPropertyName(propertyName)) {
91532
91666
  bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
91533
91667
  }
@@ -91593,7 +91727,7 @@ var ts;
91593
91727
  if (flattenContext.level >= 1 /* ObjectRest */) {
91594
91728
  // If an array pattern contains an ObjectRest, we must cache the result so that we
91595
91729
  // can perform the ObjectRest destructuring in a different declaration
91596
- if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91730
+ if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91597
91731
  flattenContext.hasTransformedPriorElement = true;
91598
91732
  var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
91599
91733
  if (flattenContext.hoistTempVariables) {
@@ -91815,8 +91949,6 @@ var ts;
91815
91949
  var USE_NEW_TYPE_METADATA_FORMAT = false;
91816
91950
  var TypeScriptSubstitutionFlags;
91817
91951
  (function (TypeScriptSubstitutionFlags) {
91818
- /** Enables substitutions for decorated classes. */
91819
- TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases";
91820
91952
  /** Enables substitutions for namespace exports. */
91821
91953
  TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports";
91822
91954
  /* Enables substitutions for unqualified enum members */
@@ -91842,9 +91974,9 @@ var ts;
91842
91974
  var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
91843
91975
  var resolver = context.getEmitResolver();
91844
91976
  var compilerOptions = context.getCompilerOptions();
91845
- var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
91846
91977
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
91847
91978
  var moduleKind = ts.getEmitModuleKind(compilerOptions);
91979
+ var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined;
91848
91980
  // Save the previous transformation hooks.
91849
91981
  var previousOnEmitNode = context.onEmitNode;
91850
91982
  var previousOnSubstituteNode = context.onSubstituteNode;
@@ -91859,7 +91991,6 @@ var ts;
91859
91991
  var currentNamespace;
91860
91992
  var currentNamespaceContainerName;
91861
91993
  var currentLexicalScope;
91862
- var currentNameScope;
91863
91994
  var currentScopeFirstDeclarationsOfName;
91864
91995
  var currentClassHasParameterProperties;
91865
91996
  /**
@@ -91867,11 +91998,6 @@ var ts;
91867
91998
  * They are persisted between each SourceFile transformation and should not be reset.
91868
91999
  */
91869
92000
  var enabledSubstitutions;
91870
- /**
91871
- * A map that keeps track of aliases created for classes with decorators to avoid issues
91872
- * with the double-binding behavior of classes.
91873
- */
91874
- var classAliases;
91875
92001
  /**
91876
92002
  * Keeps track of whether we are within any containing namespaces when performing
91877
92003
  * just-in-time substitution while printing an expression identifier.
@@ -91915,7 +92041,6 @@ var ts;
91915
92041
  function saveStateAndInvoke(node, f) {
91916
92042
  // Save state
91917
92043
  var savedCurrentScope = currentLexicalScope;
91918
- var savedCurrentNameScope = currentNameScope;
91919
92044
  var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
91920
92045
  var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
91921
92046
  // Handle state changes before visiting a node.
@@ -91926,7 +92051,6 @@ var ts;
91926
92051
  currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
91927
92052
  }
91928
92053
  currentLexicalScope = savedCurrentScope;
91929
- currentNameScope = savedCurrentNameScope;
91930
92054
  currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
91931
92055
  return visited;
91932
92056
  }
@@ -91942,7 +92066,6 @@ var ts;
91942
92066
  case 262 /* ModuleBlock */:
91943
92067
  case 235 /* Block */:
91944
92068
  currentLexicalScope = node;
91945
- currentNameScope = undefined;
91946
92069
  currentScopeFirstDeclarationsOfName = undefined;
91947
92070
  break;
91948
92071
  case 257 /* ClassDeclaration */:
@@ -91960,10 +92083,6 @@ var ts;
91960
92083
  // programs may also have an undefined name.
91961
92084
  ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
91962
92085
  }
91963
- if (ts.isClassDeclaration(node)) {
91964
- // XXX: should probably also cover interfaces and type aliases that can have type variables?
91965
- currentNameScope = node;
91966
- }
91967
92086
  break;
91968
92087
  }
91969
92088
  }
@@ -92065,35 +92184,66 @@ var ts;
92065
92184
  return node;
92066
92185
  }
92067
92186
  /**
92068
- * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
92187
+ * Gets a specialized visitor that visits the immediate children of a class with TypeScript syntax.
92069
92188
  *
92070
- * @param node The node to visit.
92189
+ * @param parent The class containing the elements to visit.
92071
92190
  */
92072
- function classElementVisitor(node) {
92073
- return saveStateAndInvoke(node, classElementVisitorWorker);
92191
+ function getClassElementVisitor(parent) {
92192
+ return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); };
92074
92193
  }
92075
92194
  /**
92076
92195
  * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
92077
92196
  *
92078
92197
  * @param node The node to visit.
92079
92198
  */
92080
- function classElementVisitorWorker(node) {
92199
+ function classElementVisitorWorker(node, parent) {
92081
92200
  switch (node.kind) {
92082
92201
  case 171 /* Constructor */:
92083
92202
  return visitConstructor(node);
92084
92203
  case 167 /* PropertyDeclaration */:
92085
92204
  // Property declarations are not TypeScript syntax, but they must be visited
92086
92205
  // for the decorator transformation.
92087
- return visitPropertyDeclaration(node);
92088
- case 176 /* IndexSignature */:
92206
+ return visitPropertyDeclaration(node, parent);
92089
92207
  case 172 /* GetAccessor */:
92208
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92209
+ return visitGetAccessor(node, parent);
92090
92210
  case 173 /* SetAccessor */:
92211
+ // Set Accessors can have TypeScript modifiers and type annotations.
92212
+ return visitSetAccessor(node, parent);
92091
92213
  case 169 /* MethodDeclaration */:
92214
+ // TypeScript method declarations may have decorators, modifiers
92215
+ // or type annotations.
92216
+ return visitMethodDeclaration(node, parent);
92092
92217
  case 170 /* ClassStaticBlockDeclaration */:
92093
- // Fallback to the default visit behavior.
92094
- return visitorWorker(node);
92218
+ return ts.visitEachChild(node, visitor, context);
92095
92219
  case 234 /* SemicolonClassElement */:
92096
92220
  return node;
92221
+ case 176 /* IndexSignature */:
92222
+ // Index signatures are elided
92223
+ return;
92224
+ default:
92225
+ return ts.Debug.failBadSyntaxKind(node);
92226
+ }
92227
+ }
92228
+ function getObjectLiteralElementVisitor(parent) {
92229
+ return function (node) { return saveStateAndInvoke(node, function (n) { return objectLiteralElementVisitorWorker(n, parent); }); };
92230
+ }
92231
+ function objectLiteralElementVisitorWorker(node, parent) {
92232
+ switch (node.kind) {
92233
+ case 296 /* PropertyAssignment */:
92234
+ case 297 /* ShorthandPropertyAssignment */:
92235
+ case 298 /* SpreadAssignment */:
92236
+ return visitor(node);
92237
+ case 172 /* GetAccessor */:
92238
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92239
+ return visitGetAccessor(node, parent);
92240
+ case 173 /* SetAccessor */:
92241
+ // Set Accessors can have TypeScript modifiers and type annotations.
92242
+ return visitSetAccessor(node, parent);
92243
+ case 169 /* MethodDeclaration */:
92244
+ // TypeScript method declarations may have decorators, modifiers
92245
+ // or type annotations.
92246
+ return visitMethodDeclaration(node, parent);
92097
92247
  default:
92098
92248
  return ts.Debug.failBadSyntaxKind(node);
92099
92249
  }
@@ -92166,22 +92316,14 @@ var ts;
92166
92316
  // TypeScript type nodes are elided.
92167
92317
  // falls through
92168
92318
  case 176 /* IndexSignature */:
92169
- // TypeScript index signatures are elided.
92170
- // falls through
92171
- case 165 /* Decorator */:
92172
- // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
92319
+ // TypeScript index signatures are elided.
92173
92320
  return undefined;
92174
92321
  case 259 /* TypeAliasDeclaration */:
92175
92322
  // TypeScript type-only declarations are elided.
92176
92323
  return factory.createNotEmittedStatement(node);
92177
- case 167 /* PropertyDeclaration */:
92178
- // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
92179
- return visitPropertyDeclaration(node);
92180
92324
  case 264 /* NamespaceExportDeclaration */:
92181
92325
  // TypeScript namespace export declarations are elided.
92182
92326
  return undefined;
92183
- case 171 /* Constructor */:
92184
- return visitConstructor(node);
92185
92327
  case 258 /* InterfaceDeclaration */:
92186
92328
  // TypeScript interfaces are elided, but some comments may be preserved.
92187
92329
  // See the implementation of `getLeadingComments` in comments.ts for more details.
@@ -92215,16 +92357,15 @@ var ts;
92215
92357
  case 228 /* ExpressionWithTypeArguments */:
92216
92358
  // TypeScript supports type arguments on an expression in an `extends` heritage clause.
92217
92359
  return visitExpressionWithTypeArguments(node);
92360
+ case 205 /* ObjectLiteralExpression */:
92361
+ return visitObjectLiteralExpression(node);
92362
+ case 171 /* Constructor */:
92363
+ case 167 /* PropertyDeclaration */:
92218
92364
  case 169 /* MethodDeclaration */:
92219
- // TypeScript method declarations may have decorators, modifiers
92220
- // or type annotations.
92221
- return visitMethodDeclaration(node);
92222
92365
  case 172 /* GetAccessor */:
92223
- // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92224
- return visitGetAccessor(node);
92225
92366
  case 173 /* SetAccessor */:
92226
- // Set Accessors can have TypeScript modifiers and type annotations.
92227
- return visitSetAccessor(node);
92367
+ case 170 /* ClassStaticBlockDeclaration */:
92368
+ return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors");
92228
92369
  case 256 /* FunctionDeclaration */:
92229
92370
  // Typescript function declarations can have modifiers, decorators, and type annotations.
92230
92371
  return visitFunctionDeclaration(node);
@@ -92290,6 +92431,9 @@ var ts;
92290
92431
  !ts.isJsonSourceFile(node);
92291
92432
  return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
92292
92433
  }
92434
+ function visitObjectLiteralExpression(node) {
92435
+ return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement));
92436
+ }
92293
92437
  function getClassFacts(node, staticProperties) {
92294
92438
  var facts = 0 /* None */;
92295
92439
  if (ts.some(staticProperties))
@@ -92312,7 +92456,7 @@ var ts;
92312
92456
  return facts;
92313
92457
  }
92314
92458
  function hasTypeScriptClassSyntax(node) {
92315
- return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */);
92459
+ return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */);
92316
92460
  }
92317
92461
  function isClassLikeDeclarationWithTypeScriptSyntax(node) {
92318
92462
  return ts.some(node.decorators)
@@ -92322,7 +92466,9 @@ var ts;
92322
92466
  }
92323
92467
  function visitClassDeclaration(node) {
92324
92468
  if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
92325
- return ts.visitEachChild(node, visitor, context);
92469
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92470
+ ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name,
92471
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92326
92472
  }
92327
92473
  var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
92328
92474
  var facts = getClassFacts(node, staticProperties);
@@ -92330,14 +92476,25 @@ var ts;
92330
92476
  context.startLexicalEnvironment();
92331
92477
  }
92332
92478
  var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
92333
- var classStatement = facts & 2 /* HasConstructorDecorators */
92334
- ? createClassDeclarationHeadWithDecorators(node, name)
92335
- : createClassDeclarationHeadWithoutDecorators(node, name, facts);
92479
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92480
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92481
+ // we do not emit modifiers on the declaration if we are emitting an IIFE
92482
+ var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92483
+ ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92484
+ : ts.elideNodes(factory, node.modifiers); // preserve positions, if available
92485
+ // ${modifiers} class ${name} ${heritageClauses} {
92486
+ // ${members}
92487
+ // }
92488
+ var classStatement = factory.updateClassDeclaration(node, decorators, modifiers, name,
92489
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92490
+ // To better align with the old emitter, we should not emit a trailing source map
92491
+ // entry if the class has static properties.
92492
+ var emitFlags = ts.getEmitFlags(node);
92493
+ if (facts & 1 /* HasStaticInitializedProperties */) {
92494
+ emitFlags |= 32 /* NoTrailingSourceMap */;
92495
+ }
92496
+ ts.setEmitFlags(classStatement, emitFlags);
92336
92497
  var statements = [classStatement];
92337
- // Write any decorators of the node.
92338
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
92339
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
92340
- addConstructorDecorationStatement(statements, node);
92341
92498
  if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
92342
92499
  // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
92343
92500
  // 'es2015' transformer can properly nest static initializers and decorators. The result
@@ -92397,164 +92554,14 @@ var ts;
92397
92554
  }
92398
92555
  return ts.singleOrMany(statements);
92399
92556
  }
92400
- /**
92401
- * Transforms a non-decorated class declaration and appends the resulting statements.
92402
- *
92403
- * @param node A ClassDeclaration node.
92404
- * @param name The name of the class.
92405
- * @param facts Precomputed facts about the class.
92406
- */
92407
- function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
92408
- // ${modifiers} class ${name} ${heritageClauses} {
92409
- // ${members}
92410
- // }
92411
- // we do not emit modifiers on the declaration if we are emitting an IIFE
92412
- var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92413
- ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92414
- : undefined;
92415
- var classDeclaration = factory.createClassDeclaration(
92416
- /*decorators*/ undefined, modifiers, name,
92417
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92418
- // To better align with the old emitter, we should not emit a trailing source map
92419
- // entry if the class has static properties.
92420
- var emitFlags = ts.getEmitFlags(node);
92421
- if (facts & 1 /* HasStaticInitializedProperties */) {
92422
- emitFlags |= 32 /* NoTrailingSourceMap */;
92423
- }
92424
- ts.setTextRange(classDeclaration, node);
92425
- ts.setOriginalNode(classDeclaration, node);
92426
- ts.setEmitFlags(classDeclaration, emitFlags);
92427
- return classDeclaration;
92428
- }
92429
- /**
92430
- * Transforms a decorated class declaration and appends the resulting statements. If
92431
- * the class requires an alias to avoid issues with double-binding, the alias is returned.
92432
- */
92433
- function createClassDeclarationHeadWithDecorators(node, name) {
92434
- // When we emit an ES6 class that has a class decorator, we must tailor the
92435
- // emit to certain specific cases.
92436
- //
92437
- // In the simplest case, we emit the class declaration as a let declaration, and
92438
- // evaluate decorators after the close of the class body:
92439
- //
92440
- // [Example 1]
92441
- // ---------------------------------------------------------------------
92442
- // TypeScript | Javascript
92443
- // ---------------------------------------------------------------------
92444
- // @dec | let C = class C {
92445
- // class C { | }
92446
- // } | C = __decorate([dec], C);
92447
- // ---------------------------------------------------------------------
92448
- // @dec | let C = class C {
92449
- // export class C { | }
92450
- // } | C = __decorate([dec], C);
92451
- // | export { C };
92452
- // ---------------------------------------------------------------------
92453
- //
92454
- // If a class declaration contains a reference to itself *inside* of the class body,
92455
- // this introduces two bindings to the class: One outside of the class body, and one
92456
- // inside of the class body. If we apply decorators as in [Example 1] above, there
92457
- // is the possibility that the decorator `dec` will return a new value for the
92458
- // constructor, which would result in the binding inside of the class no longer
92459
- // pointing to the same reference as the binding outside of the class.
92460
- //
92461
- // As a result, we must instead rewrite all references to the class *inside* of the
92462
- // class body to instead point to a local temporary alias for the class:
92463
- //
92464
- // [Example 2]
92465
- // ---------------------------------------------------------------------
92466
- // TypeScript | Javascript
92467
- // ---------------------------------------------------------------------
92468
- // @dec | let C = C_1 = class C {
92469
- // class C { | static x() { return C_1.y; }
92470
- // static x() { return C.y; } | }
92471
- // static y = 1; | C.y = 1;
92472
- // } | C = C_1 = __decorate([dec], C);
92473
- // | var C_1;
92474
- // ---------------------------------------------------------------------
92475
- // @dec | let C = class C {
92476
- // export class C { | static x() { return C_1.y; }
92477
- // static x() { return C.y; } | }
92478
- // static y = 1; | C.y = 1;
92479
- // } | C = C_1 = __decorate([dec], C);
92480
- // | export { C };
92481
- // | var C_1;
92482
- // ---------------------------------------------------------------------
92483
- //
92484
- // If a class declaration is the default export of a module, we instead emit
92485
- // the export after the decorated declaration:
92486
- //
92487
- // [Example 3]
92488
- // ---------------------------------------------------------------------
92489
- // TypeScript | Javascript
92490
- // ---------------------------------------------------------------------
92491
- // @dec | let default_1 = class {
92492
- // export default class { | }
92493
- // } | default_1 = __decorate([dec], default_1);
92494
- // | export default default_1;
92495
- // ---------------------------------------------------------------------
92496
- // @dec | let C = class C {
92497
- // export default class C { | }
92498
- // } | C = __decorate([dec], C);
92499
- // | export default C;
92500
- // ---------------------------------------------------------------------
92501
- //
92502
- // If the class declaration is the default export and a reference to itself
92503
- // inside of the class body, we must emit both an alias for the class *and*
92504
- // move the export after the declaration:
92505
- //
92506
- // [Example 4]
92507
- // ---------------------------------------------------------------------
92508
- // TypeScript | Javascript
92509
- // ---------------------------------------------------------------------
92510
- // @dec | let C = class C {
92511
- // export default class C { | static x() { return C_1.y; }
92512
- // static x() { return C.y; } | }
92513
- // static y = 1; | C.y = 1;
92514
- // } | C = C_1 = __decorate([dec], C);
92515
- // | export default C;
92516
- // | var C_1;
92517
- // ---------------------------------------------------------------------
92518
- //
92519
- var location = ts.moveRangePastDecorators(node);
92520
- var classAlias = getClassAliasIfNeeded(node);
92521
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92522
- // without any block-scoped variable collision handling
92523
- var declName = languageVersion <= 2 /* ES2015 */ ?
92524
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92525
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92526
- // ... = class ${name} ${heritageClauses} {
92527
- // ${members}
92528
- // }
92529
- var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
92530
- var members = transformClassMembers(node);
92531
- var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
92532
- ts.setOriginalNode(classExpression, node);
92533
- ts.setTextRange(classExpression, location);
92534
- // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
92535
- // or decoratedClassAlias if the class contain self-reference.
92536
- var statement = factory.createVariableStatement(
92537
- /*modifiers*/ undefined, factory.createVariableDeclarationList([
92538
- factory.createVariableDeclaration(declName,
92539
- /*exclamationToken*/ undefined,
92540
- /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
92541
- ], 1 /* Let */));
92542
- ts.setOriginalNode(statement, node);
92543
- ts.setTextRange(statement, location);
92544
- ts.setCommentRange(statement, node);
92545
- return statement;
92546
- }
92547
92557
  function visitClassExpression(node) {
92548
- if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
92549
- return ts.visitEachChild(node, visitor, context);
92550
- }
92551
- var classExpression = factory.createClassExpression(
92552
- /*decorators*/ undefined,
92558
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92559
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92560
+ return factory.updateClassExpression(node, decorators,
92553
92561
  /*modifiers*/ undefined, node.name,
92554
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92555
- ts.setOriginalNode(classExpression, node);
92556
- ts.setTextRange(classExpression, node);
92557
- return classExpression;
92562
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), isClassLikeDeclarationWithTypeScriptSyntax(node) ?
92563
+ transformClassMembers(node) :
92564
+ ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92558
92565
  }
92559
92566
  /**
92560
92567
  * Transforms the members of a class.
@@ -92579,48 +92586,9 @@ var ts;
92579
92586
  }
92580
92587
  }
92581
92588
  }
92582
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
92589
+ ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92583
92590
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
92584
92591
  }
92585
- /**
92586
- * Gets either the static or instance members of a class that are decorated, or have
92587
- * parameters that are decorated.
92588
- *
92589
- * @param node The class containing the member.
92590
- * @param isStatic A value indicating whether to retrieve static or instance members of
92591
- * the class.
92592
- */
92593
- function getDecoratedClassElements(node, isStatic) {
92594
- return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
92595
- }
92596
- /**
92597
- * Determines whether a class member is a static member of a class that is decorated, or
92598
- * has parameters that are decorated.
92599
- *
92600
- * @param member The class member.
92601
- */
92602
- function isStaticDecoratedClassElement(member, parent) {
92603
- return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
92604
- }
92605
- /**
92606
- * Determines whether a class member is an instance member of a class that is decorated,
92607
- * or has parameters that are decorated.
92608
- *
92609
- * @param member The class member.
92610
- */
92611
- function isInstanceDecoratedClassElement(member, parent) {
92612
- return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
92613
- }
92614
- /**
92615
- * Determines whether a class member is either a static or an instance member of a class
92616
- * that is decorated, or has parameters that are decorated.
92617
- *
92618
- * @param member The class member.
92619
- */
92620
- function isDecoratedClassElement(member, isStaticElement, parent) {
92621
- return ts.nodeOrChildIsDecorated(member, parent)
92622
- && isStaticElement === ts.isStatic(member);
92623
- }
92624
92592
  /**
92625
92593
  * Gets an array of arrays of decorators for the parameters of a function-like node.
92626
92594
  * The offset into the result array should correspond to the offset of the parameter.
@@ -92666,14 +92634,14 @@ var ts;
92666
92634
  /**
92667
92635
  * Gets an AllDecorators object containing the decorators for the member and its parameters.
92668
92636
  *
92669
- * @param node The class node that contains the member.
92637
+ * @param parent The class node that contains the member.
92670
92638
  * @param member The class member.
92671
92639
  */
92672
- function getAllDecoratorsOfClassElement(node, member) {
92640
+ function getAllDecoratorsOfClassElement(member, parent) {
92673
92641
  switch (member.kind) {
92674
92642
  case 172 /* GetAccessor */:
92675
92643
  case 173 /* SetAccessor */:
92676
- return getAllDecoratorsOfAccessors(node, member);
92644
+ return getAllDecoratorsOfAccessors(parent, member);
92677
92645
  case 169 /* MethodDeclaration */:
92678
92646
  return getAllDecoratorsOfMethod(member);
92679
92647
  case 167 /* PropertyDeclaration */:
@@ -92742,209 +92710,82 @@ var ts;
92742
92710
  if (!allDecorators) {
92743
92711
  return undefined;
92744
92712
  }
92745
- var decoratorExpressions = [];
92746
- ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
92747
- ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
92748
- addTypeMetadata(node, container, decoratorExpressions);
92749
- return decoratorExpressions;
92750
- }
92751
- /**
92752
- * Generates statements used to apply decorators to either the static or instance members
92753
- * of a class.
92754
- *
92755
- * @param node The class node.
92756
- * @param isStatic A value indicating whether to generate statements for static or
92757
- * instance members.
92758
- */
92759
- function addClassElementDecorationStatements(statements, node, isStatic) {
92760
- ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
92761
- }
92762
- /**
92763
- * Generates expressions used to apply decorators to either the static or instance members
92764
- * of a class.
92765
- *
92766
- * @param node The class node.
92767
- * @param isStatic A value indicating whether to generate expressions for static or
92768
- * instance members.
92769
- */
92770
- function generateClassElementDecorationExpressions(node, isStatic) {
92771
- var members = getDecoratedClassElements(node, isStatic);
92772
- var expressions;
92773
- for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
92774
- var member = members_8[_i];
92775
- var expression = generateClassElementDecorationExpression(node, member);
92776
- if (expression) {
92777
- if (!expressions) {
92778
- expressions = [expression];
92779
- }
92780
- else {
92781
- expressions.push(expression);
92782
- }
92783
- }
92784
- }
92785
- return expressions;
92786
- }
92787
- /**
92788
- * Generates an expression used to evaluate class element decorators at runtime.
92789
- *
92790
- * @param node The class node that contains the member.
92791
- * @param member The class member.
92792
- */
92793
- function generateClassElementDecorationExpression(node, member) {
92794
- var allDecorators = getAllDecoratorsOfClassElement(node, member);
92795
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
92796
- if (!decoratorExpressions) {
92797
- return undefined;
92798
- }
92799
- // Emit the call to __decorate. Given the following:
92800
- //
92801
- // class C {
92802
- // @dec method(@dec2 x) {}
92803
- // @dec get accessor() {}
92804
- // @dec prop;
92805
- // }
92806
- //
92807
- // The emit for a method is:
92808
- //
92809
- // __decorate([
92810
- // dec,
92811
- // __param(0, dec2),
92812
- // __metadata("design:type", Function),
92813
- // __metadata("design:paramtypes", [Object]),
92814
- // __metadata("design:returntype", void 0)
92815
- // ], C.prototype, "method", null);
92816
- //
92817
- // The emit for an accessor is:
92818
- //
92819
- // __decorate([
92820
- // dec
92821
- // ], C.prototype, "accessor", null);
92822
- //
92823
- // The emit for a property is:
92824
- //
92825
- // __decorate([
92826
- // dec
92827
- // ], C.prototype, "prop");
92828
- //
92829
- var prefix = getClassMemberPrefix(node, member);
92830
- var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
92831
- var descriptor = languageVersion > 0 /* ES3 */
92832
- ? member.kind === 167 /* PropertyDeclaration */
92833
- // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
92834
- // should not invoke `Object.getOwnPropertyDescriptor`.
92835
- ? factory.createVoidZero()
92836
- // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
92837
- // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
92838
- : factory.createNull()
92839
- : undefined;
92840
- var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
92841
- ts.setTextRange(helper, ts.moveRangePastDecorators(member));
92842
- ts.setEmitFlags(helper, 1536 /* NoComments */);
92843
- return helper;
92844
- }
92845
- /**
92846
- * Generates a __decorate helper call for a class constructor.
92847
- *
92848
- * @param node The class node.
92849
- */
92850
- function addConstructorDecorationStatement(statements, node) {
92851
- var expression = generateConstructorDecorationExpression(node);
92852
- if (expression) {
92853
- statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
92854
- }
92855
- }
92856
- /**
92857
- * Generates a __decorate helper call for a class constructor.
92858
- *
92859
- * @param node The class node.
92860
- */
92861
- function generateConstructorDecorationExpression(node) {
92862
- var allDecorators = getAllDecoratorsOfConstructor(node);
92863
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92864
- if (!decoratorExpressions) {
92865
- return undefined;
92866
- }
92867
- var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
92868
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92869
- // without any block-scoped variable collision handling
92870
- var localName = languageVersion <= 2 /* ES2015 */ ?
92871
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92872
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92873
- var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
92874
- var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
92875
- ts.setEmitFlags(expression, 1536 /* NoComments */);
92876
- ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
92877
- return expression;
92878
- }
92879
- /**
92880
- * Transforms a decorator into an expression.
92881
- *
92882
- * @param decorator The decorator node.
92883
- */
92884
- function transformDecorator(decorator) {
92885
- return ts.visitNode(decorator.expression, visitor, ts.isExpression);
92713
+ var decorators = ts.visitNodes(allDecorators.decorators, visitor, ts.isDecorator);
92714
+ var parameterDecorators = ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter);
92715
+ var metadataDecorators = ts.some(decorators) || ts.some(parameterDecorators) ? getTypeMetadata(node, container) : undefined;
92716
+ var result = factory.createNodeArray(ts.concatenate(ts.concatenate(decorators, parameterDecorators), metadataDecorators));
92717
+ ts.setTextRange(result, decorators);
92718
+ return result;
92886
92719
  }
92887
92720
  /**
92888
- * Transforms the decorators of a parameter.
92721
+ * Transforms the decorators of a parameter into decorators of the class/method.
92889
92722
  *
92890
- * @param decorators The decorators for the parameter at the provided offset.
92723
+ * @param parameterDecorators The decorators for the parameter at the provided offset.
92891
92724
  * @param parameterOffset The offset of the parameter.
92892
92725
  */
92893
- function transformDecoratorsOfParameter(decorators, parameterOffset) {
92894
- var expressions;
92895
- if (decorators) {
92896
- expressions = [];
92897
- for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
92898
- var decorator = decorators_1[_i];
92899
- var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
92900
- ts.setTextRange(helper, decorator.expression);
92726
+ function transformDecoratorsOfParameter(parameterDecorators, parameterOffset) {
92727
+ if (parameterDecorators) {
92728
+ var decorators = [];
92729
+ for (var _i = 0, parameterDecorators_1 = parameterDecorators; _i < parameterDecorators_1.length; _i++) {
92730
+ var parameterDecorator = parameterDecorators_1[_i];
92731
+ var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression);
92732
+ var helper = emitHelpers().createParamHelper(expression, parameterOffset);
92733
+ ts.setTextRange(helper, parameterDecorator.expression);
92901
92734
  ts.setEmitFlags(helper, 1536 /* NoComments */);
92902
- expressions.push(helper);
92735
+ var decorator = factory.createDecorator(helper);
92736
+ ts.setTextRange(decorator, parameterDecorator.expression);
92737
+ ts.setEmitFlags(decorator, 1536 /* NoComments */);
92738
+ decorators.push(decorator);
92903
92739
  }
92740
+ return decorators;
92904
92741
  }
92905
- return expressions;
92906
92742
  }
92907
92743
  /**
92908
- * Adds optional type metadata for a declaration.
92744
+ * Gets optional type metadata for a declaration.
92909
92745
  *
92910
92746
  * @param node The declaration node.
92911
- * @param decoratorExpressions The destination array to which to add new decorator expressions.
92912
92747
  */
92913
- function addTypeMetadata(node, container, decoratorExpressions) {
92914
- if (USE_NEW_TYPE_METADATA_FORMAT) {
92915
- addNewTypeMetadata(node, container, decoratorExpressions);
92916
- }
92917
- else {
92918
- addOldTypeMetadata(node, container, decoratorExpressions);
92919
- }
92748
+ function getTypeMetadata(node, container) {
92749
+ return USE_NEW_TYPE_METADATA_FORMAT ?
92750
+ getNewTypeMetadata(node, container) :
92751
+ getOldTypeMetadata(node, container);
92920
92752
  }
92921
- function addOldTypeMetadata(node, container, decoratorExpressions) {
92922
- if (compilerOptions.emitDecoratorMetadata) {
92753
+ function getOldTypeMetadata(node, container) {
92754
+ if (typeSerializer) {
92755
+ var decorators = void 0;
92923
92756
  if (shouldAddTypeMetadata(node)) {
92924
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
92757
+ var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92758
+ decorators = ts.append(decorators, factory.createDecorator(typeMetadata));
92925
92759
  }
92926
92760
  if (shouldAddParamTypesMetadata(node)) {
92927
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
92761
+ var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container));
92762
+ decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata));
92928
92763
  }
92929
92764
  if (shouldAddReturnTypeMetadata(node)) {
92930
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
92765
+ var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92766
+ decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata));
92931
92767
  }
92768
+ return decorators;
92932
92769
  }
92933
92770
  }
92934
- function addNewTypeMetadata(node, container, decoratorExpressions) {
92935
- if (compilerOptions.emitDecoratorMetadata) {
92771
+ function getNewTypeMetadata(node, container) {
92772
+ if (typeSerializer) {
92936
92773
  var properties = void 0;
92937
92774
  if (shouldAddTypeMetadata(node)) {
92938
- (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node))));
92775
+ var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92776
+ properties = ts.append(properties, typeProperty);
92939
92777
  }
92940
92778
  if (shouldAddParamTypesMetadata(node)) {
92941
- (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container))));
92779
+ 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)));
92780
+ properties = ts.append(properties, paramTypeProperty);
92942
92781
  }
92943
92782
  if (shouldAddReturnTypeMetadata(node)) {
92944
- (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node))));
92783
+ var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92784
+ properties = ts.append(properties, returnTypeProperty);
92945
92785
  }
92946
92786
  if (properties) {
92947
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true)));
92787
+ var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true));
92788
+ return [factory.createDecorator(typeInfoMetadata)];
92948
92789
  }
92949
92790
  }
92950
92791
  }
@@ -92991,347 +92832,6 @@ var ts;
92991
92832
  }
92992
92833
  return false;
92993
92834
  }
92994
- function getAccessorTypeNode(node) {
92995
- var accessors = resolver.getAllAccessorDeclarations(node);
92996
- return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
92997
- || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
92998
- }
92999
- /**
93000
- * Serializes the type of a node for use with decorator type metadata.
93001
- *
93002
- * @param node The node that should have its type serialized.
93003
- */
93004
- function serializeTypeOfNode(node) {
93005
- switch (node.kind) {
93006
- case 167 /* PropertyDeclaration */:
93007
- case 164 /* Parameter */:
93008
- return serializeTypeNode(node.type);
93009
- case 173 /* SetAccessor */:
93010
- case 172 /* GetAccessor */:
93011
- return serializeTypeNode(getAccessorTypeNode(node));
93012
- case 257 /* ClassDeclaration */:
93013
- case 226 /* ClassExpression */:
93014
- case 169 /* MethodDeclaration */:
93015
- return factory.createIdentifier("Function");
93016
- default:
93017
- return factory.createVoidZero();
93018
- }
93019
- }
93020
- /**
93021
- * Serializes the types of the parameters of a node for use with decorator type metadata.
93022
- *
93023
- * @param node The node that should have its parameter types serialized.
93024
- */
93025
- function serializeParameterTypesOfNode(node, container) {
93026
- var valueDeclaration = ts.isClassLike(node)
93027
- ? ts.getFirstConstructorWithBody(node)
93028
- : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
93029
- ? node
93030
- : undefined;
93031
- var expressions = [];
93032
- if (valueDeclaration) {
93033
- var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
93034
- var numParameters = parameters.length;
93035
- for (var i = 0; i < numParameters; i++) {
93036
- var parameter = parameters[i];
93037
- if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
93038
- continue;
93039
- }
93040
- if (parameter.dotDotDotToken) {
93041
- expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
93042
- }
93043
- else {
93044
- expressions.push(serializeTypeOfNode(parameter));
93045
- }
93046
- }
93047
- }
93048
- return factory.createArrayLiteralExpression(expressions);
93049
- }
93050
- function getParametersOfDecoratedDeclaration(node, container) {
93051
- if (container && node.kind === 172 /* GetAccessor */) {
93052
- var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
93053
- if (setAccessor) {
93054
- return setAccessor.parameters;
93055
- }
93056
- }
93057
- return node.parameters;
93058
- }
93059
- /**
93060
- * Serializes the return type of a node for use with decorator type metadata.
93061
- *
93062
- * @param node The node that should have its return type serialized.
93063
- */
93064
- function serializeReturnTypeOfNode(node) {
93065
- if (ts.isFunctionLike(node) && node.type) {
93066
- return serializeTypeNode(node.type);
93067
- }
93068
- else if (ts.isAsyncFunction(node)) {
93069
- return factory.createIdentifier("Promise");
93070
- }
93071
- return factory.createVoidZero();
93072
- }
93073
- /**
93074
- * Serializes a type node for use with decorator type metadata.
93075
- *
93076
- * Types are serialized in the following fashion:
93077
- * - Void types point to "undefined" (e.g. "void 0")
93078
- * - Function and Constructor types point to the global "Function" constructor.
93079
- * - Interface types with a call or construct signature types point to the global
93080
- * "Function" constructor.
93081
- * - Array and Tuple types point to the global "Array" constructor.
93082
- * - Type predicates and booleans point to the global "Boolean" constructor.
93083
- * - String literal types and strings point to the global "String" constructor.
93084
- * - Enum and number types point to the global "Number" constructor.
93085
- * - Symbol types point to the global "Symbol" constructor.
93086
- * - Type references to classes (or class-like variables) point to the constructor for the class.
93087
- * - Anything else points to the global "Object" constructor.
93088
- *
93089
- * @param node The type node to serialize.
93090
- */
93091
- function serializeTypeNode(node) {
93092
- if (node === undefined) {
93093
- return factory.createIdentifier("Object");
93094
- }
93095
- switch (node.kind) {
93096
- case 114 /* VoidKeyword */:
93097
- case 153 /* UndefinedKeyword */:
93098
- case 143 /* NeverKeyword */:
93099
- return factory.createVoidZero();
93100
- case 191 /* ParenthesizedType */:
93101
- return serializeTypeNode(node.type);
93102
- case 179 /* FunctionType */:
93103
- case 180 /* ConstructorType */:
93104
- return factory.createIdentifier("Function");
93105
- case 183 /* ArrayType */:
93106
- case 184 /* TupleType */:
93107
- return factory.createIdentifier("Array");
93108
- case 177 /* TypePredicate */:
93109
- case 133 /* BooleanKeyword */:
93110
- return factory.createIdentifier("Boolean");
93111
- case 198 /* TemplateLiteralType */:
93112
- case 150 /* StringKeyword */:
93113
- return factory.createIdentifier("String");
93114
- case 148 /* ObjectKeyword */:
93115
- return factory.createIdentifier("Object");
93116
- case 196 /* LiteralType */:
93117
- switch (node.literal.kind) {
93118
- case 10 /* StringLiteral */:
93119
- case 14 /* NoSubstitutionTemplateLiteral */:
93120
- return factory.createIdentifier("String");
93121
- case 219 /* PrefixUnaryExpression */:
93122
- case 8 /* NumericLiteral */:
93123
- return factory.createIdentifier("Number");
93124
- case 9 /* BigIntLiteral */:
93125
- return getGlobalBigIntNameWithFallback();
93126
- case 110 /* TrueKeyword */:
93127
- case 95 /* FalseKeyword */:
93128
- return factory.createIdentifier("Boolean");
93129
- case 104 /* NullKeyword */:
93130
- return factory.createVoidZero();
93131
- default:
93132
- return ts.Debug.failBadSyntaxKind(node.literal);
93133
- }
93134
- case 147 /* NumberKeyword */:
93135
- return factory.createIdentifier("Number");
93136
- case 158 /* BigIntKeyword */:
93137
- return getGlobalBigIntNameWithFallback();
93138
- case 151 /* SymbolKeyword */:
93139
- return languageVersion < 2 /* ES2015 */
93140
- ? getGlobalSymbolNameWithFallback()
93141
- : factory.createIdentifier("Symbol");
93142
- case 178 /* TypeReference */:
93143
- return serializeTypeReferenceNode(node);
93144
- case 188 /* IntersectionType */:
93145
- case 187 /* UnionType */:
93146
- return serializeTypeList(node.types);
93147
- case 189 /* ConditionalType */:
93148
- return serializeTypeList([node.trueType, node.falseType]);
93149
- case 193 /* TypeOperator */:
93150
- if (node.operator === 145 /* ReadonlyKeyword */) {
93151
- return serializeTypeNode(node.type);
93152
- }
93153
- break;
93154
- case 181 /* TypeQuery */:
93155
- case 194 /* IndexedAccessType */:
93156
- case 195 /* MappedType */:
93157
- case 182 /* TypeLiteral */:
93158
- case 130 /* AnyKeyword */:
93159
- case 155 /* UnknownKeyword */:
93160
- case 192 /* ThisType */:
93161
- case 200 /* ImportType */:
93162
- break;
93163
- // handle JSDoc types from an invalid parse
93164
- case 312 /* JSDocAllType */:
93165
- case 313 /* JSDocUnknownType */:
93166
- case 317 /* JSDocFunctionType */:
93167
- case 318 /* JSDocVariadicType */:
93168
- case 319 /* JSDocNamepathType */:
93169
- break;
93170
- case 314 /* JSDocNullableType */:
93171
- case 315 /* JSDocNonNullableType */:
93172
- case 316 /* JSDocOptionalType */:
93173
- return serializeTypeNode(node.type);
93174
- default:
93175
- return ts.Debug.failBadSyntaxKind(node);
93176
- }
93177
- return factory.createIdentifier("Object");
93178
- }
93179
- function serializeTypeList(types) {
93180
- // Note when updating logic here also update getEntityNameForDecoratorMetadata
93181
- // so that aliases can be marked as referenced
93182
- var serializedUnion;
93183
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
93184
- var typeNode = types_22[_i];
93185
- while (typeNode.kind === 191 /* ParenthesizedType */) {
93186
- typeNode = typeNode.type; // Skip parens if need be
93187
- }
93188
- if (typeNode.kind === 143 /* NeverKeyword */) {
93189
- continue; // Always elide `never` from the union/intersection if possible
93190
- }
93191
- if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) {
93192
- continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
93193
- }
93194
- var serializedIndividual = serializeTypeNode(typeNode);
93195
- if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
93196
- // One of the individual is global object, return immediately
93197
- return serializedIndividual;
93198
- }
93199
- // If there exists union that is not void 0 expression, check if the the common type is identifier.
93200
- // anything more complex and we will just default to Object
93201
- else if (serializedUnion) {
93202
- // Different types
93203
- if (!ts.isIdentifier(serializedUnion) ||
93204
- !ts.isIdentifier(serializedIndividual) ||
93205
- serializedUnion.escapedText !== serializedIndividual.escapedText) {
93206
- return factory.createIdentifier("Object");
93207
- }
93208
- }
93209
- else {
93210
- // Initialize the union type
93211
- serializedUnion = serializedIndividual;
93212
- }
93213
- }
93214
- // If we were able to find common type, use it
93215
- return serializedUnion || factory.createVoidZero(); // Fallback is only hit if all union constituients are null/undefined/never
93216
- }
93217
- /**
93218
- * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with
93219
- * decorator type metadata.
93220
- *
93221
- * @param node The type reference node.
93222
- */
93223
- function serializeTypeReferenceNode(node) {
93224
- var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
93225
- switch (kind) {
93226
- case ts.TypeReferenceSerializationKind.Unknown:
93227
- // From conditional type type reference that cannot be resolved is Similar to any or unknown
93228
- if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
93229
- return factory.createIdentifier("Object");
93230
- }
93231
- var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
93232
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93233
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"),
93234
- /*questionToken*/ undefined, temp,
93235
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93236
- case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
93237
- return serializeEntityNameAsExpression(node.typeName);
93238
- case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
93239
- return factory.createVoidZero();
93240
- case ts.TypeReferenceSerializationKind.BigIntLikeType:
93241
- return getGlobalBigIntNameWithFallback();
93242
- case ts.TypeReferenceSerializationKind.BooleanType:
93243
- return factory.createIdentifier("Boolean");
93244
- case ts.TypeReferenceSerializationKind.NumberLikeType:
93245
- return factory.createIdentifier("Number");
93246
- case ts.TypeReferenceSerializationKind.StringLikeType:
93247
- return factory.createIdentifier("String");
93248
- case ts.TypeReferenceSerializationKind.ArrayLikeType:
93249
- return factory.createIdentifier("Array");
93250
- case ts.TypeReferenceSerializationKind.ESSymbolType:
93251
- return languageVersion < 2 /* ES2015 */
93252
- ? getGlobalSymbolNameWithFallback()
93253
- : factory.createIdentifier("Symbol");
93254
- case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
93255
- return factory.createIdentifier("Function");
93256
- case ts.TypeReferenceSerializationKind.Promise:
93257
- return factory.createIdentifier("Promise");
93258
- case ts.TypeReferenceSerializationKind.ObjectType:
93259
- return factory.createIdentifier("Object");
93260
- default:
93261
- return ts.Debug.assertNever(kind);
93262
- }
93263
- }
93264
- function createCheckedValue(left, right) {
93265
- return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
93266
- }
93267
- /**
93268
- * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
93269
- *
93270
- * @param node The entity name to serialize.
93271
- */
93272
- function serializeEntityNameAsExpressionFallback(node) {
93273
- if (node.kind === 79 /* Identifier */) {
93274
- // A -> typeof A !== undefined && A
93275
- var copied = serializeEntityNameAsExpression(node);
93276
- return createCheckedValue(copied, copied);
93277
- }
93278
- if (node.left.kind === 79 /* Identifier */) {
93279
- // A.B -> typeof A !== undefined && A.B
93280
- return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
93281
- }
93282
- // A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C
93283
- var left = serializeEntityNameAsExpressionFallback(node.left);
93284
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93285
- return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
93286
- }
93287
- /**
93288
- * Serializes an entity name as an expression for decorator type metadata.
93289
- *
93290
- * @param node The entity name to serialize.
93291
- */
93292
- function serializeEntityNameAsExpression(node) {
93293
- switch (node.kind) {
93294
- case 79 /* Identifier */:
93295
- // Create a clone of the name with a new parent, and treat it as if it were
93296
- // a source tree node for the purposes of the checker.
93297
- var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
93298
- name.original = undefined;
93299
- ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
93300
- return name;
93301
- case 161 /* QualifiedName */:
93302
- return serializeQualifiedNameAsExpression(node);
93303
- }
93304
- }
93305
- /**
93306
- * Serializes an qualified name as an expression for decorator type metadata.
93307
- *
93308
- * @param node The qualified name to serialize.
93309
- * @param useFallback A value indicating whether to use logical operators to test for the
93310
- * qualified name at runtime.
93311
- */
93312
- function serializeQualifiedNameAsExpression(node) {
93313
- return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
93314
- }
93315
- /**
93316
- * Gets an expression that points to the global "Symbol" constructor at runtime if it is
93317
- * available.
93318
- */
93319
- function getGlobalSymbolNameWithFallback() {
93320
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"),
93321
- /*questionToken*/ undefined, factory.createIdentifier("Symbol"),
93322
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93323
- }
93324
- /**
93325
- * Gets an expression that points to the global "BigInt" constructor at runtime if it is
93326
- * available.
93327
- */
93328
- function getGlobalBigIntNameWithFallback() {
93329
- return languageVersion < 99 /* ESNext */
93330
- ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
93331
- /*questionToken*/ undefined, factory.createIdentifier("BigInt"),
93332
- /*colonToken*/ undefined, factory.createIdentifier("Object"))
93333
- : factory.createIdentifier("BigInt");
93334
- }
93335
92835
  /**
93336
92836
  * Gets an expression that represents a property name (for decorated properties or enums).
93337
92837
  * For a computed property, a name is generated for the node.
@@ -93416,21 +92916,23 @@ var ts;
93416
92916
  function shouldEmitFunctionLikeDeclaration(node) {
93417
92917
  return !ts.nodeIsMissing(node.body);
93418
92918
  }
93419
- function visitPropertyDeclaration(node) {
93420
- if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92919
+ function visitPropertyDeclaration(node, parent) {
92920
+ var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */);
92921
+ if (isAmbient && !ts.some(node.decorators)) {
93421
92922
  return undefined;
93422
92923
  }
93423
- var updated = factory.updatePropertyDeclaration(node,
93424
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
92924
+ var allDecorators = getAllDecoratorsOfClassElement(node, parent);
92925
+ var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators);
92926
+ // Preserve a `declare x` property with decorators to be handled by the decorators transform
92927
+ if (isAmbient) {
92928
+ return factory.updatePropertyDeclaration(node, decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */), ts.visitNode(node.name, visitor, ts.isPropertyName),
92929
+ /*questionOrExclamationToken*/ undefined,
92930
+ /*type*/ undefined,
92931
+ /*initializer*/ undefined);
92932
+ }
92933
+ return factory.updatePropertyDeclaration(node, decorators, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
93425
92934
  /*questionOrExclamationToken*/ undefined,
93426
92935
  /*type*/ undefined, ts.visitNode(node.initializer, visitor));
93427
- if (updated !== node) {
93428
- // While we emit the source map for the node after skipping decorators and modifiers,
93429
- // we need to emit the comments for the original range.
93430
- ts.setCommentRange(updated, node);
93431
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93432
- }
93433
- return updated;
93434
92936
  }
93435
92937
  function visitConstructor(node) {
93436
92938
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93438,7 +92940,7 @@ var ts;
93438
92940
  }
93439
92941
  return factory.updateConstructorDeclaration(node,
93440
92942
  /*decorators*/ undefined,
93441
- /*modifiers*/ undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
92943
+ /*modifiers*/ ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
93442
92944
  }
93443
92945
  function transformConstructorBody(body, constructor) {
93444
92946
  var parametersWithPropertyAssignments = constructor &&
@@ -93502,22 +93004,19 @@ var ts;
93502
93004
  ts.setEmitFlags(localName, 1536 /* NoComments */);
93503
93005
  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))));
93504
93006
  }
93505
- function visitMethodDeclaration(node) {
93007
+ function visitMethodDeclaration(node, parent) {
93008
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
93009
+ return node;
93010
+ }
93506
93011
  if (!shouldEmitFunctionLikeDeclaration(node)) {
93507
93012
  return undefined;
93508
93013
  }
93509
- var updated = factory.updateMethodDeclaration(node,
93510
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
93014
+ var allDecorators = ts.isClassLike(parent) ? getAllDecoratorsOfClassElement(node, parent) : undefined;
93015
+ var decorators = ts.isClassLike(parent) ? transformAllDecoratorsOfDeclaration(node, parent, allDecorators) : undefined;
93016
+ return factory.updateMethodDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
93511
93017
  /*questionToken*/ undefined,
93512
93018
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
93513
93019
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context));
93514
- if (updated !== node) {
93515
- // While we emit the source map for the node after skipping decorators and modifiers,
93516
- // we need to emit the comments for the original range.
93517
- ts.setCommentRange(updated, node);
93518
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93519
- }
93520
- return updated;
93521
93020
  }
93522
93021
  /**
93523
93022
  * Determines whether to emit an accessor declaration. We should not emit the
@@ -93528,34 +93027,30 @@ var ts;
93528
93027
  function shouldEmitAccessorDeclaration(node) {
93529
93028
  return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
93530
93029
  }
93531
- function visitGetAccessor(node) {
93030
+ function visitGetAccessor(node, parent) {
93031
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
93032
+ return node;
93033
+ }
93532
93034
  if (!shouldEmitAccessorDeclaration(node)) {
93533
93035
  return undefined;
93534
93036
  }
93535
- var updated = factory.updateGetAccessorDeclaration(node,
93536
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
93037
+ var decorators = ts.isClassLike(parent) ?
93038
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
93039
+ undefined;
93040
+ return factory.updateGetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
93537
93041
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93538
- if (updated !== node) {
93539
- // While we emit the source map for the node after skipping decorators and modifiers,
93540
- // we need to emit the comments for the original range.
93541
- ts.setCommentRange(updated, node);
93542
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93543
- }
93544
- return updated;
93545
93042
  }
93546
- function visitSetAccessor(node) {
93043
+ function visitSetAccessor(node, parent) {
93044
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
93045
+ return node;
93046
+ }
93547
93047
  if (!shouldEmitAccessorDeclaration(node)) {
93548
93048
  return undefined;
93549
93049
  }
93550
- var updated = factory.updateSetAccessorDeclaration(node,
93551
- /*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([]));
93552
- if (updated !== node) {
93553
- // While we emit the source map for the node after skipping decorators and modifiers,
93554
- // we need to emit the comments for the original range.
93555
- ts.setCommentRange(updated, node);
93556
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93557
- }
93558
- return updated;
93050
+ var decorators = ts.isClassLike(parent) ?
93051
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
93052
+ undefined;
93053
+ 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([]));
93559
93054
  }
93560
93055
  function visitFunctionDeclaration(node) {
93561
93056
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93591,9 +93086,9 @@ var ts;
93591
93086
  if (ts.parameterIsThisKeyword(node)) {
93592
93087
  return undefined;
93593
93088
  }
93594
- var updated = factory.updateParameterDeclaration(node,
93595
- /*decorators*/ undefined,
93596
- /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
93089
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
93090
+ ts.elideNodes(factory, node.modifiers), // preserve positions, if available
93091
+ node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
93597
93092
  /*questionToken*/ undefined,
93598
93093
  /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
93599
93094
  if (updated !== node) {
@@ -94289,12 +93784,6 @@ var ts;
94289
93784
  return isExternalModuleExport(node)
94290
93785
  && ts.hasSyntacticModifier(node, 512 /* Default */);
94291
93786
  }
94292
- /**
94293
- * Creates a statement for the provided expression. This is used in calls to `map`.
94294
- */
94295
- function expressionToStatement(expression) {
94296
- return factory.createExpressionStatement(expression);
94297
- }
94298
93787
  function addExportMemberAssignment(statements, node) {
94299
93788
  var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node));
94300
93789
  ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
@@ -94326,44 +93815,12 @@ var ts;
94326
93815
  function getNamespaceContainerName(node) {
94327
93816
  return factory.getGeneratedNameForNode(node);
94328
93817
  }
94329
- /**
94330
- * Gets a local alias for a class declaration if it is a decorated class with an internal
94331
- * reference to the static side of the class. This is necessary to avoid issues with
94332
- * double-binding semantics for the class name.
94333
- */
94334
- function getClassAliasIfNeeded(node) {
94335
- if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
94336
- enableSubstitutionForClassAliases();
94337
- var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
94338
- classAliases[ts.getOriginalNodeId(node)] = classAlias;
94339
- hoistVariableDeclaration(classAlias);
94340
- return classAlias;
94341
- }
94342
- }
94343
- function getClassPrototype(node) {
94344
- return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
94345
- }
94346
- function getClassMemberPrefix(node, member) {
94347
- return ts.isStatic(member)
94348
- ? factory.getDeclarationName(node)
94349
- : getClassPrototype(node);
94350
- }
94351
93818
  function enableSubstitutionForNonQualifiedEnumMembers() {
94352
93819
  if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
94353
93820
  enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
94354
93821
  context.enableSubstitution(79 /* Identifier */);
94355
93822
  }
94356
93823
  }
94357
- function enableSubstitutionForClassAliases() {
94358
- if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
94359
- enabledSubstitutions |= 1 /* ClassAliases */;
94360
- // We need to enable substitutions for identifiers. This allows us to
94361
- // substitute class names inside of a class declaration.
94362
- context.enableSubstitution(79 /* Identifier */);
94363
- // Keep track of class aliases.
94364
- classAliases = [];
94365
- }
94366
- }
94367
93824
  function enableSubstitutionForNamespaceExports() {
94368
93825
  if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
94369
93826
  enabledSubstitutions |= 2 /* NamespaceExports */;
@@ -94448,32 +93905,9 @@ var ts;
94448
93905
  return node;
94449
93906
  }
94450
93907
  function substituteExpressionIdentifier(node) {
94451
- return trySubstituteClassAlias(node)
94452
- || trySubstituteNamespaceExportedName(node)
93908
+ return trySubstituteNamespaceExportedName(node)
94453
93909
  || node;
94454
93910
  }
94455
- function trySubstituteClassAlias(node) {
94456
- if (enabledSubstitutions & 1 /* ClassAliases */) {
94457
- if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
94458
- // Due to the emit for class decorators, any reference to the class from inside of the class body
94459
- // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
94460
- // behavior of class names in ES6.
94461
- // Also, when emitting statics for class expressions, we must substitute a class alias for
94462
- // constructor references in static property initializers.
94463
- var declaration = resolver.getReferencedValueDeclaration(node);
94464
- if (declaration) {
94465
- var classAlias = classAliases[declaration.id]; // TODO: GH#18217
94466
- if (classAlias) {
94467
- var clone_2 = factory.cloneNode(classAlias);
94468
- ts.setSourceMapRange(clone_2, node);
94469
- ts.setCommentRange(clone_2, node);
94470
- return clone_2;
94471
- }
94472
- }
94473
- }
94474
- }
94475
- return undefined;
94476
- }
94477
93911
  function trySubstituteNamespaceExportedName(node) {
94478
93912
  // If this is explicitly a local name, do not substitute.
94479
93913
  if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
@@ -94611,7 +94045,7 @@ var ts;
94611
94045
  return visited;
94612
94046
  }
94613
94047
  function visitorWorker(node, valueIsDiscarded) {
94614
- if (node.transformFlags & 8388608 /* ContainsClassFields */) {
94048
+ if (node.transformFlags & 16777216 /* ContainsClassFields */) {
94615
94049
  switch (node.kind) {
94616
94050
  case 226 /* ClassExpression */:
94617
94051
  case 257 /* ClassDeclaration */:
@@ -94626,8 +94060,8 @@ var ts;
94626
94060
  return visitClassStaticBlockDeclaration(node);
94627
94061
  }
94628
94062
  }
94629
- if (node.transformFlags & 8388608 /* ContainsClassFields */ ||
94630
- node.transformFlags & 33554432 /* ContainsLexicalSuper */ &&
94063
+ if (node.transformFlags & 16777216 /* ContainsClassFields */ ||
94064
+ node.transformFlags & 134217728 /* ContainsLexicalSuper */ &&
94631
94065
  shouldTransformSuperInStaticInitializers &&
94632
94066
  currentStaticPropertyDeclarationOrStaticBlock &&
94633
94067
  currentClassLexicalEnvironment) {
@@ -95201,13 +94635,13 @@ var ts;
95201
94635
  facts |= 2 /* NeedsClassConstructorReference */;
95202
94636
  }
95203
94637
  if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
95204
- if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) {
94638
+ if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
95205
94639
  facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
95206
94640
  if (!(facts & 1 /* ClassWasDecorated */)) {
95207
94641
  facts |= 2 /* NeedsClassConstructorReference */;
95208
94642
  }
95209
94643
  }
95210
- if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) {
94644
+ if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) {
95211
94645
  if (!(facts & 1 /* ClassWasDecorated */)) {
95212
94646
  facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
95213
94647
  }
@@ -95792,10 +95226,10 @@ var ts;
95792
95226
  if (declaration) {
95793
95227
  var classAlias = classAliases[declaration.id]; // TODO: GH#18217
95794
95228
  if (classAlias) {
95795
- var clone_3 = factory.cloneNode(classAlias);
95796
- ts.setSourceMapRange(clone_3, node);
95797
- ts.setCommentRange(clone_3, node);
95798
- return clone_3;
95229
+ var clone_2 = factory.cloneNode(classAlias);
95230
+ ts.setSourceMapRange(clone_2, node);
95231
+ ts.setCommentRange(clone_2, node);
95232
+ return clone_2;
95799
95233
  }
95800
95234
  }
95801
95235
  }
@@ -96157,6 +95591,965 @@ var ts;
96157
95591
  })(ts || (ts = {}));
96158
95592
  /*@internal*/
96159
95593
  var ts;
95594
+ (function (ts) {
95595
+ function createRuntimeTypeSerializer(context) {
95596
+ var hoistVariableDeclaration = context.hoistVariableDeclaration;
95597
+ var resolver = context.getEmitResolver();
95598
+ var compilerOptions = context.getCompilerOptions();
95599
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95600
+ var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
95601
+ var currentLexicalScope;
95602
+ var currentNameScope;
95603
+ return {
95604
+ serializeTypeNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeNode, node); },
95605
+ serializeTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeOfNode, node); },
95606
+ serializeParameterTypesOfNode: function (serializerContext, node, container) { return setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container); },
95607
+ serializeReturnTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node); },
95608
+ };
95609
+ function setSerializerContextAnd(serializerContext, cb, node, arg) {
95610
+ var savedCurrentLexicalScope = currentLexicalScope;
95611
+ var savedCurrentNameScope = currentNameScope;
95612
+ currentLexicalScope = serializerContext.currentLexicalScope;
95613
+ currentNameScope = serializerContext.currentNameScope;
95614
+ var result = arg === undefined ? cb(node) : cb(node, arg);
95615
+ currentLexicalScope = savedCurrentLexicalScope;
95616
+ currentNameScope = savedCurrentNameScope;
95617
+ return result;
95618
+ }
95619
+ function getAccessorTypeNode(node) {
95620
+ var accessors = resolver.getAllAccessorDeclarations(node);
95621
+ return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
95622
+ || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
95623
+ }
95624
+ /**
95625
+ * Serializes the type of a node for use with decorator type metadata.
95626
+ * @param node The node that should have its type serialized.
95627
+ */
95628
+ function serializeTypeOfNode(node) {
95629
+ switch (node.kind) {
95630
+ case 167 /* PropertyDeclaration */:
95631
+ case 164 /* Parameter */:
95632
+ return serializeTypeNode(node.type);
95633
+ case 173 /* SetAccessor */:
95634
+ case 172 /* GetAccessor */:
95635
+ return serializeTypeNode(getAccessorTypeNode(node));
95636
+ case 257 /* ClassDeclaration */:
95637
+ case 226 /* ClassExpression */:
95638
+ case 169 /* MethodDeclaration */:
95639
+ return ts.factory.createIdentifier("Function");
95640
+ default:
95641
+ return ts.factory.createVoidZero();
95642
+ }
95643
+ }
95644
+ /**
95645
+ * Serializes the type of a node for use with decorator type metadata.
95646
+ * @param node The node that should have its type serialized.
95647
+ */
95648
+ function serializeParameterTypesOfNode(node, container) {
95649
+ var valueDeclaration = ts.isClassLike(node)
95650
+ ? ts.getFirstConstructorWithBody(node)
95651
+ : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
95652
+ ? node
95653
+ : undefined;
95654
+ var expressions = [];
95655
+ if (valueDeclaration) {
95656
+ var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
95657
+ var numParameters = parameters.length;
95658
+ for (var i = 0; i < numParameters; i++) {
95659
+ var parameter = parameters[i];
95660
+ if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
95661
+ continue;
95662
+ }
95663
+ if (parameter.dotDotDotToken) {
95664
+ expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
95665
+ }
95666
+ else {
95667
+ expressions.push(serializeTypeOfNode(parameter));
95668
+ }
95669
+ }
95670
+ }
95671
+ return ts.factory.createArrayLiteralExpression(expressions);
95672
+ }
95673
+ function getParametersOfDecoratedDeclaration(node, container) {
95674
+ if (container && node.kind === 172 /* GetAccessor */) {
95675
+ var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
95676
+ if (setAccessor) {
95677
+ return setAccessor.parameters;
95678
+ }
95679
+ }
95680
+ return node.parameters;
95681
+ }
95682
+ /**
95683
+ * Serializes the return type of a node for use with decorator type metadata.
95684
+ * @param node The node that should have its return type serialized.
95685
+ */
95686
+ function serializeReturnTypeOfNode(node) {
95687
+ if (ts.isFunctionLike(node) && node.type) {
95688
+ return serializeTypeNode(node.type);
95689
+ }
95690
+ else if (ts.isAsyncFunction(node)) {
95691
+ return ts.factory.createIdentifier("Promise");
95692
+ }
95693
+ return ts.factory.createVoidZero();
95694
+ }
95695
+ /**
95696
+ * Serializes a type node for use with decorator type metadata.
95697
+ *
95698
+ * Types are serialized in the following fashion:
95699
+ * - Void types point to "undefined" (e.g. "void 0")
95700
+ * - Function and Constructor types point to the global "Function" constructor.
95701
+ * - Interface types with a call or construct signature types point to the global
95702
+ * "Function" constructor.
95703
+ * - Array and Tuple types point to the global "Array" constructor.
95704
+ * - Type predicates and booleans point to the global "Boolean" constructor.
95705
+ * - String literal types and strings point to the global "String" constructor.
95706
+ * - Enum and number types point to the global "Number" constructor.
95707
+ * - Symbol types point to the global "Symbol" constructor.
95708
+ * - Type references to classes (or class-like variables) point to the constructor for the class.
95709
+ * - Anything else points to the global "Object" constructor.
95710
+ *
95711
+ * @param node The type node to serialize.
95712
+ */
95713
+ function serializeTypeNode(node) {
95714
+ if (node === undefined) {
95715
+ return ts.factory.createIdentifier("Object");
95716
+ }
95717
+ node = ts.skipTypeParentheses(node);
95718
+ switch (node.kind) {
95719
+ case 114 /* VoidKeyword */:
95720
+ case 153 /* UndefinedKeyword */:
95721
+ case 143 /* NeverKeyword */:
95722
+ return ts.factory.createVoidZero();
95723
+ case 179 /* FunctionType */:
95724
+ case 180 /* ConstructorType */:
95725
+ return ts.factory.createIdentifier("Function");
95726
+ case 183 /* ArrayType */:
95727
+ case 184 /* TupleType */:
95728
+ return ts.factory.createIdentifier("Array");
95729
+ case 177 /* TypePredicate */:
95730
+ return node.assertsModifier ?
95731
+ ts.factory.createVoidZero() :
95732
+ ts.factory.createIdentifier("Boolean");
95733
+ case 133 /* BooleanKeyword */:
95734
+ return ts.factory.createIdentifier("Boolean");
95735
+ case 198 /* TemplateLiteralType */:
95736
+ case 150 /* StringKeyword */:
95737
+ return ts.factory.createIdentifier("String");
95738
+ case 148 /* ObjectKeyword */:
95739
+ return ts.factory.createIdentifier("Object");
95740
+ case 196 /* LiteralType */:
95741
+ return serializeLiteralOfLiteralTypeNode(node.literal);
95742
+ case 147 /* NumberKeyword */:
95743
+ return ts.factory.createIdentifier("Number");
95744
+ case 158 /* BigIntKeyword */:
95745
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95746
+ case 151 /* SymbolKeyword */:
95747
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95748
+ case 178 /* TypeReference */:
95749
+ return serializeTypeReferenceNode(node);
95750
+ case 188 /* IntersectionType */:
95751
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true);
95752
+ case 187 /* UnionType */:
95753
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false);
95754
+ case 189 /* ConditionalType */:
95755
+ return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false);
95756
+ case 193 /* TypeOperator */:
95757
+ if (node.operator === 145 /* ReadonlyKeyword */) {
95758
+ return serializeTypeNode(node.type);
95759
+ }
95760
+ break;
95761
+ case 181 /* TypeQuery */:
95762
+ case 194 /* IndexedAccessType */:
95763
+ case 195 /* MappedType */:
95764
+ case 182 /* TypeLiteral */:
95765
+ case 130 /* AnyKeyword */:
95766
+ case 155 /* UnknownKeyword */:
95767
+ case 192 /* ThisType */:
95768
+ case 200 /* ImportType */:
95769
+ break;
95770
+ // handle JSDoc types from an invalid parse
95771
+ case 312 /* JSDocAllType */:
95772
+ case 313 /* JSDocUnknownType */:
95773
+ case 317 /* JSDocFunctionType */:
95774
+ case 318 /* JSDocVariadicType */:
95775
+ case 319 /* JSDocNamepathType */:
95776
+ break;
95777
+ case 314 /* JSDocNullableType */:
95778
+ case 315 /* JSDocNonNullableType */:
95779
+ case 316 /* JSDocOptionalType */:
95780
+ return serializeTypeNode(node.type);
95781
+ default:
95782
+ return ts.Debug.failBadSyntaxKind(node);
95783
+ }
95784
+ return ts.factory.createIdentifier("Object");
95785
+ }
95786
+ function serializeLiteralOfLiteralTypeNode(node) {
95787
+ switch (node.kind) {
95788
+ case 10 /* StringLiteral */:
95789
+ case 14 /* NoSubstitutionTemplateLiteral */:
95790
+ return ts.factory.createIdentifier("String");
95791
+ case 219 /* PrefixUnaryExpression */: {
95792
+ var operand = node.operand;
95793
+ switch (operand.kind) {
95794
+ case 8 /* NumericLiteral */:
95795
+ case 9 /* BigIntLiteral */:
95796
+ return serializeLiteralOfLiteralTypeNode(operand);
95797
+ default:
95798
+ return ts.Debug.failBadSyntaxKind(operand);
95799
+ }
95800
+ }
95801
+ case 8 /* NumericLiteral */:
95802
+ return ts.factory.createIdentifier("Number");
95803
+ case 9 /* BigIntLiteral */:
95804
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95805
+ case 110 /* TrueKeyword */:
95806
+ case 95 /* FalseKeyword */:
95807
+ return ts.factory.createIdentifier("Boolean");
95808
+ case 104 /* NullKeyword */:
95809
+ return ts.factory.createVoidZero();
95810
+ default:
95811
+ return ts.Debug.failBadSyntaxKind(node);
95812
+ }
95813
+ }
95814
+ function serializeUnionOrIntersectionConstituents(types, isIntersection) {
95815
+ // Note when updating logic here also update `getEntityNameForDecoratorMetadata` in checker.ts so that aliases can be marked as referenced
95816
+ var serializedType;
95817
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
95818
+ var typeNode = types_22[_i];
95819
+ typeNode = ts.skipTypeParentheses(typeNode);
95820
+ if (typeNode.kind === 143 /* NeverKeyword */) {
95821
+ if (isIntersection)
95822
+ return ts.factory.createVoidZero(); // Reduce to `never` in an intersection
95823
+ continue; // Elide `never` in a union
95824
+ }
95825
+ if (typeNode.kind === 155 /* UnknownKeyword */) {
95826
+ if (!isIntersection)
95827
+ return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union
95828
+ continue; // Elide `unknown` in an intersection
95829
+ }
95830
+ if (typeNode.kind === 130 /* AnyKeyword */) {
95831
+ return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection
95832
+ }
95833
+ if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) {
95834
+ continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
95835
+ }
95836
+ var serializedConstituent = serializeTypeNode(typeNode);
95837
+ if (ts.isIdentifier(serializedConstituent) && serializedConstituent.escapedText === "Object") {
95838
+ // One of the individual is global object, return immediately
95839
+ return serializedConstituent;
95840
+ }
95841
+ // If there exists union that is not `void 0` expression, check if the the common type is identifier.
95842
+ // anything more complex and we will just default to Object
95843
+ if (serializedType) {
95844
+ // Different types
95845
+ if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
95846
+ return ts.factory.createIdentifier("Object");
95847
+ }
95848
+ }
95849
+ else {
95850
+ // Initialize the union type
95851
+ serializedType = serializedConstituent;
95852
+ }
95853
+ }
95854
+ // If we were able to find common type, use it
95855
+ return serializedType !== null && serializedType !== void 0 ? serializedType : (ts.factory.createVoidZero()); // Fallback is only hit if all union constituents are null/undefined/never
95856
+ }
95857
+ function equateSerializedTypeNodes(left, right) {
95858
+ return (
95859
+ // temp vars used in fallback
95860
+ ts.isGeneratedIdentifier(left) ? ts.isGeneratedIdentifier(right) :
95861
+ // entity names
95862
+ ts.isIdentifier(left) ? ts.isIdentifier(right)
95863
+ && left.escapedText === right.escapedText :
95864
+ ts.isPropertyAccessExpression(left) ? ts.isPropertyAccessExpression(right)
95865
+ && equateSerializedTypeNodes(left.expression, right.expression)
95866
+ && equateSerializedTypeNodes(left.name, right.name) :
95867
+ // `void 0`
95868
+ ts.isVoidExpression(left) ? ts.isVoidExpression(right)
95869
+ && ts.isNumericLiteral(left.expression) && left.expression.text === "0"
95870
+ && ts.isNumericLiteral(right.expression) && right.expression.text === "0" :
95871
+ // `"undefined"` or `"function"` in `typeof` checks
95872
+ ts.isStringLiteral(left) ? ts.isStringLiteral(right)
95873
+ && left.text === right.text :
95874
+ // used in `typeof` checks for fallback
95875
+ ts.isTypeOfExpression(left) ? ts.isTypeOfExpression(right)
95876
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95877
+ // parens in `typeof` checks with temps
95878
+ ts.isParenthesizedExpression(left) ? ts.isParenthesizedExpression(right)
95879
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95880
+ // conditionals used in fallback
95881
+ ts.isConditionalExpression(left) ? ts.isConditionalExpression(right)
95882
+ && equateSerializedTypeNodes(left.condition, right.condition)
95883
+ && equateSerializedTypeNodes(left.whenTrue, right.whenTrue)
95884
+ && equateSerializedTypeNodes(left.whenFalse, right.whenFalse) :
95885
+ // logical binary and assignments used in fallback
95886
+ ts.isBinaryExpression(left) ? ts.isBinaryExpression(right)
95887
+ && left.operatorToken.kind === right.operatorToken.kind
95888
+ && equateSerializedTypeNodes(left.left, right.left)
95889
+ && equateSerializedTypeNodes(left.right, right.right) :
95890
+ false);
95891
+ }
95892
+ /**
95893
+ * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with decorator type metadata.
95894
+ * @param node The type reference node.
95895
+ */
95896
+ function serializeTypeReferenceNode(node) {
95897
+ var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope !== null && currentNameScope !== void 0 ? currentNameScope : currentLexicalScope);
95898
+ switch (kind) {
95899
+ case ts.TypeReferenceSerializationKind.Unknown:
95900
+ // From conditional type type reference that cannot be resolved is Similar to any or unknown
95901
+ if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
95902
+ return ts.factory.createIdentifier("Object");
95903
+ }
95904
+ var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
95905
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95906
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createAssignment(temp, serialized), "function"),
95907
+ /*questionToken*/ undefined, temp,
95908
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95909
+ case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
95910
+ return serializeEntityNameAsExpression(node.typeName);
95911
+ case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
95912
+ return ts.factory.createVoidZero();
95913
+ case ts.TypeReferenceSerializationKind.BigIntLikeType:
95914
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95915
+ case ts.TypeReferenceSerializationKind.BooleanType:
95916
+ return ts.factory.createIdentifier("Boolean");
95917
+ case ts.TypeReferenceSerializationKind.NumberLikeType:
95918
+ return ts.factory.createIdentifier("Number");
95919
+ case ts.TypeReferenceSerializationKind.StringLikeType:
95920
+ return ts.factory.createIdentifier("String");
95921
+ case ts.TypeReferenceSerializationKind.ArrayLikeType:
95922
+ return ts.factory.createIdentifier("Array");
95923
+ case ts.TypeReferenceSerializationKind.ESSymbolType:
95924
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95925
+ case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
95926
+ return ts.factory.createIdentifier("Function");
95927
+ case ts.TypeReferenceSerializationKind.Promise:
95928
+ return ts.factory.createIdentifier("Promise");
95929
+ case ts.TypeReferenceSerializationKind.ObjectType:
95930
+ return ts.factory.createIdentifier("Object");
95931
+ default:
95932
+ return ts.Debug.assertNever(kind);
95933
+ }
95934
+ }
95935
+ /**
95936
+ * Produces an expression that results in `right` if `left` is not undefined at runtime:
95937
+ *
95938
+ * ```
95939
+ * typeof left !== "undefined" && right
95940
+ * ```
95941
+ *
95942
+ * We use `typeof L !== "undefined"` (rather than `L !== undefined`) since `L` may not be declared.
95943
+ * It's acceptable for this expression to result in `false` at runtime, as the result is intended to be
95944
+ * further checked by any containing expression.
95945
+ */
95946
+ function createCheckedValue(left, right) {
95947
+ return ts.factory.createLogicalAnd(ts.factory.createStrictInequality(ts.factory.createTypeOfExpression(left), ts.factory.createStringLiteral("undefined")), right);
95948
+ }
95949
+ /**
95950
+ * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
95951
+ * @param node The entity name to serialize.
95952
+ */
95953
+ function serializeEntityNameAsExpressionFallback(node) {
95954
+ if (node.kind === 79 /* Identifier */) {
95955
+ // A -> typeof A !== "undefined" && A
95956
+ var copied = serializeEntityNameAsExpression(node);
95957
+ return createCheckedValue(copied, copied);
95958
+ }
95959
+ if (node.left.kind === 79 /* Identifier */) {
95960
+ // A.B -> typeof A !== "undefined" && A.B
95961
+ return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
95962
+ }
95963
+ // A.B.C -> typeof A !== "undefined" && (_a = A.B) !== void 0 && _a.C
95964
+ var left = serializeEntityNameAsExpressionFallback(node.left);
95965
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95966
+ 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));
95967
+ }
95968
+ /**
95969
+ * Serializes an entity name as an expression for decorator type metadata.
95970
+ * @param node The entity name to serialize.
95971
+ */
95972
+ function serializeEntityNameAsExpression(node) {
95973
+ switch (node.kind) {
95974
+ case 79 /* Identifier */:
95975
+ // Create a clone of the name with a new parent, and treat it as if it were
95976
+ // a source tree node for the purposes of the checker.
95977
+ var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
95978
+ name.original = undefined;
95979
+ ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
95980
+ return name;
95981
+ case 161 /* QualifiedName */:
95982
+ return serializeQualifiedNameAsExpression(node);
95983
+ }
95984
+ }
95985
+ /**
95986
+ * Serializes an qualified name as an expression for decorator type metadata.
95987
+ * @param node The qualified name to serialize.
95988
+ */
95989
+ function serializeQualifiedNameAsExpression(node) {
95990
+ return ts.factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
95991
+ }
95992
+ function getGlobalConstructorWithFallback(name) {
95993
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createIdentifier(name), "function"),
95994
+ /*questionToken*/ undefined, ts.factory.createIdentifier(name),
95995
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95996
+ }
95997
+ function getGlobalConstructor(name, minLanguageVersion) {
95998
+ return languageVersion < minLanguageVersion ?
95999
+ getGlobalConstructorWithFallback(name) :
96000
+ ts.factory.createIdentifier(name);
96001
+ }
96002
+ }
96003
+ ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer;
96004
+ })(ts || (ts = {}));
96005
+ /*@internal*/
96006
+ var ts;
96007
+ (function (ts) {
96008
+ function transformLegacyDecorators(context) {
96009
+ var factory = context.factory, emitHelpers = context.getEmitHelperFactory, hoistVariableDeclaration = context.hoistVariableDeclaration;
96010
+ var resolver = context.getEmitResolver();
96011
+ var compilerOptions = context.getCompilerOptions();
96012
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
96013
+ // Save the previous transformation hooks.
96014
+ var previousOnSubstituteNode = context.onSubstituteNode;
96015
+ // Set new transformation hooks.
96016
+ context.onSubstituteNode = onSubstituteNode;
96017
+ /**
96018
+ * A map that keeps track of aliases created for classes with decorators to avoid issues
96019
+ * with the double-binding behavior of classes.
96020
+ */
96021
+ var classAliases;
96022
+ return ts.chainBundle(context, transformSourceFile);
96023
+ function transformSourceFile(node) {
96024
+ var visited = ts.visitEachChild(node, visitor, context);
96025
+ ts.addEmitHelpers(visited, context.readEmitHelpers());
96026
+ return visited;
96027
+ }
96028
+ function visitor(node) {
96029
+ if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) {
96030
+ return node;
96031
+ }
96032
+ switch (node.kind) {
96033
+ case 165 /* Decorator */:
96034
+ // Decorators are elided. They will be emitted as part of `visitClassDeclaration`.
96035
+ return undefined;
96036
+ case 257 /* ClassDeclaration */:
96037
+ return visitClassDeclaration(node);
96038
+ case 226 /* ClassExpression */:
96039
+ return visitClassExpression(node);
96040
+ case 171 /* Constructor */:
96041
+ return visitConstructorDeclaration(node);
96042
+ case 169 /* MethodDeclaration */:
96043
+ return visitMethodDeclaration(node);
96044
+ case 173 /* SetAccessor */:
96045
+ return visitSetAccessorDeclaration(node);
96046
+ case 172 /* GetAccessor */:
96047
+ return visitGetAccessorDeclaration(node);
96048
+ case 170 /* ClassStaticBlockDeclaration */:
96049
+ return visitClassStaticBlockDeclaration(node);
96050
+ case 167 /* PropertyDeclaration */:
96051
+ return visitPropertyDeclaration(node);
96052
+ case 164 /* Parameter */:
96053
+ return visitParameterDeclaration(node);
96054
+ default:
96055
+ return ts.visitEachChild(node, visitor, context);
96056
+ }
96057
+ }
96058
+ function visitClassDeclaration(node) {
96059
+ if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
96060
+ return ts.visitEachChild(node, visitor, context);
96061
+ var classStatement = ts.some(node.decorators) ?
96062
+ createClassDeclarationHeadWithDecorators(node, node.name) :
96063
+ createClassDeclarationHeadWithoutDecorators(node, node.name);
96064
+ var statements = [classStatement];
96065
+ // Write any decorators of the node.
96066
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
96067
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
96068
+ addConstructorDecorationStatement(statements, node);
96069
+ if (statements.length > 1) {
96070
+ // Add a DeclarationMarker as a marker for the end of the declaration
96071
+ statements.push(factory.createEndOfDeclarationMarker(node));
96072
+ ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
96073
+ }
96074
+ return ts.singleOrMany(statements);
96075
+ }
96076
+ /**
96077
+ * Transforms a non-decorated class declaration.
96078
+ *
96079
+ * @param node A ClassDeclaration node.
96080
+ * @param name The name of the class.
96081
+ */
96082
+ function createClassDeclarationHeadWithoutDecorators(node, name) {
96083
+ // ${modifiers} class ${name} ${heritageClauses} {
96084
+ // ${members}
96085
+ // }
96086
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, name,
96087
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96088
+ }
96089
+ /**
96090
+ * Transforms a decorated class declaration and appends the resulting statements. If
96091
+ * the class requires an alias to avoid issues with double-binding, the alias is returned.
96092
+ */
96093
+ function createClassDeclarationHeadWithDecorators(node, name) {
96094
+ // When we emit an ES6 class that has a class decorator, we must tailor the
96095
+ // emit to certain specific cases.
96096
+ //
96097
+ // In the simplest case, we emit the class declaration as a let declaration, and
96098
+ // evaluate decorators after the close of the class body:
96099
+ //
96100
+ // [Example 1]
96101
+ // ---------------------------------------------------------------------
96102
+ // TypeScript | Javascript
96103
+ // ---------------------------------------------------------------------
96104
+ // @dec | let C = class C {
96105
+ // class C { | }
96106
+ // } | C = __decorate([dec], C);
96107
+ // ---------------------------------------------------------------------
96108
+ // @dec | let C = class C {
96109
+ // export class C { | }
96110
+ // } | C = __decorate([dec], C);
96111
+ // | export { C };
96112
+ // ---------------------------------------------------------------------
96113
+ //
96114
+ // If a class declaration contains a reference to itself *inside* of the class body,
96115
+ // this introduces two bindings to the class: One outside of the class body, and one
96116
+ // inside of the class body. If we apply decorators as in [Example 1] above, there
96117
+ // is the possibility that the decorator `dec` will return a new value for the
96118
+ // constructor, which would result in the binding inside of the class no longer
96119
+ // pointing to the same reference as the binding outside of the class.
96120
+ //
96121
+ // As a result, we must instead rewrite all references to the class *inside* of the
96122
+ // class body to instead point to a local temporary alias for the class:
96123
+ //
96124
+ // [Example 2]
96125
+ // ---------------------------------------------------------------------
96126
+ // TypeScript | Javascript
96127
+ // ---------------------------------------------------------------------
96128
+ // @dec | let C = C_1 = class C {
96129
+ // class C { | static x() { return C_1.y; }
96130
+ // static x() { return C.y; } | }
96131
+ // static y = 1; | C.y = 1;
96132
+ // } | C = C_1 = __decorate([dec], C);
96133
+ // | var C_1;
96134
+ // ---------------------------------------------------------------------
96135
+ // @dec | let C = class C {
96136
+ // export class C { | static x() { return C_1.y; }
96137
+ // static x() { return C.y; } | }
96138
+ // static y = 1; | C.y = 1;
96139
+ // } | C = C_1 = __decorate([dec], C);
96140
+ // | export { C };
96141
+ // | var C_1;
96142
+ // ---------------------------------------------------------------------
96143
+ //
96144
+ // If a class declaration is the default export of a module, we instead emit
96145
+ // the export after the decorated declaration:
96146
+ //
96147
+ // [Example 3]
96148
+ // ---------------------------------------------------------------------
96149
+ // TypeScript | Javascript
96150
+ // ---------------------------------------------------------------------
96151
+ // @dec | let default_1 = class {
96152
+ // export default class { | }
96153
+ // } | default_1 = __decorate([dec], default_1);
96154
+ // | export default default_1;
96155
+ // ---------------------------------------------------------------------
96156
+ // @dec | let C = class C {
96157
+ // export default class C { | }
96158
+ // } | C = __decorate([dec], C);
96159
+ // | export default C;
96160
+ // ---------------------------------------------------------------------
96161
+ //
96162
+ // If the class declaration is the default export and a reference to itself
96163
+ // inside of the class body, we must emit both an alias for the class *and*
96164
+ // move the export after the declaration:
96165
+ //
96166
+ // [Example 4]
96167
+ // ---------------------------------------------------------------------
96168
+ // TypeScript | Javascript
96169
+ // ---------------------------------------------------------------------
96170
+ // @dec | let C = class C {
96171
+ // export default class C { | static x() { return C_1.y; }
96172
+ // static x() { return C.y; } | }
96173
+ // static y = 1; | C.y = 1;
96174
+ // } | C = C_1 = __decorate([dec], C);
96175
+ // | export default C;
96176
+ // | var C_1;
96177
+ // ---------------------------------------------------------------------
96178
+ //
96179
+ var location = ts.moveRangePastModifiers(node);
96180
+ var classAlias = getClassAliasIfNeeded(node);
96181
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
96182
+ // without any block-scoped variable collision handling
96183
+ var declName = languageVersion <= 2 /* ES2015 */ ?
96184
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
96185
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
96186
+ // ... = class ${name} ${heritageClauses} {
96187
+ // ${members}
96188
+ // }
96189
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96190
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96191
+ var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
96192
+ ts.setOriginalNode(classExpression, node);
96193
+ ts.setTextRange(classExpression, location);
96194
+ // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
96195
+ // or decoratedClassAlias if the class contain self-reference.
96196
+ var statement = factory.createVariableStatement(
96197
+ /*modifiers*/ undefined, factory.createVariableDeclarationList([
96198
+ factory.createVariableDeclaration(declName,
96199
+ /*exclamationToken*/ undefined,
96200
+ /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
96201
+ ], 1 /* Let */));
96202
+ ts.setOriginalNode(statement, node);
96203
+ ts.setTextRange(statement, location);
96204
+ ts.setCommentRange(statement, node);
96205
+ return statement;
96206
+ }
96207
+ function visitClassExpression(node) {
96208
+ // Legacy decorators were not supported on class expressions
96209
+ return factory.updateClassExpression(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.name,
96210
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96211
+ }
96212
+ function visitConstructorDeclaration(node) {
96213
+ return factory.updateConstructorDeclaration(node,
96214
+ /*decorators*/ undefined, node.modifiers, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock));
96215
+ }
96216
+ function finishClassElement(updated, original) {
96217
+ if (updated !== original) {
96218
+ // While we emit the source map for the node after skipping decorators and modifiers,
96219
+ // we need to emit the comments for the original range.
96220
+ ts.setCommentRange(updated, original);
96221
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(original));
96222
+ }
96223
+ return updated;
96224
+ }
96225
+ function visitMethodDeclaration(node) {
96226
+ return finishClassElement(factory.updateMethodDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName),
96227
+ /*questionToken*/ undefined,
96228
+ /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
96229
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96230
+ }
96231
+ function visitGetAccessorDeclaration(node) {
96232
+ 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),
96233
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96234
+ }
96235
+ function visitSetAccessorDeclaration(node) {
96236
+ 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);
96237
+ }
96238
+ function visitClassStaticBlockDeclaration(node) {
96239
+ return factory.updateClassStaticBlockDeclaration(node,
96240
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.body, visitor, ts.isBlock));
96241
+ }
96242
+ function visitPropertyDeclaration(node) {
96243
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
96244
+ return undefined;
96245
+ }
96246
+ return finishClassElement(factory.updatePropertyDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName),
96247
+ /*questionOrExclamationToken*/ undefined,
96248
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
96249
+ }
96250
+ function visitParameterDeclaration(node) {
96251
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators),
96252
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
96253
+ /*questionToken*/ undefined,
96254
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
96255
+ if (updated !== node) {
96256
+ // While we emit the source map for the node after skipping decorators and modifiers,
96257
+ // we need to emit the comments for the original range.
96258
+ ts.setCommentRange(updated, node);
96259
+ ts.setTextRange(updated, ts.moveRangePastModifiers(node));
96260
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
96261
+ ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */);
96262
+ }
96263
+ return updated;
96264
+ }
96265
+ /**
96266
+ * Transforms all of the decorators for a declaration into an array of expressions.
96267
+ *
96268
+ * @param allDecorators An object containing all of the decorators for the declaration.
96269
+ */
96270
+ function transformAllDecoratorsOfDeclaration(allDecorators) {
96271
+ if (!allDecorators) {
96272
+ return undefined;
96273
+ }
96274
+ var decoratorExpressions = [];
96275
+ ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
96276
+ ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
96277
+ return decoratorExpressions;
96278
+ }
96279
+ /**
96280
+ * Generates statements used to apply decorators to either the static or instance members
96281
+ * of a class.
96282
+ *
96283
+ * @param node The class node.
96284
+ * @param isStatic A value indicating whether to generate statements for static or
96285
+ * instance members.
96286
+ */
96287
+ function addClassElementDecorationStatements(statements, node, isStatic) {
96288
+ ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), function (expr) { return factory.createExpressionStatement(expr); }));
96289
+ }
96290
+ /**
96291
+ * Determines whether a class member is either a static or an instance member of a class
96292
+ * that is decorated, or has parameters that are decorated.
96293
+ *
96294
+ * @param member The class member.
96295
+ */
96296
+ function isDecoratedClassElement(member, isStaticElement, parent) {
96297
+ return ts.nodeOrChildIsDecorated(member, parent)
96298
+ && isStaticElement === ts.isStatic(member);
96299
+ }
96300
+ /**
96301
+ * Gets either the static or instance members of a class that are decorated, or have
96302
+ * parameters that are decorated.
96303
+ *
96304
+ * @param node The class containing the member.
96305
+ * @param isStatic A value indicating whether to retrieve static or instance members of
96306
+ * the class.
96307
+ */
96308
+ function getDecoratedClassElements(node, isStatic) {
96309
+ return ts.filter(node.members, function (m) { return isDecoratedClassElement(m, isStatic, node); });
96310
+ }
96311
+ /**
96312
+ * Generates expressions used to apply decorators to either the static or instance members
96313
+ * of a class.
96314
+ *
96315
+ * @param node The class node.
96316
+ * @param isStatic A value indicating whether to generate expressions for static or
96317
+ * instance members.
96318
+ */
96319
+ function generateClassElementDecorationExpressions(node, isStatic) {
96320
+ var members = getDecoratedClassElements(node, isStatic);
96321
+ var expressions;
96322
+ for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
96323
+ var member = members_8[_i];
96324
+ expressions = ts.append(expressions, generateClassElementDecorationExpression(node, member));
96325
+ }
96326
+ return expressions;
96327
+ }
96328
+ /**
96329
+ * Generates an expression used to evaluate class element decorators at runtime.
96330
+ *
96331
+ * @param node The class node that contains the member.
96332
+ * @param member The class member.
96333
+ */
96334
+ function generateClassElementDecorationExpression(node, member) {
96335
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96336
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96337
+ if (!decoratorExpressions) {
96338
+ return undefined;
96339
+ }
96340
+ // Emit the call to __decorate. Given the following:
96341
+ //
96342
+ // class C {
96343
+ // @dec method(@dec2 x) {}
96344
+ // @dec get accessor() {}
96345
+ // @dec prop;
96346
+ // }
96347
+ //
96348
+ // The emit for a method is:
96349
+ //
96350
+ // __decorate([
96351
+ // dec,
96352
+ // __param(0, dec2),
96353
+ // __metadata("design:type", Function),
96354
+ // __metadata("design:paramtypes", [Object]),
96355
+ // __metadata("design:returntype", void 0)
96356
+ // ], C.prototype, "method", null);
96357
+ //
96358
+ // The emit for an accessor is:
96359
+ //
96360
+ // __decorate([
96361
+ // dec
96362
+ // ], C.prototype, "accessor", null);
96363
+ //
96364
+ // The emit for a property is:
96365
+ //
96366
+ // __decorate([
96367
+ // dec
96368
+ // ], C.prototype, "prop");
96369
+ //
96370
+ var prefix = getClassMemberPrefix(node, member);
96371
+ var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
96372
+ var descriptor = languageVersion > 0 /* ES3 */
96373
+ ? member.kind === 167 /* PropertyDeclaration */
96374
+ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
96375
+ // should not invoke `Object.getOwnPropertyDescriptor`.
96376
+ ? factory.createVoidZero()
96377
+ // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
96378
+ // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
96379
+ : factory.createNull()
96380
+ : undefined;
96381
+ var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
96382
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96383
+ ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member));
96384
+ return helper;
96385
+ }
96386
+ /**
96387
+ * Generates a __decorate helper call for a class constructor.
96388
+ *
96389
+ * @param node The class node.
96390
+ */
96391
+ function addConstructorDecorationStatement(statements, node) {
96392
+ var expression = generateConstructorDecorationExpression(node);
96393
+ if (expression) {
96394
+ statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
96395
+ }
96396
+ }
96397
+ /**
96398
+ * Generates a __decorate helper call for a class constructor.
96399
+ *
96400
+ * @param node The class node.
96401
+ */
96402
+ function generateConstructorDecorationExpression(node) {
96403
+ var allDecorators = ts.getAllDecoratorsOfClass(node);
96404
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96405
+ if (!decoratorExpressions) {
96406
+ return undefined;
96407
+ }
96408
+ var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
96409
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
96410
+ // without any block-scoped variable collision handling
96411
+ var localName = languageVersion <= 2 /* ES2015 */ ?
96412
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
96413
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
96414
+ var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
96415
+ var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
96416
+ ts.setEmitFlags(expression, 1536 /* NoComments */);
96417
+ ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node));
96418
+ return expression;
96419
+ }
96420
+ /**
96421
+ * Transforms a decorator into an expression.
96422
+ *
96423
+ * @param decorator The decorator node.
96424
+ */
96425
+ function transformDecorator(decorator) {
96426
+ return ts.visitNode(decorator.expression, visitor, ts.isExpression);
96427
+ }
96428
+ /**
96429
+ * Transforms the decorators of a parameter.
96430
+ *
96431
+ * @param decorators The decorators for the parameter at the provided offset.
96432
+ * @param parameterOffset The offset of the parameter.
96433
+ */
96434
+ function transformDecoratorsOfParameter(decorators, parameterOffset) {
96435
+ var expressions;
96436
+ if (decorators) {
96437
+ expressions = [];
96438
+ for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
96439
+ var decorator = decorators_1[_i];
96440
+ var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
96441
+ ts.setTextRange(helper, decorator.expression);
96442
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96443
+ expressions.push(helper);
96444
+ }
96445
+ }
96446
+ return expressions;
96447
+ }
96448
+ /**
96449
+ * Gets an expression that represents a property name (for decorated properties or enums).
96450
+ * For a computed property, a name is generated for the node.
96451
+ *
96452
+ * @param member The member whose name should be converted into an expression.
96453
+ */
96454
+ function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
96455
+ var name = member.name;
96456
+ if (ts.isPrivateIdentifier(name)) {
96457
+ return factory.createIdentifier("");
96458
+ }
96459
+ else if (ts.isComputedPropertyName(name)) {
96460
+ return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
96461
+ ? factory.getGeneratedNameForNode(name)
96462
+ : name.expression;
96463
+ }
96464
+ else if (ts.isIdentifier(name)) {
96465
+ return factory.createStringLiteral(ts.idText(name));
96466
+ }
96467
+ else {
96468
+ return factory.cloneNode(name);
96469
+ }
96470
+ }
96471
+ function enableSubstitutionForClassAliases() {
96472
+ if (!classAliases) {
96473
+ // We need to enable substitutions for identifiers. This allows us to
96474
+ // substitute class names inside of a class declaration.
96475
+ context.enableSubstitution(79 /* Identifier */);
96476
+ // Keep track of class aliases.
96477
+ classAliases = [];
96478
+ }
96479
+ }
96480
+ /**
96481
+ * Gets a local alias for a class declaration if it is a decorated class with an internal
96482
+ * reference to the static side of the class. This is necessary to avoid issues with
96483
+ * double-binding semantics for the class name.
96484
+ */
96485
+ function getClassAliasIfNeeded(node) {
96486
+ if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
96487
+ enableSubstitutionForClassAliases();
96488
+ var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
96489
+ classAliases[ts.getOriginalNodeId(node)] = classAlias;
96490
+ hoistVariableDeclaration(classAlias);
96491
+ return classAlias;
96492
+ }
96493
+ }
96494
+ function getClassPrototype(node) {
96495
+ return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
96496
+ }
96497
+ function getClassMemberPrefix(node, member) {
96498
+ return ts.isStatic(member)
96499
+ ? factory.getDeclarationName(node)
96500
+ : getClassPrototype(node);
96501
+ }
96502
+ /**
96503
+ * Hooks node substitutions.
96504
+ *
96505
+ * @param hint A hint as to the intended usage of the node.
96506
+ * @param node The node to substitute.
96507
+ */
96508
+ function onSubstituteNode(hint, node) {
96509
+ node = previousOnSubstituteNode(hint, node);
96510
+ if (hint === 1 /* Expression */) {
96511
+ return substituteExpression(node);
96512
+ }
96513
+ return node;
96514
+ }
96515
+ function substituteExpression(node) {
96516
+ switch (node.kind) {
96517
+ case 79 /* Identifier */:
96518
+ return substituteExpressionIdentifier(node);
96519
+ }
96520
+ return node;
96521
+ }
96522
+ function substituteExpressionIdentifier(node) {
96523
+ var _a;
96524
+ return (_a = trySubstituteClassAlias(node)) !== null && _a !== void 0 ? _a : node;
96525
+ }
96526
+ function trySubstituteClassAlias(node) {
96527
+ if (classAliases) {
96528
+ if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
96529
+ // Due to the emit for class decorators, any reference to the class from inside of the class body
96530
+ // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
96531
+ // behavior of class names in ES6.
96532
+ // Also, when emitting statics for class expressions, we must substitute a class alias for
96533
+ // constructor references in static property initializers.
96534
+ var declaration = resolver.getReferencedValueDeclaration(node);
96535
+ if (declaration) {
96536
+ var classAlias = classAliases[declaration.id]; // TODO: GH#18217
96537
+ if (classAlias) {
96538
+ var clone_3 = factory.cloneNode(classAlias);
96539
+ ts.setSourceMapRange(clone_3, node);
96540
+ ts.setCommentRange(clone_3, node);
96541
+ return clone_3;
96542
+ }
96543
+ }
96544
+ }
96545
+ }
96546
+ return undefined;
96547
+ }
96548
+ }
96549
+ ts.transformLegacyDecorators = transformLegacyDecorators;
96550
+ })(ts || (ts = {}));
96551
+ /*@internal*/
96552
+ var ts;
96160
96553
  (function (ts) {
96161
96554
  var ES2017SubstitutionFlags;
96162
96555
  (function (ES2017SubstitutionFlags) {
@@ -97005,7 +97398,7 @@ var ts;
97005
97398
  return objects;
97006
97399
  }
97007
97400
  function visitObjectLiteralExpression(node) {
97008
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97401
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97009
97402
  // spread elements emit like so:
97010
97403
  // non-spread elements are chunked together into object literals, and then all are passed to __assign:
97011
97404
  // { a, ...o, b } => __assign(__assign({a}, o), {b});
@@ -97078,7 +97471,7 @@ var ts;
97078
97471
  * expression of an `ExpressionStatement`).
97079
97472
  */
97080
97473
  function visitBinaryExpression(node, expressionResultIsUnused) {
97081
- if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97474
+ if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97082
97475
  return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
97083
97476
  }
97084
97477
  if (node.operatorToken.kind === 27 /* CommaToken */) {
@@ -97109,7 +97502,7 @@ var ts;
97109
97502
  function visitCatchClause(node) {
97110
97503
  if (node.variableDeclaration &&
97111
97504
  ts.isBindingPattern(node.variableDeclaration.name) &&
97112
- node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97505
+ node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97113
97506
  var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
97114
97507
  var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
97115
97508
  var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
@@ -97150,7 +97543,7 @@ var ts;
97150
97543
  }
97151
97544
  function visitVariableDeclarationWorker(node, exportedVariableStatement) {
97152
97545
  // If we are here it is because the name contains a binding pattern with a rest somewhere in it.
97153
- if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97546
+ if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97154
97547
  return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
97155
97548
  /*rval*/ undefined, exportedVariableStatement);
97156
97549
  }
@@ -97169,7 +97562,7 @@ var ts;
97169
97562
  */
97170
97563
  function visitForOfStatement(node, outermostLabeledStatement) {
97171
97564
  var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
97172
- if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97565
+ if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97173
97566
  node = transformForOfStatementWithObjectRest(node);
97174
97567
  }
97175
97568
  var result = node.awaitModifier ?
@@ -97282,7 +97675,7 @@ var ts;
97282
97675
  /*type*/ undefined,
97283
97676
  /*initializer*/ undefined);
97284
97677
  }
97285
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97678
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97286
97679
  // Binding patterns are converted into a generated name and are
97287
97680
  // evaluated inside the function body.
97288
97681
  return factory.updateParameterDeclaration(node,
@@ -97300,7 +97693,7 @@ var ts;
97300
97693
  if (parameters) {
97301
97694
  parameters.add(parameter);
97302
97695
  }
97303
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97696
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97304
97697
  parameters = new ts.Set();
97305
97698
  }
97306
97699
  }
@@ -97523,7 +97916,7 @@ var ts;
97523
97916
  statements = ts.append(statements, statement);
97524
97917
  }
97525
97918
  }
97526
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97919
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97527
97920
  containsPrecedingObjectRestOrSpread = true;
97528
97921
  var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
97529
97922
  /*doNotRecordTempVariablesInLine*/ false,
@@ -98895,7 +99288,7 @@ var ts;
98895
99288
  && !node.expression;
98896
99289
  }
98897
99290
  function isOrMayContainReturnCompletion(node) {
98898
- return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */
99291
+ return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */
98899
99292
  && (ts.isReturnStatement(node)
98900
99293
  || ts.isIfStatement(node)
98901
99294
  || ts.isWithStatement(node)
@@ -99459,7 +99852,7 @@ var ts;
99459
99852
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
99460
99853
  insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
99461
99854
  if (isDerivedClass || superCallExpression) {
99462
- if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
99855
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
99463
99856
  // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
99464
99857
  // following representation:
99465
99858
  //
@@ -100004,7 +100397,7 @@ var ts;
100004
100397
  * @param node An ArrowFunction node.
100005
100398
  */
100006
100399
  function visitArrowFunction(node) {
100007
- if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
100400
+ if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
100008
100401
  hierarchyFacts |= 65536 /* CapturedLexicalThis */;
100009
100402
  }
100010
100403
  var savedConvertedLoopState = convertedLoopState;
@@ -100290,7 +100683,7 @@ var ts;
100290
100683
  * @param node A VariableDeclarationList node.
100291
100684
  */
100292
100685
  function visitVariableDeclarationList(node) {
100293
- if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) {
100686
+ if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) {
100294
100687
  if (node.flags & 3 /* BlockScoped */) {
100295
100688
  enableSubstitutionsForBlockScopedBindings();
100296
100689
  }
@@ -100303,7 +100696,7 @@ var ts;
100303
100696
  ts.setCommentRange(declarationList, node);
100304
100697
  // If the first or last declaration is a binding pattern, we need to modify
100305
100698
  // the source map range for the declaration list.
100306
- if (node.transformFlags & 262144 /* ContainsBindingPattern */
100699
+ if (node.transformFlags & 524288 /* ContainsBindingPattern */
100307
100700
  && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
100308
100701
  ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
100309
100702
  }
@@ -100627,7 +101020,7 @@ var ts;
100627
101020
  var numInitialProperties = -1, hasComputed = false;
100628
101021
  for (var i = 0; i < properties.length; i++) {
100629
101022
  var property = properties[i];
100630
- if ((property.transformFlags & 524288 /* ContainsYield */ &&
101023
+ if ((property.transformFlags & 1048576 /* ContainsYield */ &&
100631
101024
  hierarchyFacts & 4 /* AsyncFunctionBody */)
100632
101025
  || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) {
100633
101026
  numInitialProperties = i;
@@ -100900,7 +101293,7 @@ var ts;
100900
101293
  */
100901
101294
  function createFunctionForInitializerOfForStatement(node, currentState) {
100902
101295
  var functionName = factory.createUniqueName("_loop_init");
100903
- var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0;
101296
+ var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0;
100904
101297
  var emitFlags = 0 /* None */;
100905
101298
  if (currentState.containsLexicalThis)
100906
101299
  emitFlags |= 8 /* CapturesThis */;
@@ -101015,7 +101408,7 @@ var ts;
101015
101408
  var loopBody = factory.createBlock(statements, /*multiLine*/ true);
101016
101409
  if (ts.isBlock(statement))
101017
101410
  ts.setOriginalNode(loopBody, statement);
101018
- var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0;
101411
+ var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0;
101019
101412
  var emitFlags = 524288 /* ReuseTempVariableScope */;
101020
101413
  if (currentState.containsLexicalThis)
101021
101414
  emitFlags |= 8 /* CapturesThis */;
@@ -101497,7 +101890,7 @@ var ts;
101497
101890
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
101498
101891
  // We are here either because SuperKeyword was used somewhere in the expression, or
101499
101892
  // because we contain a SpreadElementExpression.
101500
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */ ||
101893
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */ ||
101501
101894
  node.expression.kind === 106 /* SuperKeyword */ ||
101502
101895
  ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
101503
101896
  var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
@@ -101505,7 +101898,7 @@ var ts;
101505
101898
  ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
101506
101899
  }
101507
101900
  var resultingCall = void 0;
101508
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
101901
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
101509
101902
  // [source]
101510
101903
  // f(...a, b)
101511
101904
  // x.m(...a, b)
@@ -102347,10 +102740,10 @@ var ts;
102347
102740
  case 247 /* ReturnStatement */:
102348
102741
  return visitReturnStatement(node);
102349
102742
  default:
102350
- if (node.transformFlags & 524288 /* ContainsYield */) {
102743
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102351
102744
  return visitJavaScriptContainingYield(node);
102352
102745
  }
102353
- else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
102746
+ else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) {
102354
102747
  return ts.visitEachChild(node, visitor, context);
102355
102748
  }
102356
102749
  else {
@@ -102555,7 +102948,7 @@ var ts;
102555
102948
  * @param node The node to visit.
102556
102949
  */
102557
102950
  function visitVariableStatement(node) {
102558
- if (node.transformFlags & 524288 /* ContainsYield */) {
102951
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102559
102952
  transformAndEmitVariableDeclarationList(node.declarationList);
102560
102953
  return undefined;
102561
102954
  }
@@ -103613,7 +104006,7 @@ var ts;
103613
104006
  }
103614
104007
  }
103615
104008
  function containsYield(node) {
103616
- return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0;
104009
+ return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0;
103617
104010
  }
103618
104011
  function countInitialNodesWithoutYield(nodes) {
103619
104012
  var numNodes = nodes.length;
@@ -104662,7 +105055,7 @@ var ts;
104662
105055
  function transformSourceFile(node) {
104663
105056
  if (node.isDeclarationFile ||
104664
105057
  !(ts.isEffectiveExternalModule(node, compilerOptions) ||
104665
- node.transformFlags & 4194304 /* ContainsDynamicImport */ ||
105058
+ node.transformFlags & 8388608 /* ContainsDynamicImport */ ||
104666
105059
  (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
104667
105060
  return node;
104668
105061
  }
@@ -104999,7 +105392,7 @@ var ts;
104999
105392
  function visitorWorker(node, valueIsDiscarded) {
105000
105393
  // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
105001
105394
  // as export/import statements are only transformed at the top level of a file.
105002
- if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
105395
+ if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
105003
105396
  return node;
105004
105397
  }
105005
105398
  switch (node.kind) {
@@ -105150,7 +105543,7 @@ var ts;
105150
105543
  var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
105151
105544
  // 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.
105152
105545
  var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
105153
- var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */);
105546
+ var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
105154
105547
  switch (compilerOptions.module) {
105155
105548
  case ts.ModuleKind.AMD:
105156
105549
  return createImportCallExpressionAMD(argument, containsLexicalThis);
@@ -106137,7 +106530,7 @@ var ts;
106137
106530
  * @param node The SourceFile node.
106138
106531
  */
106139
106532
  function transformSourceFile(node) {
106140
- if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) {
106533
+ if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) {
106141
106534
  return node;
106142
106535
  }
106143
106536
  var id = ts.getOriginalNodeId(node);
@@ -106306,7 +106699,7 @@ var ts;
106306
106699
  // - Temporary variables will appear at the top rather than at the bottom of the file
106307
106700
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
106308
106701
  var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
106309
- var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ?
106702
+ var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ?
106310
106703
  factory.createModifiersFromModifierFlags(256 /* Async */) :
106311
106704
  undefined;
106312
106705
  var moduleObject = factory.createObjectLiteralExpression([
@@ -107215,7 +107608,7 @@ var ts;
107215
107608
  * @param node The node to visit.
107216
107609
  */
107217
107610
  function visitorWorker(node, valueIsDiscarded) {
107218
- if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
107611
+ if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
107219
107612
  return node;
107220
107613
  }
107221
107614
  switch (node.kind) {
@@ -109758,6 +110151,7 @@ var ts;
109758
110151
  var transformers = [];
109759
110152
  ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
109760
110153
  transformers.push(ts.transformTypeScript);
110154
+ transformers.push(ts.transformLegacyDecorators);
109761
110155
  transformers.push(ts.transformClassFields);
109762
110156
  if (ts.getJSXTransformEnabled(compilerOptions)) {
109763
110157
  transformers.push(ts.transformJsx);
@@ -126057,7 +126451,7 @@ var ts;
126057
126451
  * @param typeAcquisition is used to customize the typing acquisition process
126058
126452
  * @param compilerOptions are used as a source for typing inference
126059
126453
  */
126060
- function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
126454
+ function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
126061
126455
  if (!typeAcquisition || !typeAcquisition.enable) {
126062
126456
  return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
126063
126457
  }
@@ -126075,12 +126469,14 @@ var ts;
126075
126469
  addInferredTypings(typeAcquisition.include, "Explicitly included types");
126076
126470
  var exclude = typeAcquisition.exclude || [];
126077
126471
  // Directories to search for package.json, bower.json and other typing information
126078
- var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
126079
- possibleSearchDirs.add(projectRootPath);
126080
- possibleSearchDirs.forEach(function (searchDir) {
126081
- getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
126082
- getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
126083
- });
126472
+ if (!compilerOptions.types) {
126473
+ var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
126474
+ possibleSearchDirs.add(projectRootPath);
126475
+ possibleSearchDirs.forEach(function (searchDir) {
126476
+ getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
126477
+ getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
126478
+ });
126479
+ }
126084
126480
  if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
126085
126481
  getTypingNamesFromSourceFileNames(fileNames);
126086
126482
  }
@@ -168079,7 +168475,7 @@ var ts;
168079
168475
  if (_this.safeList === undefined) {
168080
168476
  _this.safeList = ts.JsTyping.loadSafeList(_this.host, ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
168081
168477
  }
168082
- 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);
168478
+ 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);
168083
168479
  });
168084
168480
  };
168085
168481
  return CoreServicesShimObject;