typescript 4.8.0-dev.20220603 → 4.8.0-dev.20220604
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +962 -625
- package/lib/tsserver.js +1413 -1017
- package/lib/tsserverlibrary.js +1413 -1017
- package/lib/typescript.js +1413 -1017
- package/lib/typescriptServices.js +1413 -1017
- package/lib/typingsInstaller.js +1413 -1017
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220604";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -5561,21 +5561,22 @@ var ts;
|
|
|
5561
5561
|
TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 4096] = "ContainsDestructuringAssignment";
|
|
5562
5562
|
// Markers
|
|
5563
5563
|
// - Flags used to indicate that a subtree contains a specific transformation.
|
|
5564
|
-
TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] =
|
|
5565
|
-
TransformFlags[TransformFlags["ContainsLexicalThis"] =
|
|
5566
|
-
TransformFlags[TransformFlags["ContainsRestOrSpread"] =
|
|
5567
|
-
TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] =
|
|
5568
|
-
TransformFlags[TransformFlags["ContainsComputedPropertyName"] =
|
|
5569
|
-
TransformFlags[TransformFlags["ContainsBlockScopedBinding"] =
|
|
5570
|
-
TransformFlags[TransformFlags["ContainsBindingPattern"] =
|
|
5571
|
-
TransformFlags[TransformFlags["ContainsYield"] =
|
|
5572
|
-
TransformFlags[TransformFlags["ContainsAwait"] =
|
|
5573
|
-
TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] =
|
|
5574
|
-
TransformFlags[TransformFlags["ContainsDynamicImport"] =
|
|
5575
|
-
TransformFlags[TransformFlags["ContainsClassFields"] =
|
|
5576
|
-
TransformFlags[TransformFlags["
|
|
5577
|
-
TransformFlags[TransformFlags["
|
|
5578
|
-
TransformFlags[TransformFlags["
|
|
5564
|
+
TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 8192] = "ContainsTypeScriptClassSyntax";
|
|
5565
|
+
TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis";
|
|
5566
|
+
TransformFlags[TransformFlags["ContainsRestOrSpread"] = 32768] = "ContainsRestOrSpread";
|
|
5567
|
+
TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 65536] = "ContainsObjectRestOrSpread";
|
|
5568
|
+
TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 131072] = "ContainsComputedPropertyName";
|
|
5569
|
+
TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 262144] = "ContainsBlockScopedBinding";
|
|
5570
|
+
TransformFlags[TransformFlags["ContainsBindingPattern"] = 524288] = "ContainsBindingPattern";
|
|
5571
|
+
TransformFlags[TransformFlags["ContainsYield"] = 1048576] = "ContainsYield";
|
|
5572
|
+
TransformFlags[TransformFlags["ContainsAwait"] = 2097152] = "ContainsAwait";
|
|
5573
|
+
TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 4194304] = "ContainsHoistedDeclarationOrCompletion";
|
|
5574
|
+
TransformFlags[TransformFlags["ContainsDynamicImport"] = 8388608] = "ContainsDynamicImport";
|
|
5575
|
+
TransformFlags[TransformFlags["ContainsClassFields"] = 16777216] = "ContainsClassFields";
|
|
5576
|
+
TransformFlags[TransformFlags["ContainsDecorators"] = 33554432] = "ContainsDecorators";
|
|
5577
|
+
TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
|
|
5578
|
+
TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
|
|
5579
|
+
TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
|
|
5579
5580
|
// Please leave this as 1 << 29.
|
|
5580
5581
|
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
|
|
5581
5582
|
// It is a good reminder of how much room we have left
|
|
@@ -5601,24 +5602,24 @@ var ts;
|
|
|
5601
5602
|
TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
|
|
5602
5603
|
TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
|
|
5603
5604
|
TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
|
|
5604
|
-
TransformFlags[TransformFlags["ArrowFunctionExcludes"] =
|
|
5605
|
-
TransformFlags[TransformFlags["FunctionExcludes"] =
|
|
5606
|
-
TransformFlags[TransformFlags["ConstructorExcludes"] =
|
|
5607
|
-
TransformFlags[TransformFlags["MethodOrAccessorExcludes"] =
|
|
5608
|
-
TransformFlags[TransformFlags["PropertyExcludes"] =
|
|
5609
|
-
TransformFlags[TransformFlags["ClassExcludes"] =
|
|
5610
|
-
TransformFlags[TransformFlags["ModuleExcludes"] =
|
|
5605
|
+
TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
|
|
5606
|
+
TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
|
|
5607
|
+
TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
|
|
5608
|
+
TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
|
|
5609
|
+
TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
|
|
5610
|
+
TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
|
|
5611
|
+
TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
|
|
5611
5612
|
TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
|
|
5612
|
-
TransformFlags[TransformFlags["ObjectLiteralExcludes"] =
|
|
5613
|
-
TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] =
|
|
5614
|
-
TransformFlags[TransformFlags["VariableDeclarationListExcludes"] =
|
|
5613
|
+
TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
|
|
5614
|
+
TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
|
|
5615
|
+
TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
|
|
5615
5616
|
TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
|
|
5616
|
-
TransformFlags[TransformFlags["CatchClauseExcludes"] =
|
|
5617
|
-
TransformFlags[TransformFlags["BindingPatternExcludes"] =
|
|
5618
|
-
TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] =
|
|
5617
|
+
TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
|
|
5618
|
+
TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
|
|
5619
|
+
TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
|
|
5619
5620
|
// Propagating flags
|
|
5620
5621
|
// - Bitmasks for flags that should propagate from a child
|
|
5621
|
-
TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] =
|
|
5622
|
+
TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 134234112] = "PropertyNamePropagatingFlags";
|
|
5622
5623
|
// Masks
|
|
5623
5624
|
// - Additional bitmasks
|
|
5624
5625
|
})(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
|
|
@@ -16990,6 +16991,12 @@ var ts;
|
|
|
16990
16991
|
return [child, node];
|
|
16991
16992
|
}
|
|
16992
16993
|
ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
|
|
16994
|
+
function skipTypeParentheses(node) {
|
|
16995
|
+
while (ts.isParenthesizedTypeNode(node))
|
|
16996
|
+
node = node.type;
|
|
16997
|
+
return node;
|
|
16998
|
+
}
|
|
16999
|
+
ts.skipTypeParentheses = skipTypeParentheses;
|
|
16993
17000
|
function skipParentheses(node, excludeJSDocTypeAssertions) {
|
|
16994
17001
|
var flags = excludeJSDocTypeAssertions ?
|
|
16995
17002
|
1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ :
|
|
@@ -19224,7 +19231,7 @@ var ts;
|
|
|
19224
19231
|
* Moves the start position of a range past any decorators.
|
|
19225
19232
|
*/
|
|
19226
19233
|
function moveRangePastDecorators(node) {
|
|
19227
|
-
return node.decorators && node.decorators.
|
|
19234
|
+
return node.decorators && !positionIsSynthesized(node.decorators.end)
|
|
19228
19235
|
? moveRangePos(node, node.decorators.end)
|
|
19229
19236
|
: node;
|
|
19230
19237
|
}
|
|
@@ -19233,7 +19240,7 @@ var ts;
|
|
|
19233
19240
|
* Moves the start position of a range past any decorators or modifiers.
|
|
19234
19241
|
*/
|
|
19235
19242
|
function moveRangePastModifiers(node) {
|
|
19236
|
-
return node.modifiers && node.modifiers.
|
|
19243
|
+
return node.modifiers && !positionIsSynthesized(node.modifiers.end)
|
|
19237
19244
|
? moveRangePos(node, node.modifiers.end)
|
|
19238
19245
|
: moveRangePastDecorators(node);
|
|
19239
19246
|
}
|
|
@@ -22663,7 +22670,7 @@ var ts;
|
|
|
22663
22670
|
function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
|
|
22664
22671
|
var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
|
|
22665
22672
|
node.body = body;
|
|
22666
|
-
node.transformFlags |= propagateChildFlags(node.body) & ~
|
|
22673
|
+
node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */;
|
|
22667
22674
|
if (!body)
|
|
22668
22675
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
22669
22676
|
return node;
|
|
@@ -22791,7 +22798,7 @@ var ts;
|
|
|
22791
22798
|
node.typeArguments = createNodeArray(typeArguments);
|
|
22792
22799
|
}
|
|
22793
22800
|
if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
|
|
22794
|
-
node.transformFlags |=
|
|
22801
|
+
node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */;
|
|
22795
22802
|
}
|
|
22796
22803
|
return node;
|
|
22797
22804
|
}
|
|
@@ -22843,7 +22850,7 @@ var ts;
|
|
|
22843
22850
|
ts.Debug.fail("First character of private identifier must be #: " + text);
|
|
22844
22851
|
var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */);
|
|
22845
22852
|
node.escapedText = ts.escapeLeadingUnderscores(text);
|
|
22846
|
-
node.transformFlags |=
|
|
22853
|
+
node.transformFlags |= 16777216 /* ContainsClassFields */;
|
|
22847
22854
|
return node;
|
|
22848
22855
|
}
|
|
22849
22856
|
//
|
|
@@ -22890,14 +22897,14 @@ var ts;
|
|
|
22890
22897
|
transformFlags = 1 /* ContainsTypeScript */;
|
|
22891
22898
|
break;
|
|
22892
22899
|
case 106 /* SuperKeyword */:
|
|
22893
|
-
transformFlags = 1024 /* ContainsES2015 */ |
|
|
22900
|
+
transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */;
|
|
22894
22901
|
break;
|
|
22895
22902
|
case 124 /* StaticKeyword */:
|
|
22896
22903
|
transformFlags = 1024 /* ContainsES2015 */;
|
|
22897
22904
|
break;
|
|
22898
22905
|
case 108 /* ThisKeyword */:
|
|
22899
22906
|
// 'this' indicates a lexical 'this'
|
|
22900
|
-
transformFlags =
|
|
22907
|
+
transformFlags = 16384 /* ContainsLexicalThis */;
|
|
22901
22908
|
break;
|
|
22902
22909
|
}
|
|
22903
22910
|
if (transformFlags) {
|
|
@@ -22995,7 +23002,7 @@ var ts;
|
|
|
22995
23002
|
node.transformFlags |=
|
|
22996
23003
|
propagateChildFlags(node.expression) |
|
|
22997
23004
|
1024 /* ContainsES2015 */ |
|
|
22998
|
-
|
|
23005
|
+
131072 /* ContainsComputedPropertyName */;
|
|
22999
23006
|
return node;
|
|
23000
23007
|
}
|
|
23001
23008
|
// @api
|
|
@@ -23061,7 +23068,7 @@ var ts;
|
|
|
23061
23068
|
if (questionToken)
|
|
23062
23069
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
23063
23070
|
if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
|
|
23064
|
-
node.transformFlags |=
|
|
23071
|
+
node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
|
|
23065
23072
|
if (initializer || dotDotDotToken)
|
|
23066
23073
|
node.transformFlags |= 1024 /* ContainsES2015 */;
|
|
23067
23074
|
}
|
|
@@ -23086,7 +23093,8 @@ var ts;
|
|
|
23086
23093
|
node.transformFlags |=
|
|
23087
23094
|
propagateChildFlags(node.expression) |
|
|
23088
23095
|
1 /* ContainsTypeScript */ |
|
|
23089
|
-
|
|
23096
|
+
8192 /* ContainsTypeScriptClassSyntax */ |
|
|
23097
|
+
33554432 /* ContainsDecorators */;
|
|
23090
23098
|
return node;
|
|
23091
23099
|
}
|
|
23092
23100
|
// @api
|
|
@@ -23124,9 +23132,9 @@ var ts;
|
|
|
23124
23132
|
node.transformFlags |=
|
|
23125
23133
|
propagateChildFlags(node.questionToken) |
|
|
23126
23134
|
propagateChildFlags(node.exclamationToken) |
|
|
23127
|
-
|
|
23135
|
+
16777216 /* ContainsClassFields */;
|
|
23128
23136
|
if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
|
|
23129
|
-
node.transformFlags |=
|
|
23137
|
+
node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
|
|
23130
23138
|
}
|
|
23131
23139
|
if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
|
|
23132
23140
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
@@ -23209,7 +23217,7 @@ var ts;
|
|
|
23209
23217
|
/*name*/ undefined,
|
|
23210
23218
|
/*typeParameters*/ undefined);
|
|
23211
23219
|
node.body = body;
|
|
23212
|
-
node.transformFlags = propagateChildFlags(body) |
|
|
23220
|
+
node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */;
|
|
23213
23221
|
return node;
|
|
23214
23222
|
}
|
|
23215
23223
|
// @api
|
|
@@ -23733,11 +23741,11 @@ var ts;
|
|
|
23733
23741
|
node.transformFlags |=
|
|
23734
23742
|
propagateChildrenFlags(node.elements) |
|
|
23735
23743
|
1024 /* ContainsES2015 */ |
|
|
23736
|
-
|
|
23737
|
-
if (node.transformFlags &
|
|
23744
|
+
524288 /* ContainsBindingPattern */;
|
|
23745
|
+
if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
|
|
23738
23746
|
node.transformFlags |=
|
|
23739
23747
|
128 /* ContainsES2018 */ |
|
|
23740
|
-
|
|
23748
|
+
65536 /* ContainsObjectRestOrSpread */;
|
|
23741
23749
|
}
|
|
23742
23750
|
return node;
|
|
23743
23751
|
}
|
|
@@ -23754,7 +23762,7 @@ var ts;
|
|
|
23754
23762
|
node.transformFlags |=
|
|
23755
23763
|
propagateChildrenFlags(node.elements) |
|
|
23756
23764
|
1024 /* ContainsES2015 */ |
|
|
23757
|
-
|
|
23765
|
+
524288 /* ContainsBindingPattern */;
|
|
23758
23766
|
return node;
|
|
23759
23767
|
}
|
|
23760
23768
|
// @api
|
|
@@ -23779,7 +23787,7 @@ var ts;
|
|
|
23779
23787
|
propagateChildFlags(node.propertyName);
|
|
23780
23788
|
}
|
|
23781
23789
|
if (dotDotDotToken)
|
|
23782
|
-
node.transformFlags |=
|
|
23790
|
+
node.transformFlags |= 32768 /* ContainsRestOrSpread */;
|
|
23783
23791
|
return node;
|
|
23784
23792
|
}
|
|
23785
23793
|
// @api
|
|
@@ -23954,10 +23962,10 @@ var ts;
|
|
|
23954
23962
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
23955
23963
|
}
|
|
23956
23964
|
if (ts.isImportKeyword(node.expression)) {
|
|
23957
|
-
node.transformFlags |=
|
|
23965
|
+
node.transformFlags |= 8388608 /* ContainsDynamicImport */;
|
|
23958
23966
|
}
|
|
23959
23967
|
else if (ts.isSuperProperty(node.expression)) {
|
|
23960
|
-
node.transformFlags |=
|
|
23968
|
+
node.transformFlags |= 16384 /* ContainsLexicalThis */;
|
|
23961
23969
|
}
|
|
23962
23970
|
return node;
|
|
23963
23971
|
}
|
|
@@ -23990,7 +23998,7 @@ var ts;
|
|
|
23990
23998
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
23991
23999
|
}
|
|
23992
24000
|
if (ts.isSuperProperty(node.expression)) {
|
|
23993
|
-
node.transformFlags |=
|
|
24001
|
+
node.transformFlags |= 16384 /* ContainsLexicalThis */;
|
|
23994
24002
|
}
|
|
23995
24003
|
return node;
|
|
23996
24004
|
}
|
|
@@ -24130,7 +24138,7 @@ var ts;
|
|
|
24130
24138
|
propagateChildFlags(node.equalsGreaterThanToken) |
|
|
24131
24139
|
1024 /* ContainsES2015 */;
|
|
24132
24140
|
if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
|
|
24133
|
-
node.transformFlags |= 256 /* ContainsES2017 */ |
|
|
24141
|
+
node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */;
|
|
24134
24142
|
}
|
|
24135
24143
|
return node;
|
|
24136
24144
|
}
|
|
@@ -24192,7 +24200,7 @@ var ts;
|
|
|
24192
24200
|
propagateChildFlags(node.expression) |
|
|
24193
24201
|
256 /* ContainsES2017 */ |
|
|
24194
24202
|
128 /* ContainsES2018 */ |
|
|
24195
|
-
|
|
24203
|
+
2097152 /* ContainsAwait */;
|
|
24196
24204
|
return node;
|
|
24197
24205
|
}
|
|
24198
24206
|
// @api
|
|
@@ -24213,7 +24221,7 @@ var ts;
|
|
|
24213
24221
|
ts.isIdentifier(node.operand) &&
|
|
24214
24222
|
!ts.isGeneratedIdentifier(node.operand) &&
|
|
24215
24223
|
!ts.isLocalName(node.operand)) {
|
|
24216
|
-
node.transformFlags |=
|
|
24224
|
+
node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
|
|
24217
24225
|
}
|
|
24218
24226
|
return node;
|
|
24219
24227
|
}
|
|
@@ -24234,7 +24242,7 @@ var ts;
|
|
|
24234
24242
|
if (ts.isIdentifier(node.operand) &&
|
|
24235
24243
|
!ts.isGeneratedIdentifier(node.operand) &&
|
|
24236
24244
|
!ts.isLocalName(node.operand)) {
|
|
24237
|
-
node.transformFlags |=
|
|
24245
|
+
node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
|
|
24238
24246
|
}
|
|
24239
24247
|
return node;
|
|
24240
24248
|
}
|
|
@@ -24283,8 +24291,8 @@ var ts;
|
|
|
24283
24291
|
return node;
|
|
24284
24292
|
}
|
|
24285
24293
|
function propagateAssignmentPatternFlags(node) {
|
|
24286
|
-
if (node.transformFlags &
|
|
24287
|
-
return
|
|
24294
|
+
if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */)
|
|
24295
|
+
return 65536 /* ContainsObjectRestOrSpread */;
|
|
24288
24296
|
if (node.transformFlags & 128 /* ContainsES2018 */) {
|
|
24289
24297
|
// check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
|
|
24290
24298
|
// will not be correctly interpreted by the ES2018 transformer
|
|
@@ -24292,8 +24300,8 @@ var ts;
|
|
|
24292
24300
|
var element = _a[_i];
|
|
24293
24301
|
var target = ts.getTargetOfBindingOrAssignmentElement(element);
|
|
24294
24302
|
if (target && ts.isAssignmentPattern(target)) {
|
|
24295
|
-
if (target.transformFlags &
|
|
24296
|
-
return
|
|
24303
|
+
if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
24304
|
+
return 65536 /* ContainsObjectRestOrSpread */;
|
|
24297
24305
|
}
|
|
24298
24306
|
if (target.transformFlags & 128 /* ContainsES2018 */) {
|
|
24299
24307
|
var flags_1 = propagateAssignmentPatternFlags(target);
|
|
@@ -24419,7 +24427,7 @@ var ts;
|
|
|
24419
24427
|
propagateChildFlags(node.asteriskToken) |
|
|
24420
24428
|
1024 /* ContainsES2015 */ |
|
|
24421
24429
|
128 /* ContainsES2018 */ |
|
|
24422
|
-
|
|
24430
|
+
1048576 /* ContainsYield */;
|
|
24423
24431
|
return node;
|
|
24424
24432
|
}
|
|
24425
24433
|
// @api
|
|
@@ -24436,7 +24444,7 @@ var ts;
|
|
|
24436
24444
|
node.transformFlags |=
|
|
24437
24445
|
propagateChildFlags(node.expression) |
|
|
24438
24446
|
1024 /* ContainsES2015 */ |
|
|
24439
|
-
|
|
24447
|
+
32768 /* ContainsRestOrSpread */;
|
|
24440
24448
|
return node;
|
|
24441
24449
|
}
|
|
24442
24450
|
// @api
|
|
@@ -24769,7 +24777,7 @@ var ts;
|
|
|
24769
24777
|
node.label = asName(label);
|
|
24770
24778
|
node.transformFlags |=
|
|
24771
24779
|
propagateChildFlags(node.label) |
|
|
24772
|
-
|
|
24780
|
+
4194304 /* ContainsHoistedDeclarationOrCompletion */;
|
|
24773
24781
|
return node;
|
|
24774
24782
|
}
|
|
24775
24783
|
// @api
|
|
@@ -24784,7 +24792,7 @@ var ts;
|
|
|
24784
24792
|
node.label = asName(label);
|
|
24785
24793
|
node.transformFlags |=
|
|
24786
24794
|
propagateChildFlags(node.label) |
|
|
24787
|
-
|
|
24795
|
+
4194304 /* ContainsHoistedDeclarationOrCompletion */;
|
|
24788
24796
|
return node;
|
|
24789
24797
|
}
|
|
24790
24798
|
// @api
|
|
@@ -24801,7 +24809,7 @@ var ts;
|
|
|
24801
24809
|
node.transformFlags |=
|
|
24802
24810
|
propagateChildFlags(node.expression) |
|
|
24803
24811
|
128 /* ContainsES2018 */ |
|
|
24804
|
-
|
|
24812
|
+
4194304 /* ContainsHoistedDeclarationOrCompletion */;
|
|
24805
24813
|
return node;
|
|
24806
24814
|
}
|
|
24807
24815
|
// @api
|
|
@@ -24927,11 +24935,11 @@ var ts;
|
|
|
24927
24935
|
node.declarations = createNodeArray(declarations);
|
|
24928
24936
|
node.transformFlags |=
|
|
24929
24937
|
propagateChildrenFlags(node.declarations) |
|
|
24930
|
-
|
|
24938
|
+
4194304 /* ContainsHoistedDeclarationOrCompletion */;
|
|
24931
24939
|
if (flags & 3 /* BlockScoped */) {
|
|
24932
24940
|
node.transformFlags |=
|
|
24933
24941
|
1024 /* ContainsES2015 */ |
|
|
24934
|
-
|
|
24942
|
+
262144 /* ContainsBlockScopedBinding */;
|
|
24935
24943
|
}
|
|
24936
24944
|
return node;
|
|
24937
24945
|
}
|
|
@@ -24951,7 +24959,7 @@ var ts;
|
|
|
24951
24959
|
else {
|
|
24952
24960
|
node.transformFlags |=
|
|
24953
24961
|
propagateChildFlags(node.asteriskToken) |
|
|
24954
|
-
|
|
24962
|
+
4194304 /* ContainsHoistedDeclarationOrCompletion */;
|
|
24955
24963
|
if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
|
|
24956
24964
|
if (node.asteriskToken) {
|
|
24957
24965
|
node.transformFlags |= 128 /* ContainsES2018 */;
|
|
@@ -24987,7 +24995,7 @@ var ts;
|
|
|
24987
24995
|
}
|
|
24988
24996
|
else {
|
|
24989
24997
|
node.transformFlags |= 1024 /* ContainsES2015 */;
|
|
24990
|
-
if (node.transformFlags &
|
|
24998
|
+
if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) {
|
|
24991
24999
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
24992
25000
|
}
|
|
24993
25001
|
}
|
|
@@ -25046,7 +25054,7 @@ var ts;
|
|
|
25046
25054
|
node.transformFlags |=
|
|
25047
25055
|
propagateChildrenFlags(node.members) |
|
|
25048
25056
|
1 /* ContainsTypeScript */;
|
|
25049
|
-
node.transformFlags &= ~
|
|
25057
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
|
|
25050
25058
|
return node;
|
|
25051
25059
|
}
|
|
25052
25060
|
// @api
|
|
@@ -25074,7 +25082,7 @@ var ts;
|
|
|
25074
25082
|
propagateChildFlags(node.body) |
|
|
25075
25083
|
1 /* ContainsTypeScript */;
|
|
25076
25084
|
}
|
|
25077
|
-
node.transformFlags &= ~
|
|
25085
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
|
|
25078
25086
|
return node;
|
|
25079
25087
|
}
|
|
25080
25088
|
// @api
|
|
@@ -25134,7 +25142,7 @@ var ts;
|
|
|
25134
25142
|
node.transformFlags |= propagateChildFlags(node.moduleReference);
|
|
25135
25143
|
if (!ts.isExternalModuleReference(node.moduleReference))
|
|
25136
25144
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
25137
|
-
node.transformFlags &= ~
|
|
25145
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
|
|
25138
25146
|
return node;
|
|
25139
25147
|
}
|
|
25140
25148
|
// @api
|
|
@@ -25156,7 +25164,7 @@ var ts;
|
|
|
25156
25164
|
node.transformFlags |=
|
|
25157
25165
|
propagateChildFlags(node.importClause) |
|
|
25158
25166
|
propagateChildFlags(node.moduleSpecifier);
|
|
25159
|
-
node.transformFlags &= ~
|
|
25167
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25160
25168
|
return node;
|
|
25161
25169
|
}
|
|
25162
25170
|
// @api
|
|
@@ -25181,7 +25189,7 @@ var ts;
|
|
|
25181
25189
|
if (isTypeOnly) {
|
|
25182
25190
|
node.transformFlags |= 1 /* ContainsTypeScript */;
|
|
25183
25191
|
}
|
|
25184
|
-
node.transformFlags &= ~
|
|
25192
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25185
25193
|
return node;
|
|
25186
25194
|
}
|
|
25187
25195
|
// @api
|
|
@@ -25241,7 +25249,7 @@ var ts;
|
|
|
25241
25249
|
var node = createBaseNode(268 /* NamespaceImport */);
|
|
25242
25250
|
node.name = name;
|
|
25243
25251
|
node.transformFlags |= propagateChildFlags(node.name);
|
|
25244
|
-
node.transformFlags &= ~
|
|
25252
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25245
25253
|
return node;
|
|
25246
25254
|
}
|
|
25247
25255
|
// @api
|
|
@@ -25257,7 +25265,7 @@ var ts;
|
|
|
25257
25265
|
node.transformFlags |=
|
|
25258
25266
|
propagateChildFlags(node.name) |
|
|
25259
25267
|
4 /* ContainsESNext */;
|
|
25260
|
-
node.transformFlags &= ~
|
|
25268
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25261
25269
|
return node;
|
|
25262
25270
|
}
|
|
25263
25271
|
// @api
|
|
@@ -25271,7 +25279,7 @@ var ts;
|
|
|
25271
25279
|
var node = createBaseNode(269 /* NamedImports */);
|
|
25272
25280
|
node.elements = createNodeArray(elements);
|
|
25273
25281
|
node.transformFlags |= propagateChildrenFlags(node.elements);
|
|
25274
|
-
node.transformFlags &= ~
|
|
25282
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25275
25283
|
return node;
|
|
25276
25284
|
}
|
|
25277
25285
|
// @api
|
|
@@ -25289,7 +25297,7 @@ var ts;
|
|
|
25289
25297
|
node.transformFlags |=
|
|
25290
25298
|
propagateChildFlags(node.propertyName) |
|
|
25291
25299
|
propagateChildFlags(node.name);
|
|
25292
|
-
node.transformFlags &= ~
|
|
25300
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25293
25301
|
return node;
|
|
25294
25302
|
}
|
|
25295
25303
|
// @api
|
|
@@ -25308,7 +25316,7 @@ var ts;
|
|
|
25308
25316
|
? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression)
|
|
25309
25317
|
: parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
|
|
25310
25318
|
node.transformFlags |= propagateChildFlags(node.expression);
|
|
25311
|
-
node.transformFlags &= ~
|
|
25319
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25312
25320
|
return node;
|
|
25313
25321
|
}
|
|
25314
25322
|
// @api
|
|
@@ -25329,7 +25337,7 @@ var ts;
|
|
|
25329
25337
|
node.transformFlags |=
|
|
25330
25338
|
propagateChildFlags(node.exportClause) |
|
|
25331
25339
|
propagateChildFlags(node.moduleSpecifier);
|
|
25332
|
-
node.transformFlags &= ~
|
|
25340
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25333
25341
|
return node;
|
|
25334
25342
|
}
|
|
25335
25343
|
// @api
|
|
@@ -25348,7 +25356,7 @@ var ts;
|
|
|
25348
25356
|
var node = createBaseNode(273 /* NamedExports */);
|
|
25349
25357
|
node.elements = createNodeArray(elements);
|
|
25350
25358
|
node.transformFlags |= propagateChildrenFlags(node.elements);
|
|
25351
|
-
node.transformFlags &= ~
|
|
25359
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25352
25360
|
return node;
|
|
25353
25361
|
}
|
|
25354
25362
|
// @api
|
|
@@ -25366,7 +25374,7 @@ var ts;
|
|
|
25366
25374
|
node.transformFlags |=
|
|
25367
25375
|
propagateChildFlags(node.propertyName) |
|
|
25368
25376
|
propagateChildFlags(node.name);
|
|
25369
|
-
node.transformFlags &= ~
|
|
25377
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25370
25378
|
return node;
|
|
25371
25379
|
}
|
|
25372
25380
|
// @api
|
|
@@ -25392,7 +25400,7 @@ var ts;
|
|
|
25392
25400
|
var node = createBaseNode(277 /* ExternalModuleReference */);
|
|
25393
25401
|
node.expression = expression;
|
|
25394
25402
|
node.transformFlags |= propagateChildFlags(node.expression);
|
|
25395
|
-
node.transformFlags &= ~
|
|
25403
|
+
node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
|
|
25396
25404
|
return node;
|
|
25397
25405
|
}
|
|
25398
25406
|
// @api
|
|
@@ -26166,7 +26174,7 @@ var ts;
|
|
|
26166
26174
|
node.transformFlags |=
|
|
26167
26175
|
propagateChildFlags(node.expression) |
|
|
26168
26176
|
128 /* ContainsES2018 */ |
|
|
26169
|
-
|
|
26177
|
+
65536 /* ContainsObjectRestOrSpread */;
|
|
26170
26178
|
return node;
|
|
26171
26179
|
}
|
|
26172
26180
|
// @api
|
|
@@ -27123,10 +27131,10 @@ var ts;
|
|
|
27123
27131
|
}
|
|
27124
27132
|
function propagateIdentifierNameFlags(node) {
|
|
27125
27133
|
// An IdentifierName is allowed to be `await`
|
|
27126
|
-
return propagateChildFlags(node) & ~
|
|
27134
|
+
return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
|
|
27127
27135
|
}
|
|
27128
27136
|
function propagatePropertyNameFlagsOfChild(node, transformFlags) {
|
|
27129
|
-
return transformFlags | (node.transformFlags &
|
|
27137
|
+
return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */);
|
|
27130
27138
|
}
|
|
27131
27139
|
function propagateChildFlags(child) {
|
|
27132
27140
|
if (!child)
|
|
@@ -27157,29 +27165,29 @@ var ts;
|
|
|
27157
27165
|
case 208 /* CallExpression */:
|
|
27158
27166
|
case 209 /* NewExpression */:
|
|
27159
27167
|
case 204 /* ArrayLiteralExpression */:
|
|
27160
|
-
return
|
|
27168
|
+
return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
|
|
27161
27169
|
case 261 /* ModuleDeclaration */:
|
|
27162
|
-
return
|
|
27170
|
+
return 742678528 /* ModuleExcludes */;
|
|
27163
27171
|
case 164 /* Parameter */:
|
|
27164
27172
|
return 536870912 /* ParameterExcludes */;
|
|
27165
27173
|
case 214 /* ArrowFunction */:
|
|
27166
|
-
return
|
|
27174
|
+
return 612179968 /* ArrowFunctionExcludes */;
|
|
27167
27175
|
case 213 /* FunctionExpression */:
|
|
27168
27176
|
case 256 /* FunctionDeclaration */:
|
|
27169
|
-
return
|
|
27177
|
+
return 746414080 /* FunctionExcludes */;
|
|
27170
27178
|
case 255 /* VariableDeclarationList */:
|
|
27171
|
-
return
|
|
27179
|
+
return 537460736 /* VariableDeclarationListExcludes */;
|
|
27172
27180
|
case 257 /* ClassDeclaration */:
|
|
27173
27181
|
case 226 /* ClassExpression */:
|
|
27174
|
-
return
|
|
27182
|
+
return 537010176 /* ClassExcludes */;
|
|
27175
27183
|
case 171 /* Constructor */:
|
|
27176
|
-
return
|
|
27184
|
+
return 746405888 /* ConstructorExcludes */;
|
|
27177
27185
|
case 167 /* PropertyDeclaration */:
|
|
27178
|
-
return
|
|
27186
|
+
return 671105024 /* PropertyExcludes */;
|
|
27179
27187
|
case 169 /* MethodDeclaration */:
|
|
27180
27188
|
case 172 /* GetAccessor */:
|
|
27181
27189
|
case 173 /* SetAccessor */:
|
|
27182
|
-
return
|
|
27190
|
+
return 679297024 /* MethodOrAccessorExcludes */;
|
|
27183
27191
|
case 130 /* AnyKeyword */:
|
|
27184
27192
|
case 147 /* NumberKeyword */:
|
|
27185
27193
|
case 158 /* BigIntKeyword */:
|
|
@@ -27199,12 +27207,12 @@ var ts;
|
|
|
27199
27207
|
case 259 /* TypeAliasDeclaration */:
|
|
27200
27208
|
return -2 /* TypeExcludes */;
|
|
27201
27209
|
case 205 /* ObjectLiteralExpression */:
|
|
27202
|
-
return
|
|
27210
|
+
return 537075712 /* ObjectLiteralExcludes */;
|
|
27203
27211
|
case 292 /* CatchClause */:
|
|
27204
|
-
return
|
|
27212
|
+
return 536936448 /* CatchClauseExcludes */;
|
|
27205
27213
|
case 201 /* ObjectBindingPattern */:
|
|
27206
27214
|
case 202 /* ArrayBindingPattern */:
|
|
27207
|
-
return
|
|
27215
|
+
return 536903680 /* BindingPatternExcludes */;
|
|
27208
27216
|
case 211 /* TypeAssertionExpression */:
|
|
27209
27217
|
case 229 /* AsExpression */:
|
|
27210
27218
|
case 350 /* PartiallyEmittedExpression */:
|
|
@@ -30438,6 +30446,14 @@ var ts;
|
|
|
30438
30446
|
}
|
|
30439
30447
|
}
|
|
30440
30448
|
ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline;
|
|
30449
|
+
function elideNodes(factory, nodes) {
|
|
30450
|
+
if (nodes === undefined)
|
|
30451
|
+
return undefined;
|
|
30452
|
+
if (nodes.length === 0)
|
|
30453
|
+
return nodes;
|
|
30454
|
+
return ts.setTextRange(factory.createNodeArray([], nodes.hasTrailingComma), nodes);
|
|
30455
|
+
}
|
|
30456
|
+
ts.elideNodes = elideNodes;
|
|
30441
30457
|
})(ts || (ts = {}));
|
|
30442
30458
|
var ts;
|
|
30443
30459
|
(function (ts) {
|
|
@@ -31609,7 +31625,7 @@ var ts;
|
|
|
31609
31625
|
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
|
|
31610
31626
|
function containsPossibleTopLevelAwait(node) {
|
|
31611
31627
|
return !(node.flags & 32768 /* AwaitContext */)
|
|
31612
|
-
&& !!(node.transformFlags &
|
|
31628
|
+
&& !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */);
|
|
31613
31629
|
}
|
|
31614
31630
|
function findNextStatementWithAwait(statements, start) {
|
|
31615
31631
|
for (var i = start; i < statements.length; i++) {
|
|
@@ -31650,7 +31666,7 @@ var ts;
|
|
|
31650
31666
|
ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
|
|
31651
31667
|
setFields(sourceFile);
|
|
31652
31668
|
// If we parsed this as an external module, it may contain top-level await
|
|
31653
|
-
if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags &
|
|
31669
|
+
if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
|
|
31654
31670
|
sourceFile = reparseTopLevelAwait(sourceFile);
|
|
31655
31671
|
setFields(sourceFile);
|
|
31656
31672
|
}
|
|
@@ -91048,6 +91064,124 @@ var ts;
|
|
|
91048
91064
|
return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name);
|
|
91049
91065
|
}
|
|
91050
91066
|
ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName;
|
|
91067
|
+
/**
|
|
91068
|
+
* Gets an array of arrays of decorators for the parameters of a function-like node.
|
|
91069
|
+
* The offset into the result array should correspond to the offset of the parameter.
|
|
91070
|
+
*
|
|
91071
|
+
* @param node The function-like node.
|
|
91072
|
+
*/
|
|
91073
|
+
function getDecoratorsOfParameters(node) {
|
|
91074
|
+
var decorators;
|
|
91075
|
+
if (node) {
|
|
91076
|
+
var parameters = node.parameters;
|
|
91077
|
+
var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
|
|
91078
|
+
var firstParameterOffset = firstParameterIsThis ? 1 : 0;
|
|
91079
|
+
var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
|
|
91080
|
+
for (var i = 0; i < numParameters; i++) {
|
|
91081
|
+
var parameter = parameters[i + firstParameterOffset];
|
|
91082
|
+
if (decorators || parameter.decorators) {
|
|
91083
|
+
if (!decorators) {
|
|
91084
|
+
decorators = new Array(numParameters);
|
|
91085
|
+
}
|
|
91086
|
+
decorators[i] = parameter.decorators;
|
|
91087
|
+
}
|
|
91088
|
+
}
|
|
91089
|
+
}
|
|
91090
|
+
return decorators;
|
|
91091
|
+
}
|
|
91092
|
+
/**
|
|
91093
|
+
* Gets an AllDecorators object containing the decorators for the class and the decorators for the
|
|
91094
|
+
* parameters of the constructor of the class.
|
|
91095
|
+
*
|
|
91096
|
+
* @param node The class node.
|
|
91097
|
+
*/
|
|
91098
|
+
function getAllDecoratorsOfClass(node) {
|
|
91099
|
+
var decorators = node.decorators;
|
|
91100
|
+
var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
|
|
91101
|
+
if (!decorators && !parameters) {
|
|
91102
|
+
return undefined;
|
|
91103
|
+
}
|
|
91104
|
+
return {
|
|
91105
|
+
decorators: decorators,
|
|
91106
|
+
parameters: parameters
|
|
91107
|
+
};
|
|
91108
|
+
}
|
|
91109
|
+
ts.getAllDecoratorsOfClass = getAllDecoratorsOfClass;
|
|
91110
|
+
/**
|
|
91111
|
+
* Gets an AllDecorators object containing the decorators for the member and its parameters.
|
|
91112
|
+
*
|
|
91113
|
+
* @param parent The class node that contains the member.
|
|
91114
|
+
* @param member The class member.
|
|
91115
|
+
*/
|
|
91116
|
+
function getAllDecoratorsOfClassElement(member, parent) {
|
|
91117
|
+
switch (member.kind) {
|
|
91118
|
+
case 172 /* GetAccessor */:
|
|
91119
|
+
case 173 /* SetAccessor */:
|
|
91120
|
+
return getAllDecoratorsOfAccessors(member, parent);
|
|
91121
|
+
case 169 /* MethodDeclaration */:
|
|
91122
|
+
return getAllDecoratorsOfMethod(member);
|
|
91123
|
+
case 167 /* PropertyDeclaration */:
|
|
91124
|
+
return getAllDecoratorsOfProperty(member);
|
|
91125
|
+
default:
|
|
91126
|
+
return undefined;
|
|
91127
|
+
}
|
|
91128
|
+
}
|
|
91129
|
+
ts.getAllDecoratorsOfClassElement = getAllDecoratorsOfClassElement;
|
|
91130
|
+
/**
|
|
91131
|
+
* Gets an AllDecorators object containing the decorators for the accessor and its parameters.
|
|
91132
|
+
*
|
|
91133
|
+
* @param parent The class node that contains the accessor.
|
|
91134
|
+
* @param accessor The class accessor member.
|
|
91135
|
+
*/
|
|
91136
|
+
function getAllDecoratorsOfAccessors(accessor, parent) {
|
|
91137
|
+
if (!accessor.body) {
|
|
91138
|
+
return undefined;
|
|
91139
|
+
}
|
|
91140
|
+
var _a = ts.getAllAccessorDeclarations(parent.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
|
|
91141
|
+
var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
|
|
91142
|
+
if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
|
|
91143
|
+
return undefined;
|
|
91144
|
+
}
|
|
91145
|
+
var decorators = firstAccessorWithDecorators.decorators;
|
|
91146
|
+
var parameters = getDecoratorsOfParameters(setAccessor);
|
|
91147
|
+
if (!decorators && !parameters) {
|
|
91148
|
+
return undefined;
|
|
91149
|
+
}
|
|
91150
|
+
return {
|
|
91151
|
+
decorators: decorators,
|
|
91152
|
+
parameters: parameters,
|
|
91153
|
+
getDecorators: getAccessor === null || getAccessor === void 0 ? void 0 : getAccessor.decorators,
|
|
91154
|
+
setDecorators: setAccessor === null || setAccessor === void 0 ? void 0 : setAccessor.decorators
|
|
91155
|
+
};
|
|
91156
|
+
}
|
|
91157
|
+
/**
|
|
91158
|
+
* Gets an AllDecorators object containing the decorators for the method and its parameters.
|
|
91159
|
+
*
|
|
91160
|
+
* @param method The class method member.
|
|
91161
|
+
*/
|
|
91162
|
+
function getAllDecoratorsOfMethod(method) {
|
|
91163
|
+
if (!method.body) {
|
|
91164
|
+
return undefined;
|
|
91165
|
+
}
|
|
91166
|
+
var decorators = method.decorators;
|
|
91167
|
+
var parameters = getDecoratorsOfParameters(method);
|
|
91168
|
+
if (!decorators && !parameters) {
|
|
91169
|
+
return undefined;
|
|
91170
|
+
}
|
|
91171
|
+
return { decorators: decorators, parameters: parameters };
|
|
91172
|
+
}
|
|
91173
|
+
/**
|
|
91174
|
+
* Gets an AllDecorators object containing the decorators for the property.
|
|
91175
|
+
*
|
|
91176
|
+
* @param property The class property member.
|
|
91177
|
+
*/
|
|
91178
|
+
function getAllDecoratorsOfProperty(property) {
|
|
91179
|
+
var decorators = property.decorators;
|
|
91180
|
+
if (!decorators) {
|
|
91181
|
+
return undefined;
|
|
91182
|
+
}
|
|
91183
|
+
return { decorators: decorators };
|
|
91184
|
+
}
|
|
91051
91185
|
})(ts || (ts = {}));
|
|
91052
91186
|
/*@internal*/
|
|
91053
91187
|
var ts;
|
|
@@ -91321,8 +91455,8 @@ var ts;
|
|
|
91321
91455
|
if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
|
|
91322
91456
|
var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
|
|
91323
91457
|
if (flattenContext.level >= 1 /* ObjectRest */
|
|
91324
|
-
&& !(element.transformFlags & (
|
|
91325
|
-
&& !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (
|
|
91458
|
+
&& !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
|
|
91459
|
+
&& !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
|
|
91326
91460
|
&& !ts.isComputedPropertyName(propertyName)) {
|
|
91327
91461
|
bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
|
|
91328
91462
|
}
|
|
@@ -91388,7 +91522,7 @@ var ts;
|
|
|
91388
91522
|
if (flattenContext.level >= 1 /* ObjectRest */) {
|
|
91389
91523
|
// If an array pattern contains an ObjectRest, we must cache the result so that we
|
|
91390
91524
|
// can perform the ObjectRest destructuring in a different declaration
|
|
91391
|
-
if (element.transformFlags &
|
|
91525
|
+
if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
|
|
91392
91526
|
flattenContext.hasTransformedPriorElement = true;
|
|
91393
91527
|
var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
91394
91528
|
if (flattenContext.hoistTempVariables) {
|
|
@@ -91610,8 +91744,6 @@ var ts;
|
|
|
91610
91744
|
var USE_NEW_TYPE_METADATA_FORMAT = false;
|
|
91611
91745
|
var TypeScriptSubstitutionFlags;
|
|
91612
91746
|
(function (TypeScriptSubstitutionFlags) {
|
|
91613
|
-
/** Enables substitutions for decorated classes. */
|
|
91614
|
-
TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases";
|
|
91615
91747
|
/** Enables substitutions for namespace exports. */
|
|
91616
91748
|
TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports";
|
|
91617
91749
|
/* Enables substitutions for unqualified enum members */
|
|
@@ -91637,9 +91769,9 @@ var ts;
|
|
|
91637
91769
|
var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
|
|
91638
91770
|
var resolver = context.getEmitResolver();
|
|
91639
91771
|
var compilerOptions = context.getCompilerOptions();
|
|
91640
|
-
var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
|
|
91641
91772
|
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
91642
91773
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
91774
|
+
var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined;
|
|
91643
91775
|
// Save the previous transformation hooks.
|
|
91644
91776
|
var previousOnEmitNode = context.onEmitNode;
|
|
91645
91777
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
@@ -91654,7 +91786,6 @@ var ts;
|
|
|
91654
91786
|
var currentNamespace;
|
|
91655
91787
|
var currentNamespaceContainerName;
|
|
91656
91788
|
var currentLexicalScope;
|
|
91657
|
-
var currentNameScope;
|
|
91658
91789
|
var currentScopeFirstDeclarationsOfName;
|
|
91659
91790
|
var currentClassHasParameterProperties;
|
|
91660
91791
|
/**
|
|
@@ -91662,11 +91793,6 @@ var ts;
|
|
|
91662
91793
|
* They are persisted between each SourceFile transformation and should not be reset.
|
|
91663
91794
|
*/
|
|
91664
91795
|
var enabledSubstitutions;
|
|
91665
|
-
/**
|
|
91666
|
-
* A map that keeps track of aliases created for classes with decorators to avoid issues
|
|
91667
|
-
* with the double-binding behavior of classes.
|
|
91668
|
-
*/
|
|
91669
|
-
var classAliases;
|
|
91670
91796
|
/**
|
|
91671
91797
|
* Keeps track of whether we are within any containing namespaces when performing
|
|
91672
91798
|
* just-in-time substitution while printing an expression identifier.
|
|
@@ -91710,7 +91836,6 @@ var ts;
|
|
|
91710
91836
|
function saveStateAndInvoke(node, f) {
|
|
91711
91837
|
// Save state
|
|
91712
91838
|
var savedCurrentScope = currentLexicalScope;
|
|
91713
|
-
var savedCurrentNameScope = currentNameScope;
|
|
91714
91839
|
var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
|
|
91715
91840
|
var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
|
|
91716
91841
|
// Handle state changes before visiting a node.
|
|
@@ -91721,7 +91846,6 @@ var ts;
|
|
|
91721
91846
|
currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
|
|
91722
91847
|
}
|
|
91723
91848
|
currentLexicalScope = savedCurrentScope;
|
|
91724
|
-
currentNameScope = savedCurrentNameScope;
|
|
91725
91849
|
currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
|
|
91726
91850
|
return visited;
|
|
91727
91851
|
}
|
|
@@ -91737,7 +91861,6 @@ var ts;
|
|
|
91737
91861
|
case 262 /* ModuleBlock */:
|
|
91738
91862
|
case 235 /* Block */:
|
|
91739
91863
|
currentLexicalScope = node;
|
|
91740
|
-
currentNameScope = undefined;
|
|
91741
91864
|
currentScopeFirstDeclarationsOfName = undefined;
|
|
91742
91865
|
break;
|
|
91743
91866
|
case 257 /* ClassDeclaration */:
|
|
@@ -91755,10 +91878,6 @@ var ts;
|
|
|
91755
91878
|
// programs may also have an undefined name.
|
|
91756
91879
|
ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
|
|
91757
91880
|
}
|
|
91758
|
-
if (ts.isClassDeclaration(node)) {
|
|
91759
|
-
// XXX: should probably also cover interfaces and type aliases that can have type variables?
|
|
91760
|
-
currentNameScope = node;
|
|
91761
|
-
}
|
|
91762
91881
|
break;
|
|
91763
91882
|
}
|
|
91764
91883
|
}
|
|
@@ -91860,35 +91979,66 @@ var ts;
|
|
|
91860
91979
|
return node;
|
|
91861
91980
|
}
|
|
91862
91981
|
/**
|
|
91863
|
-
*
|
|
91982
|
+
* Gets a specialized visitor that visits the immediate children of a class with TypeScript syntax.
|
|
91864
91983
|
*
|
|
91865
|
-
* @param
|
|
91984
|
+
* @param parent The class containing the elements to visit.
|
|
91866
91985
|
*/
|
|
91867
|
-
function
|
|
91868
|
-
return saveStateAndInvoke(node, classElementVisitorWorker);
|
|
91986
|
+
function getClassElementVisitor(parent) {
|
|
91987
|
+
return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); };
|
|
91869
91988
|
}
|
|
91870
91989
|
/**
|
|
91871
91990
|
* Specialized visitor that visits the immediate children of a class with TypeScript syntax.
|
|
91872
91991
|
*
|
|
91873
91992
|
* @param node The node to visit.
|
|
91874
91993
|
*/
|
|
91875
|
-
function classElementVisitorWorker(node) {
|
|
91994
|
+
function classElementVisitorWorker(node, parent) {
|
|
91876
91995
|
switch (node.kind) {
|
|
91877
91996
|
case 171 /* Constructor */:
|
|
91878
91997
|
return visitConstructor(node);
|
|
91879
91998
|
case 167 /* PropertyDeclaration */:
|
|
91880
91999
|
// Property declarations are not TypeScript syntax, but they must be visited
|
|
91881
92000
|
// for the decorator transformation.
|
|
91882
|
-
return visitPropertyDeclaration(node);
|
|
91883
|
-
case 176 /* IndexSignature */:
|
|
92001
|
+
return visitPropertyDeclaration(node, parent);
|
|
91884
92002
|
case 172 /* GetAccessor */:
|
|
92003
|
+
// Get Accessors can have TypeScript modifiers, decorators, and type annotations.
|
|
92004
|
+
return visitGetAccessor(node, parent);
|
|
91885
92005
|
case 173 /* SetAccessor */:
|
|
92006
|
+
// Set Accessors can have TypeScript modifiers and type annotations.
|
|
92007
|
+
return visitSetAccessor(node, parent);
|
|
91886
92008
|
case 169 /* MethodDeclaration */:
|
|
92009
|
+
// TypeScript method declarations may have decorators, modifiers
|
|
92010
|
+
// or type annotations.
|
|
92011
|
+
return visitMethodDeclaration(node, parent);
|
|
91887
92012
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
91888
|
-
|
|
91889
|
-
return visitorWorker(node);
|
|
92013
|
+
return ts.visitEachChild(node, visitor, context);
|
|
91890
92014
|
case 234 /* SemicolonClassElement */:
|
|
91891
92015
|
return node;
|
|
92016
|
+
case 176 /* IndexSignature */:
|
|
92017
|
+
// Index signatures are elided
|
|
92018
|
+
return;
|
|
92019
|
+
default:
|
|
92020
|
+
return ts.Debug.failBadSyntaxKind(node);
|
|
92021
|
+
}
|
|
92022
|
+
}
|
|
92023
|
+
function getObjectLiteralElementVisitor(parent) {
|
|
92024
|
+
return function (node) { return saveStateAndInvoke(node, function (n) { return objectLiteralElementVisitorWorker(n, parent); }); };
|
|
92025
|
+
}
|
|
92026
|
+
function objectLiteralElementVisitorWorker(node, parent) {
|
|
92027
|
+
switch (node.kind) {
|
|
92028
|
+
case 296 /* PropertyAssignment */:
|
|
92029
|
+
case 297 /* ShorthandPropertyAssignment */:
|
|
92030
|
+
case 298 /* SpreadAssignment */:
|
|
92031
|
+
return visitor(node);
|
|
92032
|
+
case 172 /* GetAccessor */:
|
|
92033
|
+
// Get Accessors can have TypeScript modifiers, decorators, and type annotations.
|
|
92034
|
+
return visitGetAccessor(node, parent);
|
|
92035
|
+
case 173 /* SetAccessor */:
|
|
92036
|
+
// Set Accessors can have TypeScript modifiers and type annotations.
|
|
92037
|
+
return visitSetAccessor(node, parent);
|
|
92038
|
+
case 169 /* MethodDeclaration */:
|
|
92039
|
+
// TypeScript method declarations may have decorators, modifiers
|
|
92040
|
+
// or type annotations.
|
|
92041
|
+
return visitMethodDeclaration(node, parent);
|
|
91892
92042
|
default:
|
|
91893
92043
|
return ts.Debug.failBadSyntaxKind(node);
|
|
91894
92044
|
}
|
|
@@ -91961,22 +92111,14 @@ var ts;
|
|
|
91961
92111
|
// TypeScript type nodes are elided.
|
|
91962
92112
|
// falls through
|
|
91963
92113
|
case 176 /* IndexSignature */:
|
|
91964
|
-
|
|
91965
|
-
// falls through
|
|
91966
|
-
case 165 /* Decorator */:
|
|
91967
|
-
// TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
|
|
92114
|
+
// TypeScript index signatures are elided.
|
|
91968
92115
|
return undefined;
|
|
91969
92116
|
case 259 /* TypeAliasDeclaration */:
|
|
91970
92117
|
// TypeScript type-only declarations are elided.
|
|
91971
92118
|
return factory.createNotEmittedStatement(node);
|
|
91972
|
-
case 167 /* PropertyDeclaration */:
|
|
91973
|
-
// TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
|
|
91974
|
-
return visitPropertyDeclaration(node);
|
|
91975
92119
|
case 264 /* NamespaceExportDeclaration */:
|
|
91976
92120
|
// TypeScript namespace export declarations are elided.
|
|
91977
92121
|
return undefined;
|
|
91978
|
-
case 171 /* Constructor */:
|
|
91979
|
-
return visitConstructor(node);
|
|
91980
92122
|
case 258 /* InterfaceDeclaration */:
|
|
91981
92123
|
// TypeScript interfaces are elided, but some comments may be preserved.
|
|
91982
92124
|
// See the implementation of `getLeadingComments` in comments.ts for more details.
|
|
@@ -92010,16 +92152,15 @@ var ts;
|
|
|
92010
92152
|
case 228 /* ExpressionWithTypeArguments */:
|
|
92011
92153
|
// TypeScript supports type arguments on an expression in an `extends` heritage clause.
|
|
92012
92154
|
return visitExpressionWithTypeArguments(node);
|
|
92155
|
+
case 205 /* ObjectLiteralExpression */:
|
|
92156
|
+
return visitObjectLiteralExpression(node);
|
|
92157
|
+
case 171 /* Constructor */:
|
|
92158
|
+
case 167 /* PropertyDeclaration */:
|
|
92013
92159
|
case 169 /* MethodDeclaration */:
|
|
92014
|
-
// TypeScript method declarations may have decorators, modifiers
|
|
92015
|
-
// or type annotations.
|
|
92016
|
-
return visitMethodDeclaration(node);
|
|
92017
92160
|
case 172 /* GetAccessor */:
|
|
92018
|
-
// Get Accessors can have TypeScript modifiers, decorators, and type annotations.
|
|
92019
|
-
return visitGetAccessor(node);
|
|
92020
92161
|
case 173 /* SetAccessor */:
|
|
92021
|
-
|
|
92022
|
-
return
|
|
92162
|
+
case 170 /* ClassStaticBlockDeclaration */:
|
|
92163
|
+
return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors");
|
|
92023
92164
|
case 256 /* FunctionDeclaration */:
|
|
92024
92165
|
// Typescript function declarations can have modifiers, decorators, and type annotations.
|
|
92025
92166
|
return visitFunctionDeclaration(node);
|
|
@@ -92085,6 +92226,9 @@ var ts;
|
|
|
92085
92226
|
!ts.isJsonSourceFile(node);
|
|
92086
92227
|
return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
|
|
92087
92228
|
}
|
|
92229
|
+
function visitObjectLiteralExpression(node) {
|
|
92230
|
+
return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement));
|
|
92231
|
+
}
|
|
92088
92232
|
function getClassFacts(node, staticProperties) {
|
|
92089
92233
|
var facts = 0 /* None */;
|
|
92090
92234
|
if (ts.some(staticProperties))
|
|
@@ -92107,7 +92251,7 @@ var ts;
|
|
|
92107
92251
|
return facts;
|
|
92108
92252
|
}
|
|
92109
92253
|
function hasTypeScriptClassSyntax(node) {
|
|
92110
|
-
return !!(node.transformFlags &
|
|
92254
|
+
return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */);
|
|
92111
92255
|
}
|
|
92112
92256
|
function isClassLikeDeclarationWithTypeScriptSyntax(node) {
|
|
92113
92257
|
return ts.some(node.decorators)
|
|
@@ -92117,7 +92261,9 @@ var ts;
|
|
|
92117
92261
|
}
|
|
92118
92262
|
function visitClassDeclaration(node) {
|
|
92119
92263
|
if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
|
|
92120
|
-
return ts.
|
|
92264
|
+
return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
|
|
92265
|
+
ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name,
|
|
92266
|
+
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
|
|
92121
92267
|
}
|
|
92122
92268
|
var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
|
|
92123
92269
|
var facts = getClassFacts(node, staticProperties);
|
|
@@ -92125,14 +92271,25 @@ var ts;
|
|
|
92125
92271
|
context.startLexicalEnvironment();
|
|
92126
92272
|
}
|
|
92127
92273
|
var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
|
|
92128
|
-
var
|
|
92129
|
-
|
|
92130
|
-
|
|
92274
|
+
var allDecorators = getAllDecoratorsOfConstructor(node);
|
|
92275
|
+
var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
|
|
92276
|
+
// we do not emit modifiers on the declaration if we are emitting an IIFE
|
|
92277
|
+
var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
|
|
92278
|
+
? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
|
|
92279
|
+
: ts.elideNodes(factory, node.modifiers); // preserve positions, if available
|
|
92280
|
+
// ${modifiers} class ${name} ${heritageClauses} {
|
|
92281
|
+
// ${members}
|
|
92282
|
+
// }
|
|
92283
|
+
var classStatement = factory.updateClassDeclaration(node, decorators, modifiers, name,
|
|
92284
|
+
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
|
|
92285
|
+
// To better align with the old emitter, we should not emit a trailing source map
|
|
92286
|
+
// entry if the class has static properties.
|
|
92287
|
+
var emitFlags = ts.getEmitFlags(node);
|
|
92288
|
+
if (facts & 1 /* HasStaticInitializedProperties */) {
|
|
92289
|
+
emitFlags |= 32 /* NoTrailingSourceMap */;
|
|
92290
|
+
}
|
|
92291
|
+
ts.setEmitFlags(classStatement, emitFlags);
|
|
92131
92292
|
var statements = [classStatement];
|
|
92132
|
-
// Write any decorators of the node.
|
|
92133
|
-
addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
|
|
92134
|
-
addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
|
|
92135
|
-
addConstructorDecorationStatement(statements, node);
|
|
92136
92293
|
if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
|
|
92137
92294
|
// When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
|
|
92138
92295
|
// 'es2015' transformer can properly nest static initializers and decorators. The result
|
|
@@ -92192,164 +92349,14 @@ var ts;
|
|
|
92192
92349
|
}
|
|
92193
92350
|
return ts.singleOrMany(statements);
|
|
92194
92351
|
}
|
|
92195
|
-
/**
|
|
92196
|
-
* Transforms a non-decorated class declaration and appends the resulting statements.
|
|
92197
|
-
*
|
|
92198
|
-
* @param node A ClassDeclaration node.
|
|
92199
|
-
* @param name The name of the class.
|
|
92200
|
-
* @param facts Precomputed facts about the class.
|
|
92201
|
-
*/
|
|
92202
|
-
function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
|
|
92203
|
-
// ${modifiers} class ${name} ${heritageClauses} {
|
|
92204
|
-
// ${members}
|
|
92205
|
-
// }
|
|
92206
|
-
// we do not emit modifiers on the declaration if we are emitting an IIFE
|
|
92207
|
-
var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
|
|
92208
|
-
? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
|
|
92209
|
-
: undefined;
|
|
92210
|
-
var classDeclaration = factory.createClassDeclaration(
|
|
92211
|
-
/*decorators*/ undefined, modifiers, name,
|
|
92212
|
-
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
|
|
92213
|
-
// To better align with the old emitter, we should not emit a trailing source map
|
|
92214
|
-
// entry if the class has static properties.
|
|
92215
|
-
var emitFlags = ts.getEmitFlags(node);
|
|
92216
|
-
if (facts & 1 /* HasStaticInitializedProperties */) {
|
|
92217
|
-
emitFlags |= 32 /* NoTrailingSourceMap */;
|
|
92218
|
-
}
|
|
92219
|
-
ts.setTextRange(classDeclaration, node);
|
|
92220
|
-
ts.setOriginalNode(classDeclaration, node);
|
|
92221
|
-
ts.setEmitFlags(classDeclaration, emitFlags);
|
|
92222
|
-
return classDeclaration;
|
|
92223
|
-
}
|
|
92224
|
-
/**
|
|
92225
|
-
* Transforms a decorated class declaration and appends the resulting statements. If
|
|
92226
|
-
* the class requires an alias to avoid issues with double-binding, the alias is returned.
|
|
92227
|
-
*/
|
|
92228
|
-
function createClassDeclarationHeadWithDecorators(node, name) {
|
|
92229
|
-
// When we emit an ES6 class that has a class decorator, we must tailor the
|
|
92230
|
-
// emit to certain specific cases.
|
|
92231
|
-
//
|
|
92232
|
-
// In the simplest case, we emit the class declaration as a let declaration, and
|
|
92233
|
-
// evaluate decorators after the close of the class body:
|
|
92234
|
-
//
|
|
92235
|
-
// [Example 1]
|
|
92236
|
-
// ---------------------------------------------------------------------
|
|
92237
|
-
// TypeScript | Javascript
|
|
92238
|
-
// ---------------------------------------------------------------------
|
|
92239
|
-
// @dec | let C = class C {
|
|
92240
|
-
// class C { | }
|
|
92241
|
-
// } | C = __decorate([dec], C);
|
|
92242
|
-
// ---------------------------------------------------------------------
|
|
92243
|
-
// @dec | let C = class C {
|
|
92244
|
-
// export class C { | }
|
|
92245
|
-
// } | C = __decorate([dec], C);
|
|
92246
|
-
// | export { C };
|
|
92247
|
-
// ---------------------------------------------------------------------
|
|
92248
|
-
//
|
|
92249
|
-
// If a class declaration contains a reference to itself *inside* of the class body,
|
|
92250
|
-
// this introduces two bindings to the class: One outside of the class body, and one
|
|
92251
|
-
// inside of the class body. If we apply decorators as in [Example 1] above, there
|
|
92252
|
-
// is the possibility that the decorator `dec` will return a new value for the
|
|
92253
|
-
// constructor, which would result in the binding inside of the class no longer
|
|
92254
|
-
// pointing to the same reference as the binding outside of the class.
|
|
92255
|
-
//
|
|
92256
|
-
// As a result, we must instead rewrite all references to the class *inside* of the
|
|
92257
|
-
// class body to instead point to a local temporary alias for the class:
|
|
92258
|
-
//
|
|
92259
|
-
// [Example 2]
|
|
92260
|
-
// ---------------------------------------------------------------------
|
|
92261
|
-
// TypeScript | Javascript
|
|
92262
|
-
// ---------------------------------------------------------------------
|
|
92263
|
-
// @dec | let C = C_1 = class C {
|
|
92264
|
-
// class C { | static x() { return C_1.y; }
|
|
92265
|
-
// static x() { return C.y; } | }
|
|
92266
|
-
// static y = 1; | C.y = 1;
|
|
92267
|
-
// } | C = C_1 = __decorate([dec], C);
|
|
92268
|
-
// | var C_1;
|
|
92269
|
-
// ---------------------------------------------------------------------
|
|
92270
|
-
// @dec | let C = class C {
|
|
92271
|
-
// export class C { | static x() { return C_1.y; }
|
|
92272
|
-
// static x() { return C.y; } | }
|
|
92273
|
-
// static y = 1; | C.y = 1;
|
|
92274
|
-
// } | C = C_1 = __decorate([dec], C);
|
|
92275
|
-
// | export { C };
|
|
92276
|
-
// | var C_1;
|
|
92277
|
-
// ---------------------------------------------------------------------
|
|
92278
|
-
//
|
|
92279
|
-
// If a class declaration is the default export of a module, we instead emit
|
|
92280
|
-
// the export after the decorated declaration:
|
|
92281
|
-
//
|
|
92282
|
-
// [Example 3]
|
|
92283
|
-
// ---------------------------------------------------------------------
|
|
92284
|
-
// TypeScript | Javascript
|
|
92285
|
-
// ---------------------------------------------------------------------
|
|
92286
|
-
// @dec | let default_1 = class {
|
|
92287
|
-
// export default class { | }
|
|
92288
|
-
// } | default_1 = __decorate([dec], default_1);
|
|
92289
|
-
// | export default default_1;
|
|
92290
|
-
// ---------------------------------------------------------------------
|
|
92291
|
-
// @dec | let C = class C {
|
|
92292
|
-
// export default class C { | }
|
|
92293
|
-
// } | C = __decorate([dec], C);
|
|
92294
|
-
// | export default C;
|
|
92295
|
-
// ---------------------------------------------------------------------
|
|
92296
|
-
//
|
|
92297
|
-
// If the class declaration is the default export and a reference to itself
|
|
92298
|
-
// inside of the class body, we must emit both an alias for the class *and*
|
|
92299
|
-
// move the export after the declaration:
|
|
92300
|
-
//
|
|
92301
|
-
// [Example 4]
|
|
92302
|
-
// ---------------------------------------------------------------------
|
|
92303
|
-
// TypeScript | Javascript
|
|
92304
|
-
// ---------------------------------------------------------------------
|
|
92305
|
-
// @dec | let C = class C {
|
|
92306
|
-
// export default class C { | static x() { return C_1.y; }
|
|
92307
|
-
// static x() { return C.y; } | }
|
|
92308
|
-
// static y = 1; | C.y = 1;
|
|
92309
|
-
// } | C = C_1 = __decorate([dec], C);
|
|
92310
|
-
// | export default C;
|
|
92311
|
-
// | var C_1;
|
|
92312
|
-
// ---------------------------------------------------------------------
|
|
92313
|
-
//
|
|
92314
|
-
var location = ts.moveRangePastDecorators(node);
|
|
92315
|
-
var classAlias = getClassAliasIfNeeded(node);
|
|
92316
|
-
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
|
92317
|
-
// without any block-scoped variable collision handling
|
|
92318
|
-
var declName = languageVersion <= 2 /* ES2015 */ ?
|
|
92319
|
-
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
|
92320
|
-
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
|
92321
|
-
// ... = class ${name} ${heritageClauses} {
|
|
92322
|
-
// ${members}
|
|
92323
|
-
// }
|
|
92324
|
-
var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
|
|
92325
|
-
var members = transformClassMembers(node);
|
|
92326
|
-
var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
|
|
92327
|
-
ts.setOriginalNode(classExpression, node);
|
|
92328
|
-
ts.setTextRange(classExpression, location);
|
|
92329
|
-
// let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
|
|
92330
|
-
// or decoratedClassAlias if the class contain self-reference.
|
|
92331
|
-
var statement = factory.createVariableStatement(
|
|
92332
|
-
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
92333
|
-
factory.createVariableDeclaration(declName,
|
|
92334
|
-
/*exclamationToken*/ undefined,
|
|
92335
|
-
/*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
|
|
92336
|
-
], 1 /* Let */));
|
|
92337
|
-
ts.setOriginalNode(statement, node);
|
|
92338
|
-
ts.setTextRange(statement, location);
|
|
92339
|
-
ts.setCommentRange(statement, node);
|
|
92340
|
-
return statement;
|
|
92341
|
-
}
|
|
92342
92352
|
function visitClassExpression(node) {
|
|
92343
|
-
|
|
92344
|
-
|
|
92345
|
-
|
|
92346
|
-
var classExpression = factory.createClassExpression(
|
|
92347
|
-
/*decorators*/ undefined,
|
|
92353
|
+
var allDecorators = getAllDecoratorsOfConstructor(node);
|
|
92354
|
+
var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
|
|
92355
|
+
return factory.updateClassExpression(node, decorators,
|
|
92348
92356
|
/*modifiers*/ undefined, node.name,
|
|
92349
|
-
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause),
|
|
92350
|
-
|
|
92351
|
-
|
|
92352
|
-
return classExpression;
|
|
92357
|
+
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), isClassLikeDeclarationWithTypeScriptSyntax(node) ?
|
|
92358
|
+
transformClassMembers(node) :
|
|
92359
|
+
ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
|
|
92353
92360
|
}
|
|
92354
92361
|
/**
|
|
92355
92362
|
* Transforms the members of a class.
|
|
@@ -92374,48 +92381,9 @@ var ts;
|
|
|
92374
92381
|
}
|
|
92375
92382
|
}
|
|
92376
92383
|
}
|
|
92377
|
-
ts.addRange(members, ts.visitNodes(node.members,
|
|
92384
|
+
ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
|
|
92378
92385
|
return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
|
|
92379
92386
|
}
|
|
92380
|
-
/**
|
|
92381
|
-
* Gets either the static or instance members of a class that are decorated, or have
|
|
92382
|
-
* parameters that are decorated.
|
|
92383
|
-
*
|
|
92384
|
-
* @param node The class containing the member.
|
|
92385
|
-
* @param isStatic A value indicating whether to retrieve static or instance members of
|
|
92386
|
-
* the class.
|
|
92387
|
-
*/
|
|
92388
|
-
function getDecoratedClassElements(node, isStatic) {
|
|
92389
|
-
return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
|
|
92390
|
-
}
|
|
92391
|
-
/**
|
|
92392
|
-
* Determines whether a class member is a static member of a class that is decorated, or
|
|
92393
|
-
* has parameters that are decorated.
|
|
92394
|
-
*
|
|
92395
|
-
* @param member The class member.
|
|
92396
|
-
*/
|
|
92397
|
-
function isStaticDecoratedClassElement(member, parent) {
|
|
92398
|
-
return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
|
|
92399
|
-
}
|
|
92400
|
-
/**
|
|
92401
|
-
* Determines whether a class member is an instance member of a class that is decorated,
|
|
92402
|
-
* or has parameters that are decorated.
|
|
92403
|
-
*
|
|
92404
|
-
* @param member The class member.
|
|
92405
|
-
*/
|
|
92406
|
-
function isInstanceDecoratedClassElement(member, parent) {
|
|
92407
|
-
return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
|
|
92408
|
-
}
|
|
92409
|
-
/**
|
|
92410
|
-
* Determines whether a class member is either a static or an instance member of a class
|
|
92411
|
-
* that is decorated, or has parameters that are decorated.
|
|
92412
|
-
*
|
|
92413
|
-
* @param member The class member.
|
|
92414
|
-
*/
|
|
92415
|
-
function isDecoratedClassElement(member, isStaticElement, parent) {
|
|
92416
|
-
return ts.nodeOrChildIsDecorated(member, parent)
|
|
92417
|
-
&& isStaticElement === ts.isStatic(member);
|
|
92418
|
-
}
|
|
92419
92387
|
/**
|
|
92420
92388
|
* Gets an array of arrays of decorators for the parameters of a function-like node.
|
|
92421
92389
|
* The offset into the result array should correspond to the offset of the parameter.
|
|
@@ -92461,14 +92429,14 @@ var ts;
|
|
|
92461
92429
|
/**
|
|
92462
92430
|
* Gets an AllDecorators object containing the decorators for the member and its parameters.
|
|
92463
92431
|
*
|
|
92464
|
-
* @param
|
|
92432
|
+
* @param parent The class node that contains the member.
|
|
92465
92433
|
* @param member The class member.
|
|
92466
92434
|
*/
|
|
92467
|
-
function getAllDecoratorsOfClassElement(
|
|
92435
|
+
function getAllDecoratorsOfClassElement(member, parent) {
|
|
92468
92436
|
switch (member.kind) {
|
|
92469
92437
|
case 172 /* GetAccessor */:
|
|
92470
92438
|
case 173 /* SetAccessor */:
|
|
92471
|
-
return getAllDecoratorsOfAccessors(
|
|
92439
|
+
return getAllDecoratorsOfAccessors(parent, member);
|
|
92472
92440
|
case 169 /* MethodDeclaration */:
|
|
92473
92441
|
return getAllDecoratorsOfMethod(member);
|
|
92474
92442
|
case 167 /* PropertyDeclaration */:
|
|
@@ -92537,209 +92505,82 @@ var ts;
|
|
|
92537
92505
|
if (!allDecorators) {
|
|
92538
92506
|
return undefined;
|
|
92539
92507
|
}
|
|
92540
|
-
var
|
|
92541
|
-
|
|
92542
|
-
ts.
|
|
92543
|
-
|
|
92544
|
-
|
|
92545
|
-
|
|
92546
|
-
/**
|
|
92547
|
-
* Generates statements used to apply decorators to either the static or instance members
|
|
92548
|
-
* of a class.
|
|
92549
|
-
*
|
|
92550
|
-
* @param node The class node.
|
|
92551
|
-
* @param isStatic A value indicating whether to generate statements for static or
|
|
92552
|
-
* instance members.
|
|
92553
|
-
*/
|
|
92554
|
-
function addClassElementDecorationStatements(statements, node, isStatic) {
|
|
92555
|
-
ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
|
|
92556
|
-
}
|
|
92557
|
-
/**
|
|
92558
|
-
* Generates expressions used to apply decorators to either the static or instance members
|
|
92559
|
-
* of a class.
|
|
92560
|
-
*
|
|
92561
|
-
* @param node The class node.
|
|
92562
|
-
* @param isStatic A value indicating whether to generate expressions for static or
|
|
92563
|
-
* instance members.
|
|
92564
|
-
*/
|
|
92565
|
-
function generateClassElementDecorationExpressions(node, isStatic) {
|
|
92566
|
-
var members = getDecoratedClassElements(node, isStatic);
|
|
92567
|
-
var expressions;
|
|
92568
|
-
for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
|
|
92569
|
-
var member = members_8[_i];
|
|
92570
|
-
var expression = generateClassElementDecorationExpression(node, member);
|
|
92571
|
-
if (expression) {
|
|
92572
|
-
if (!expressions) {
|
|
92573
|
-
expressions = [expression];
|
|
92574
|
-
}
|
|
92575
|
-
else {
|
|
92576
|
-
expressions.push(expression);
|
|
92577
|
-
}
|
|
92578
|
-
}
|
|
92579
|
-
}
|
|
92580
|
-
return expressions;
|
|
92581
|
-
}
|
|
92582
|
-
/**
|
|
92583
|
-
* Generates an expression used to evaluate class element decorators at runtime.
|
|
92584
|
-
*
|
|
92585
|
-
* @param node The class node that contains the member.
|
|
92586
|
-
* @param member The class member.
|
|
92587
|
-
*/
|
|
92588
|
-
function generateClassElementDecorationExpression(node, member) {
|
|
92589
|
-
var allDecorators = getAllDecoratorsOfClassElement(node, member);
|
|
92590
|
-
var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
|
|
92591
|
-
if (!decoratorExpressions) {
|
|
92592
|
-
return undefined;
|
|
92593
|
-
}
|
|
92594
|
-
// Emit the call to __decorate. Given the following:
|
|
92595
|
-
//
|
|
92596
|
-
// class C {
|
|
92597
|
-
// @dec method(@dec2 x) {}
|
|
92598
|
-
// @dec get accessor() {}
|
|
92599
|
-
// @dec prop;
|
|
92600
|
-
// }
|
|
92601
|
-
//
|
|
92602
|
-
// The emit for a method is:
|
|
92603
|
-
//
|
|
92604
|
-
// __decorate([
|
|
92605
|
-
// dec,
|
|
92606
|
-
// __param(0, dec2),
|
|
92607
|
-
// __metadata("design:type", Function),
|
|
92608
|
-
// __metadata("design:paramtypes", [Object]),
|
|
92609
|
-
// __metadata("design:returntype", void 0)
|
|
92610
|
-
// ], C.prototype, "method", null);
|
|
92611
|
-
//
|
|
92612
|
-
// The emit for an accessor is:
|
|
92613
|
-
//
|
|
92614
|
-
// __decorate([
|
|
92615
|
-
// dec
|
|
92616
|
-
// ], C.prototype, "accessor", null);
|
|
92617
|
-
//
|
|
92618
|
-
// The emit for a property is:
|
|
92619
|
-
//
|
|
92620
|
-
// __decorate([
|
|
92621
|
-
// dec
|
|
92622
|
-
// ], C.prototype, "prop");
|
|
92623
|
-
//
|
|
92624
|
-
var prefix = getClassMemberPrefix(node, member);
|
|
92625
|
-
var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
|
|
92626
|
-
var descriptor = languageVersion > 0 /* ES3 */
|
|
92627
|
-
? member.kind === 167 /* PropertyDeclaration */
|
|
92628
|
-
// We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
|
|
92629
|
-
// should not invoke `Object.getOwnPropertyDescriptor`.
|
|
92630
|
-
? factory.createVoidZero()
|
|
92631
|
-
// We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
|
|
92632
|
-
// We have this extra argument here so that we can inject an explicit property descriptor at a later date.
|
|
92633
|
-
: factory.createNull()
|
|
92634
|
-
: undefined;
|
|
92635
|
-
var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
|
|
92636
|
-
ts.setTextRange(helper, ts.moveRangePastDecorators(member));
|
|
92637
|
-
ts.setEmitFlags(helper, 1536 /* NoComments */);
|
|
92638
|
-
return helper;
|
|
92639
|
-
}
|
|
92640
|
-
/**
|
|
92641
|
-
* Generates a __decorate helper call for a class constructor.
|
|
92642
|
-
*
|
|
92643
|
-
* @param node The class node.
|
|
92644
|
-
*/
|
|
92645
|
-
function addConstructorDecorationStatement(statements, node) {
|
|
92646
|
-
var expression = generateConstructorDecorationExpression(node);
|
|
92647
|
-
if (expression) {
|
|
92648
|
-
statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
|
|
92649
|
-
}
|
|
92650
|
-
}
|
|
92651
|
-
/**
|
|
92652
|
-
* Generates a __decorate helper call for a class constructor.
|
|
92653
|
-
*
|
|
92654
|
-
* @param node The class node.
|
|
92655
|
-
*/
|
|
92656
|
-
function generateConstructorDecorationExpression(node) {
|
|
92657
|
-
var allDecorators = getAllDecoratorsOfConstructor(node);
|
|
92658
|
-
var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
|
|
92659
|
-
if (!decoratorExpressions) {
|
|
92660
|
-
return undefined;
|
|
92661
|
-
}
|
|
92662
|
-
var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
|
|
92663
|
-
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
|
92664
|
-
// without any block-scoped variable collision handling
|
|
92665
|
-
var localName = languageVersion <= 2 /* ES2015 */ ?
|
|
92666
|
-
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
|
92667
|
-
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
|
92668
|
-
var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
|
|
92669
|
-
var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
|
|
92670
|
-
ts.setEmitFlags(expression, 1536 /* NoComments */);
|
|
92671
|
-
ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
|
|
92672
|
-
return expression;
|
|
92673
|
-
}
|
|
92674
|
-
/**
|
|
92675
|
-
* Transforms a decorator into an expression.
|
|
92676
|
-
*
|
|
92677
|
-
* @param decorator The decorator node.
|
|
92678
|
-
*/
|
|
92679
|
-
function transformDecorator(decorator) {
|
|
92680
|
-
return ts.visitNode(decorator.expression, visitor, ts.isExpression);
|
|
92508
|
+
var decorators = ts.visitNodes(allDecorators.decorators, visitor, ts.isDecorator);
|
|
92509
|
+
var parameterDecorators = ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter);
|
|
92510
|
+
var metadataDecorators = ts.some(decorators) || ts.some(parameterDecorators) ? getTypeMetadata(node, container) : undefined;
|
|
92511
|
+
var result = factory.createNodeArray(ts.concatenate(ts.concatenate(decorators, parameterDecorators), metadataDecorators));
|
|
92512
|
+
ts.setTextRange(result, decorators);
|
|
92513
|
+
return result;
|
|
92681
92514
|
}
|
|
92682
92515
|
/**
|
|
92683
|
-
* Transforms the decorators of a parameter.
|
|
92516
|
+
* Transforms the decorators of a parameter into decorators of the class/method.
|
|
92684
92517
|
*
|
|
92685
|
-
* @param
|
|
92518
|
+
* @param parameterDecorators The decorators for the parameter at the provided offset.
|
|
92686
92519
|
* @param parameterOffset The offset of the parameter.
|
|
92687
92520
|
*/
|
|
92688
|
-
function transformDecoratorsOfParameter(
|
|
92689
|
-
|
|
92690
|
-
|
|
92691
|
-
|
|
92692
|
-
|
|
92693
|
-
var
|
|
92694
|
-
var helper = emitHelpers().createParamHelper(
|
|
92695
|
-
ts.setTextRange(helper,
|
|
92521
|
+
function transformDecoratorsOfParameter(parameterDecorators, parameterOffset) {
|
|
92522
|
+
if (parameterDecorators) {
|
|
92523
|
+
var decorators = [];
|
|
92524
|
+
for (var _i = 0, parameterDecorators_1 = parameterDecorators; _i < parameterDecorators_1.length; _i++) {
|
|
92525
|
+
var parameterDecorator = parameterDecorators_1[_i];
|
|
92526
|
+
var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression);
|
|
92527
|
+
var helper = emitHelpers().createParamHelper(expression, parameterOffset);
|
|
92528
|
+
ts.setTextRange(helper, parameterDecorator.expression);
|
|
92696
92529
|
ts.setEmitFlags(helper, 1536 /* NoComments */);
|
|
92697
|
-
|
|
92530
|
+
var decorator = factory.createDecorator(helper);
|
|
92531
|
+
ts.setTextRange(decorator, parameterDecorator.expression);
|
|
92532
|
+
ts.setEmitFlags(decorator, 1536 /* NoComments */);
|
|
92533
|
+
decorators.push(decorator);
|
|
92698
92534
|
}
|
|
92535
|
+
return decorators;
|
|
92699
92536
|
}
|
|
92700
|
-
return expressions;
|
|
92701
92537
|
}
|
|
92702
92538
|
/**
|
|
92703
|
-
*
|
|
92539
|
+
* Gets optional type metadata for a declaration.
|
|
92704
92540
|
*
|
|
92705
92541
|
* @param node The declaration node.
|
|
92706
|
-
* @param decoratorExpressions The destination array to which to add new decorator expressions.
|
|
92707
92542
|
*/
|
|
92708
|
-
function
|
|
92709
|
-
|
|
92710
|
-
|
|
92711
|
-
|
|
92712
|
-
else {
|
|
92713
|
-
addOldTypeMetadata(node, container, decoratorExpressions);
|
|
92714
|
-
}
|
|
92543
|
+
function getTypeMetadata(node, container) {
|
|
92544
|
+
return USE_NEW_TYPE_METADATA_FORMAT ?
|
|
92545
|
+
getNewTypeMetadata(node, container) :
|
|
92546
|
+
getOldTypeMetadata(node, container);
|
|
92715
92547
|
}
|
|
92716
|
-
function
|
|
92717
|
-
if (
|
|
92548
|
+
function getOldTypeMetadata(node, container) {
|
|
92549
|
+
if (typeSerializer) {
|
|
92550
|
+
var decorators = void 0;
|
|
92718
92551
|
if (shouldAddTypeMetadata(node)) {
|
|
92719
|
-
|
|
92552
|
+
var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
|
|
92553
|
+
decorators = ts.append(decorators, factory.createDecorator(typeMetadata));
|
|
92720
92554
|
}
|
|
92721
92555
|
if (shouldAddParamTypesMetadata(node)) {
|
|
92722
|
-
|
|
92556
|
+
var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container));
|
|
92557
|
+
decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata));
|
|
92723
92558
|
}
|
|
92724
92559
|
if (shouldAddReturnTypeMetadata(node)) {
|
|
92725
|
-
|
|
92560
|
+
var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
|
|
92561
|
+
decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata));
|
|
92726
92562
|
}
|
|
92563
|
+
return decorators;
|
|
92727
92564
|
}
|
|
92728
92565
|
}
|
|
92729
|
-
function
|
|
92730
|
-
if (
|
|
92566
|
+
function getNewTypeMetadata(node, container) {
|
|
92567
|
+
if (typeSerializer) {
|
|
92731
92568
|
var properties = void 0;
|
|
92732
92569
|
if (shouldAddTypeMetadata(node)) {
|
|
92733
|
-
|
|
92570
|
+
var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
|
|
92571
|
+
properties = ts.append(properties, typeProperty);
|
|
92734
92572
|
}
|
|
92735
92573
|
if (shouldAddParamTypesMetadata(node)) {
|
|
92736
|
-
|
|
92574
|
+
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)));
|
|
92575
|
+
properties = ts.append(properties, paramTypeProperty);
|
|
92737
92576
|
}
|
|
92738
92577
|
if (shouldAddReturnTypeMetadata(node)) {
|
|
92739
|
-
|
|
92578
|
+
var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
|
|
92579
|
+
properties = ts.append(properties, returnTypeProperty);
|
|
92740
92580
|
}
|
|
92741
92581
|
if (properties) {
|
|
92742
|
-
|
|
92582
|
+
var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true));
|
|
92583
|
+
return [factory.createDecorator(typeInfoMetadata)];
|
|
92743
92584
|
}
|
|
92744
92585
|
}
|
|
92745
92586
|
}
|
|
@@ -92786,347 +92627,6 @@ var ts;
|
|
|
92786
92627
|
}
|
|
92787
92628
|
return false;
|
|
92788
92629
|
}
|
|
92789
|
-
function getAccessorTypeNode(node) {
|
|
92790
|
-
var accessors = resolver.getAllAccessorDeclarations(node);
|
|
92791
|
-
return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
|
|
92792
|
-
|| accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
|
|
92793
|
-
}
|
|
92794
|
-
/**
|
|
92795
|
-
* Serializes the type of a node for use with decorator type metadata.
|
|
92796
|
-
*
|
|
92797
|
-
* @param node The node that should have its type serialized.
|
|
92798
|
-
*/
|
|
92799
|
-
function serializeTypeOfNode(node) {
|
|
92800
|
-
switch (node.kind) {
|
|
92801
|
-
case 167 /* PropertyDeclaration */:
|
|
92802
|
-
case 164 /* Parameter */:
|
|
92803
|
-
return serializeTypeNode(node.type);
|
|
92804
|
-
case 173 /* SetAccessor */:
|
|
92805
|
-
case 172 /* GetAccessor */:
|
|
92806
|
-
return serializeTypeNode(getAccessorTypeNode(node));
|
|
92807
|
-
case 257 /* ClassDeclaration */:
|
|
92808
|
-
case 226 /* ClassExpression */:
|
|
92809
|
-
case 169 /* MethodDeclaration */:
|
|
92810
|
-
return factory.createIdentifier("Function");
|
|
92811
|
-
default:
|
|
92812
|
-
return factory.createVoidZero();
|
|
92813
|
-
}
|
|
92814
|
-
}
|
|
92815
|
-
/**
|
|
92816
|
-
* Serializes the types of the parameters of a node for use with decorator type metadata.
|
|
92817
|
-
*
|
|
92818
|
-
* @param node The node that should have its parameter types serialized.
|
|
92819
|
-
*/
|
|
92820
|
-
function serializeParameterTypesOfNode(node, container) {
|
|
92821
|
-
var valueDeclaration = ts.isClassLike(node)
|
|
92822
|
-
? ts.getFirstConstructorWithBody(node)
|
|
92823
|
-
: ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
|
|
92824
|
-
? node
|
|
92825
|
-
: undefined;
|
|
92826
|
-
var expressions = [];
|
|
92827
|
-
if (valueDeclaration) {
|
|
92828
|
-
var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
|
|
92829
|
-
var numParameters = parameters.length;
|
|
92830
|
-
for (var i = 0; i < numParameters; i++) {
|
|
92831
|
-
var parameter = parameters[i];
|
|
92832
|
-
if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
|
|
92833
|
-
continue;
|
|
92834
|
-
}
|
|
92835
|
-
if (parameter.dotDotDotToken) {
|
|
92836
|
-
expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
|
|
92837
|
-
}
|
|
92838
|
-
else {
|
|
92839
|
-
expressions.push(serializeTypeOfNode(parameter));
|
|
92840
|
-
}
|
|
92841
|
-
}
|
|
92842
|
-
}
|
|
92843
|
-
return factory.createArrayLiteralExpression(expressions);
|
|
92844
|
-
}
|
|
92845
|
-
function getParametersOfDecoratedDeclaration(node, container) {
|
|
92846
|
-
if (container && node.kind === 172 /* GetAccessor */) {
|
|
92847
|
-
var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
|
|
92848
|
-
if (setAccessor) {
|
|
92849
|
-
return setAccessor.parameters;
|
|
92850
|
-
}
|
|
92851
|
-
}
|
|
92852
|
-
return node.parameters;
|
|
92853
|
-
}
|
|
92854
|
-
/**
|
|
92855
|
-
* Serializes the return type of a node for use with decorator type metadata.
|
|
92856
|
-
*
|
|
92857
|
-
* @param node The node that should have its return type serialized.
|
|
92858
|
-
*/
|
|
92859
|
-
function serializeReturnTypeOfNode(node) {
|
|
92860
|
-
if (ts.isFunctionLike(node) && node.type) {
|
|
92861
|
-
return serializeTypeNode(node.type);
|
|
92862
|
-
}
|
|
92863
|
-
else if (ts.isAsyncFunction(node)) {
|
|
92864
|
-
return factory.createIdentifier("Promise");
|
|
92865
|
-
}
|
|
92866
|
-
return factory.createVoidZero();
|
|
92867
|
-
}
|
|
92868
|
-
/**
|
|
92869
|
-
* Serializes a type node for use with decorator type metadata.
|
|
92870
|
-
*
|
|
92871
|
-
* Types are serialized in the following fashion:
|
|
92872
|
-
* - Void types point to "undefined" (e.g. "void 0")
|
|
92873
|
-
* - Function and Constructor types point to the global "Function" constructor.
|
|
92874
|
-
* - Interface types with a call or construct signature types point to the global
|
|
92875
|
-
* "Function" constructor.
|
|
92876
|
-
* - Array and Tuple types point to the global "Array" constructor.
|
|
92877
|
-
* - Type predicates and booleans point to the global "Boolean" constructor.
|
|
92878
|
-
* - String literal types and strings point to the global "String" constructor.
|
|
92879
|
-
* - Enum and number types point to the global "Number" constructor.
|
|
92880
|
-
* - Symbol types point to the global "Symbol" constructor.
|
|
92881
|
-
* - Type references to classes (or class-like variables) point to the constructor for the class.
|
|
92882
|
-
* - Anything else points to the global "Object" constructor.
|
|
92883
|
-
*
|
|
92884
|
-
* @param node The type node to serialize.
|
|
92885
|
-
*/
|
|
92886
|
-
function serializeTypeNode(node) {
|
|
92887
|
-
if (node === undefined) {
|
|
92888
|
-
return factory.createIdentifier("Object");
|
|
92889
|
-
}
|
|
92890
|
-
switch (node.kind) {
|
|
92891
|
-
case 114 /* VoidKeyword */:
|
|
92892
|
-
case 153 /* UndefinedKeyword */:
|
|
92893
|
-
case 143 /* NeverKeyword */:
|
|
92894
|
-
return factory.createVoidZero();
|
|
92895
|
-
case 191 /* ParenthesizedType */:
|
|
92896
|
-
return serializeTypeNode(node.type);
|
|
92897
|
-
case 179 /* FunctionType */:
|
|
92898
|
-
case 180 /* ConstructorType */:
|
|
92899
|
-
return factory.createIdentifier("Function");
|
|
92900
|
-
case 183 /* ArrayType */:
|
|
92901
|
-
case 184 /* TupleType */:
|
|
92902
|
-
return factory.createIdentifier("Array");
|
|
92903
|
-
case 177 /* TypePredicate */:
|
|
92904
|
-
case 133 /* BooleanKeyword */:
|
|
92905
|
-
return factory.createIdentifier("Boolean");
|
|
92906
|
-
case 198 /* TemplateLiteralType */:
|
|
92907
|
-
case 150 /* StringKeyword */:
|
|
92908
|
-
return factory.createIdentifier("String");
|
|
92909
|
-
case 148 /* ObjectKeyword */:
|
|
92910
|
-
return factory.createIdentifier("Object");
|
|
92911
|
-
case 196 /* LiteralType */:
|
|
92912
|
-
switch (node.literal.kind) {
|
|
92913
|
-
case 10 /* StringLiteral */:
|
|
92914
|
-
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
92915
|
-
return factory.createIdentifier("String");
|
|
92916
|
-
case 219 /* PrefixUnaryExpression */:
|
|
92917
|
-
case 8 /* NumericLiteral */:
|
|
92918
|
-
return factory.createIdentifier("Number");
|
|
92919
|
-
case 9 /* BigIntLiteral */:
|
|
92920
|
-
return getGlobalBigIntNameWithFallback();
|
|
92921
|
-
case 110 /* TrueKeyword */:
|
|
92922
|
-
case 95 /* FalseKeyword */:
|
|
92923
|
-
return factory.createIdentifier("Boolean");
|
|
92924
|
-
case 104 /* NullKeyword */:
|
|
92925
|
-
return factory.createVoidZero();
|
|
92926
|
-
default:
|
|
92927
|
-
return ts.Debug.failBadSyntaxKind(node.literal);
|
|
92928
|
-
}
|
|
92929
|
-
case 147 /* NumberKeyword */:
|
|
92930
|
-
return factory.createIdentifier("Number");
|
|
92931
|
-
case 158 /* BigIntKeyword */:
|
|
92932
|
-
return getGlobalBigIntNameWithFallback();
|
|
92933
|
-
case 151 /* SymbolKeyword */:
|
|
92934
|
-
return languageVersion < 2 /* ES2015 */
|
|
92935
|
-
? getGlobalSymbolNameWithFallback()
|
|
92936
|
-
: factory.createIdentifier("Symbol");
|
|
92937
|
-
case 178 /* TypeReference */:
|
|
92938
|
-
return serializeTypeReferenceNode(node);
|
|
92939
|
-
case 188 /* IntersectionType */:
|
|
92940
|
-
case 187 /* UnionType */:
|
|
92941
|
-
return serializeTypeList(node.types);
|
|
92942
|
-
case 189 /* ConditionalType */:
|
|
92943
|
-
return serializeTypeList([node.trueType, node.falseType]);
|
|
92944
|
-
case 193 /* TypeOperator */:
|
|
92945
|
-
if (node.operator === 145 /* ReadonlyKeyword */) {
|
|
92946
|
-
return serializeTypeNode(node.type);
|
|
92947
|
-
}
|
|
92948
|
-
break;
|
|
92949
|
-
case 181 /* TypeQuery */:
|
|
92950
|
-
case 194 /* IndexedAccessType */:
|
|
92951
|
-
case 195 /* MappedType */:
|
|
92952
|
-
case 182 /* TypeLiteral */:
|
|
92953
|
-
case 130 /* AnyKeyword */:
|
|
92954
|
-
case 155 /* UnknownKeyword */:
|
|
92955
|
-
case 192 /* ThisType */:
|
|
92956
|
-
case 200 /* ImportType */:
|
|
92957
|
-
break;
|
|
92958
|
-
// handle JSDoc types from an invalid parse
|
|
92959
|
-
case 312 /* JSDocAllType */:
|
|
92960
|
-
case 313 /* JSDocUnknownType */:
|
|
92961
|
-
case 317 /* JSDocFunctionType */:
|
|
92962
|
-
case 318 /* JSDocVariadicType */:
|
|
92963
|
-
case 319 /* JSDocNamepathType */:
|
|
92964
|
-
break;
|
|
92965
|
-
case 314 /* JSDocNullableType */:
|
|
92966
|
-
case 315 /* JSDocNonNullableType */:
|
|
92967
|
-
case 316 /* JSDocOptionalType */:
|
|
92968
|
-
return serializeTypeNode(node.type);
|
|
92969
|
-
default:
|
|
92970
|
-
return ts.Debug.failBadSyntaxKind(node);
|
|
92971
|
-
}
|
|
92972
|
-
return factory.createIdentifier("Object");
|
|
92973
|
-
}
|
|
92974
|
-
function serializeTypeList(types) {
|
|
92975
|
-
// Note when updating logic here also update getEntityNameForDecoratorMetadata
|
|
92976
|
-
// so that aliases can be marked as referenced
|
|
92977
|
-
var serializedUnion;
|
|
92978
|
-
for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
|
|
92979
|
-
var typeNode = types_22[_i];
|
|
92980
|
-
while (typeNode.kind === 191 /* ParenthesizedType */) {
|
|
92981
|
-
typeNode = typeNode.type; // Skip parens if need be
|
|
92982
|
-
}
|
|
92983
|
-
if (typeNode.kind === 143 /* NeverKeyword */) {
|
|
92984
|
-
continue; // Always elide `never` from the union/intersection if possible
|
|
92985
|
-
}
|
|
92986
|
-
if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) {
|
|
92987
|
-
continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
|
|
92988
|
-
}
|
|
92989
|
-
var serializedIndividual = serializeTypeNode(typeNode);
|
|
92990
|
-
if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
|
|
92991
|
-
// One of the individual is global object, return immediately
|
|
92992
|
-
return serializedIndividual;
|
|
92993
|
-
}
|
|
92994
|
-
// If there exists union that is not void 0 expression, check if the the common type is identifier.
|
|
92995
|
-
// anything more complex and we will just default to Object
|
|
92996
|
-
else if (serializedUnion) {
|
|
92997
|
-
// Different types
|
|
92998
|
-
if (!ts.isIdentifier(serializedUnion) ||
|
|
92999
|
-
!ts.isIdentifier(serializedIndividual) ||
|
|
93000
|
-
serializedUnion.escapedText !== serializedIndividual.escapedText) {
|
|
93001
|
-
return factory.createIdentifier("Object");
|
|
93002
|
-
}
|
|
93003
|
-
}
|
|
93004
|
-
else {
|
|
93005
|
-
// Initialize the union type
|
|
93006
|
-
serializedUnion = serializedIndividual;
|
|
93007
|
-
}
|
|
93008
|
-
}
|
|
93009
|
-
// If we were able to find common type, use it
|
|
93010
|
-
return serializedUnion || factory.createVoidZero(); // Fallback is only hit if all union constituients are null/undefined/never
|
|
93011
|
-
}
|
|
93012
|
-
/**
|
|
93013
|
-
* Serializes a TypeReferenceNode to an appropriate JS constructor value for use with
|
|
93014
|
-
* decorator type metadata.
|
|
93015
|
-
*
|
|
93016
|
-
* @param node The type reference node.
|
|
93017
|
-
*/
|
|
93018
|
-
function serializeTypeReferenceNode(node) {
|
|
93019
|
-
var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
|
|
93020
|
-
switch (kind) {
|
|
93021
|
-
case ts.TypeReferenceSerializationKind.Unknown:
|
|
93022
|
-
// From conditional type type reference that cannot be resolved is Similar to any or unknown
|
|
93023
|
-
if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
|
|
93024
|
-
return factory.createIdentifier("Object");
|
|
93025
|
-
}
|
|
93026
|
-
var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
|
|
93027
|
-
var temp = factory.createTempVariable(hoistVariableDeclaration);
|
|
93028
|
-
return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"),
|
|
93029
|
-
/*questionToken*/ undefined, temp,
|
|
93030
|
-
/*colonToken*/ undefined, factory.createIdentifier("Object"));
|
|
93031
|
-
case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
|
|
93032
|
-
return serializeEntityNameAsExpression(node.typeName);
|
|
93033
|
-
case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
|
|
93034
|
-
return factory.createVoidZero();
|
|
93035
|
-
case ts.TypeReferenceSerializationKind.BigIntLikeType:
|
|
93036
|
-
return getGlobalBigIntNameWithFallback();
|
|
93037
|
-
case ts.TypeReferenceSerializationKind.BooleanType:
|
|
93038
|
-
return factory.createIdentifier("Boolean");
|
|
93039
|
-
case ts.TypeReferenceSerializationKind.NumberLikeType:
|
|
93040
|
-
return factory.createIdentifier("Number");
|
|
93041
|
-
case ts.TypeReferenceSerializationKind.StringLikeType:
|
|
93042
|
-
return factory.createIdentifier("String");
|
|
93043
|
-
case ts.TypeReferenceSerializationKind.ArrayLikeType:
|
|
93044
|
-
return factory.createIdentifier("Array");
|
|
93045
|
-
case ts.TypeReferenceSerializationKind.ESSymbolType:
|
|
93046
|
-
return languageVersion < 2 /* ES2015 */
|
|
93047
|
-
? getGlobalSymbolNameWithFallback()
|
|
93048
|
-
: factory.createIdentifier("Symbol");
|
|
93049
|
-
case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
|
|
93050
|
-
return factory.createIdentifier("Function");
|
|
93051
|
-
case ts.TypeReferenceSerializationKind.Promise:
|
|
93052
|
-
return factory.createIdentifier("Promise");
|
|
93053
|
-
case ts.TypeReferenceSerializationKind.ObjectType:
|
|
93054
|
-
return factory.createIdentifier("Object");
|
|
93055
|
-
default:
|
|
93056
|
-
return ts.Debug.assertNever(kind);
|
|
93057
|
-
}
|
|
93058
|
-
}
|
|
93059
|
-
function createCheckedValue(left, right) {
|
|
93060
|
-
return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
|
|
93061
|
-
}
|
|
93062
|
-
/**
|
|
93063
|
-
* Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
|
|
93064
|
-
*
|
|
93065
|
-
* @param node The entity name to serialize.
|
|
93066
|
-
*/
|
|
93067
|
-
function serializeEntityNameAsExpressionFallback(node) {
|
|
93068
|
-
if (node.kind === 79 /* Identifier */) {
|
|
93069
|
-
// A -> typeof A !== undefined && A
|
|
93070
|
-
var copied = serializeEntityNameAsExpression(node);
|
|
93071
|
-
return createCheckedValue(copied, copied);
|
|
93072
|
-
}
|
|
93073
|
-
if (node.left.kind === 79 /* Identifier */) {
|
|
93074
|
-
// A.B -> typeof A !== undefined && A.B
|
|
93075
|
-
return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
|
|
93076
|
-
}
|
|
93077
|
-
// A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C
|
|
93078
|
-
var left = serializeEntityNameAsExpressionFallback(node.left);
|
|
93079
|
-
var temp = factory.createTempVariable(hoistVariableDeclaration);
|
|
93080
|
-
return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
|
|
93081
|
-
}
|
|
93082
|
-
/**
|
|
93083
|
-
* Serializes an entity name as an expression for decorator type metadata.
|
|
93084
|
-
*
|
|
93085
|
-
* @param node The entity name to serialize.
|
|
93086
|
-
*/
|
|
93087
|
-
function serializeEntityNameAsExpression(node) {
|
|
93088
|
-
switch (node.kind) {
|
|
93089
|
-
case 79 /* Identifier */:
|
|
93090
|
-
// Create a clone of the name with a new parent, and treat it as if it were
|
|
93091
|
-
// a source tree node for the purposes of the checker.
|
|
93092
|
-
var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
|
|
93093
|
-
name.original = undefined;
|
|
93094
|
-
ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
|
|
93095
|
-
return name;
|
|
93096
|
-
case 161 /* QualifiedName */:
|
|
93097
|
-
return serializeQualifiedNameAsExpression(node);
|
|
93098
|
-
}
|
|
93099
|
-
}
|
|
93100
|
-
/**
|
|
93101
|
-
* Serializes an qualified name as an expression for decorator type metadata.
|
|
93102
|
-
*
|
|
93103
|
-
* @param node The qualified name to serialize.
|
|
93104
|
-
* @param useFallback A value indicating whether to use logical operators to test for the
|
|
93105
|
-
* qualified name at runtime.
|
|
93106
|
-
*/
|
|
93107
|
-
function serializeQualifiedNameAsExpression(node) {
|
|
93108
|
-
return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
|
|
93109
|
-
}
|
|
93110
|
-
/**
|
|
93111
|
-
* Gets an expression that points to the global "Symbol" constructor at runtime if it is
|
|
93112
|
-
* available.
|
|
93113
|
-
*/
|
|
93114
|
-
function getGlobalSymbolNameWithFallback() {
|
|
93115
|
-
return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"),
|
|
93116
|
-
/*questionToken*/ undefined, factory.createIdentifier("Symbol"),
|
|
93117
|
-
/*colonToken*/ undefined, factory.createIdentifier("Object"));
|
|
93118
|
-
}
|
|
93119
|
-
/**
|
|
93120
|
-
* Gets an expression that points to the global "BigInt" constructor at runtime if it is
|
|
93121
|
-
* available.
|
|
93122
|
-
*/
|
|
93123
|
-
function getGlobalBigIntNameWithFallback() {
|
|
93124
|
-
return languageVersion < 99 /* ESNext */
|
|
93125
|
-
? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
|
|
93126
|
-
/*questionToken*/ undefined, factory.createIdentifier("BigInt"),
|
|
93127
|
-
/*colonToken*/ undefined, factory.createIdentifier("Object"))
|
|
93128
|
-
: factory.createIdentifier("BigInt");
|
|
93129
|
-
}
|
|
93130
92630
|
/**
|
|
93131
92631
|
* Gets an expression that represents a property name (for decorated properties or enums).
|
|
93132
92632
|
* For a computed property, a name is generated for the node.
|
|
@@ -93211,21 +92711,23 @@ var ts;
|
|
|
93211
92711
|
function shouldEmitFunctionLikeDeclaration(node) {
|
|
93212
92712
|
return !ts.nodeIsMissing(node.body);
|
|
93213
92713
|
}
|
|
93214
|
-
function visitPropertyDeclaration(node) {
|
|
93215
|
-
|
|
92714
|
+
function visitPropertyDeclaration(node, parent) {
|
|
92715
|
+
var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */);
|
|
92716
|
+
if (isAmbient && !ts.some(node.decorators)) {
|
|
93216
92717
|
return undefined;
|
|
93217
92718
|
}
|
|
93218
|
-
var
|
|
93219
|
-
|
|
92719
|
+
var allDecorators = getAllDecoratorsOfClassElement(node, parent);
|
|
92720
|
+
var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators);
|
|
92721
|
+
// Preserve a `declare x` property with decorators to be handled by the decorators transform
|
|
92722
|
+
if (isAmbient) {
|
|
92723
|
+
return factory.updatePropertyDeclaration(node, decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */), ts.visitNode(node.name, visitor, ts.isPropertyName),
|
|
92724
|
+
/*questionOrExclamationToken*/ undefined,
|
|
92725
|
+
/*type*/ undefined,
|
|
92726
|
+
/*initializer*/ undefined);
|
|
92727
|
+
}
|
|
92728
|
+
return factory.updatePropertyDeclaration(node, decorators, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
|
|
93220
92729
|
/*questionOrExclamationToken*/ undefined,
|
|
93221
92730
|
/*type*/ undefined, ts.visitNode(node.initializer, visitor));
|
|
93222
|
-
if (updated !== node) {
|
|
93223
|
-
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
93224
|
-
// we need to emit the comments for the original range.
|
|
93225
|
-
ts.setCommentRange(updated, node);
|
|
93226
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93227
|
-
}
|
|
93228
|
-
return updated;
|
|
93229
92731
|
}
|
|
93230
92732
|
function visitConstructor(node) {
|
|
93231
92733
|
if (!shouldEmitFunctionLikeDeclaration(node)) {
|
|
@@ -93233,7 +92735,7 @@ var ts;
|
|
|
93233
92735
|
}
|
|
93234
92736
|
return factory.updateConstructorDeclaration(node,
|
|
93235
92737
|
/*decorators*/ undefined,
|
|
93236
|
-
/*modifiers*/
|
|
92738
|
+
/*modifiers*/ ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
|
|
93237
92739
|
}
|
|
93238
92740
|
function transformConstructorBody(body, constructor) {
|
|
93239
92741
|
var parametersWithPropertyAssignments = constructor &&
|
|
@@ -93297,22 +92799,19 @@ var ts;
|
|
|
93297
92799
|
ts.setEmitFlags(localName, 1536 /* NoComments */);
|
|
93298
92800
|
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))));
|
|
93299
92801
|
}
|
|
93300
|
-
function visitMethodDeclaration(node) {
|
|
92802
|
+
function visitMethodDeclaration(node, parent) {
|
|
92803
|
+
if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
|
|
92804
|
+
return node;
|
|
92805
|
+
}
|
|
93301
92806
|
if (!shouldEmitFunctionLikeDeclaration(node)) {
|
|
93302
92807
|
return undefined;
|
|
93303
92808
|
}
|
|
93304
|
-
var
|
|
93305
|
-
|
|
92809
|
+
var allDecorators = ts.isClassLike(parent) ? getAllDecoratorsOfClassElement(node, parent) : undefined;
|
|
92810
|
+
var decorators = ts.isClassLike(parent) ? transformAllDecoratorsOfDeclaration(node, parent, allDecorators) : undefined;
|
|
92811
|
+
return factory.updateMethodDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
|
|
93306
92812
|
/*questionToken*/ undefined,
|
|
93307
92813
|
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
|
|
93308
92814
|
/*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context));
|
|
93309
|
-
if (updated !== node) {
|
|
93310
|
-
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
93311
|
-
// we need to emit the comments for the original range.
|
|
93312
|
-
ts.setCommentRange(updated, node);
|
|
93313
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93314
|
-
}
|
|
93315
|
-
return updated;
|
|
93316
92815
|
}
|
|
93317
92816
|
/**
|
|
93318
92817
|
* Determines whether to emit an accessor declaration. We should not emit the
|
|
@@ -93323,34 +92822,30 @@ var ts;
|
|
|
93323
92822
|
function shouldEmitAccessorDeclaration(node) {
|
|
93324
92823
|
return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
|
|
93325
92824
|
}
|
|
93326
|
-
function visitGetAccessor(node) {
|
|
92825
|
+
function visitGetAccessor(node, parent) {
|
|
92826
|
+
if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
|
|
92827
|
+
return node;
|
|
92828
|
+
}
|
|
93327
92829
|
if (!shouldEmitAccessorDeclaration(node)) {
|
|
93328
92830
|
return undefined;
|
|
93329
92831
|
}
|
|
93330
|
-
var
|
|
93331
|
-
|
|
92832
|
+
var decorators = ts.isClassLike(parent) ?
|
|
92833
|
+
transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
|
|
92834
|
+
undefined;
|
|
92835
|
+
return factory.updateGetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
|
|
93332
92836
|
/*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
|
|
93333
|
-
if (updated !== node) {
|
|
93334
|
-
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
93335
|
-
// we need to emit the comments for the original range.
|
|
93336
|
-
ts.setCommentRange(updated, node);
|
|
93337
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93338
|
-
}
|
|
93339
|
-
return updated;
|
|
93340
92837
|
}
|
|
93341
|
-
function visitSetAccessor(node) {
|
|
92838
|
+
function visitSetAccessor(node, parent) {
|
|
92839
|
+
if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
|
|
92840
|
+
return node;
|
|
92841
|
+
}
|
|
93342
92842
|
if (!shouldEmitAccessorDeclaration(node)) {
|
|
93343
92843
|
return undefined;
|
|
93344
92844
|
}
|
|
93345
|
-
var
|
|
93346
|
-
|
|
93347
|
-
|
|
93348
|
-
|
|
93349
|
-
// we need to emit the comments for the original range.
|
|
93350
|
-
ts.setCommentRange(updated, node);
|
|
93351
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93352
|
-
}
|
|
93353
|
-
return updated;
|
|
92845
|
+
var decorators = ts.isClassLike(parent) ?
|
|
92846
|
+
transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
|
|
92847
|
+
undefined;
|
|
92848
|
+
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([]));
|
|
93354
92849
|
}
|
|
93355
92850
|
function visitFunctionDeclaration(node) {
|
|
93356
92851
|
if (!shouldEmitFunctionLikeDeclaration(node)) {
|
|
@@ -93386,9 +92881,9 @@ var ts;
|
|
|
93386
92881
|
if (ts.parameterIsThisKeyword(node)) {
|
|
93387
92882
|
return undefined;
|
|
93388
92883
|
}
|
|
93389
|
-
var updated = factory.updateParameterDeclaration(node,
|
|
93390
|
-
|
|
93391
|
-
|
|
92884
|
+
var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
|
|
92885
|
+
ts.elideNodes(factory, node.modifiers), // preserve positions, if available
|
|
92886
|
+
node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
|
|
93392
92887
|
/*questionToken*/ undefined,
|
|
93393
92888
|
/*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
|
|
93394
92889
|
if (updated !== node) {
|
|
@@ -94084,12 +93579,6 @@ var ts;
|
|
|
94084
93579
|
return isExternalModuleExport(node)
|
|
94085
93580
|
&& ts.hasSyntacticModifier(node, 512 /* Default */);
|
|
94086
93581
|
}
|
|
94087
|
-
/**
|
|
94088
|
-
* Creates a statement for the provided expression. This is used in calls to `map`.
|
|
94089
|
-
*/
|
|
94090
|
-
function expressionToStatement(expression) {
|
|
94091
|
-
return factory.createExpressionStatement(expression);
|
|
94092
|
-
}
|
|
94093
93582
|
function addExportMemberAssignment(statements, node) {
|
|
94094
93583
|
var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node));
|
|
94095
93584
|
ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
|
|
@@ -94121,44 +93610,12 @@ var ts;
|
|
|
94121
93610
|
function getNamespaceContainerName(node) {
|
|
94122
93611
|
return factory.getGeneratedNameForNode(node);
|
|
94123
93612
|
}
|
|
94124
|
-
/**
|
|
94125
|
-
* Gets a local alias for a class declaration if it is a decorated class with an internal
|
|
94126
|
-
* reference to the static side of the class. This is necessary to avoid issues with
|
|
94127
|
-
* double-binding semantics for the class name.
|
|
94128
|
-
*/
|
|
94129
|
-
function getClassAliasIfNeeded(node) {
|
|
94130
|
-
if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
|
|
94131
|
-
enableSubstitutionForClassAliases();
|
|
94132
|
-
var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
|
|
94133
|
-
classAliases[ts.getOriginalNodeId(node)] = classAlias;
|
|
94134
|
-
hoistVariableDeclaration(classAlias);
|
|
94135
|
-
return classAlias;
|
|
94136
|
-
}
|
|
94137
|
-
}
|
|
94138
|
-
function getClassPrototype(node) {
|
|
94139
|
-
return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
|
|
94140
|
-
}
|
|
94141
|
-
function getClassMemberPrefix(node, member) {
|
|
94142
|
-
return ts.isStatic(member)
|
|
94143
|
-
? factory.getDeclarationName(node)
|
|
94144
|
-
: getClassPrototype(node);
|
|
94145
|
-
}
|
|
94146
93613
|
function enableSubstitutionForNonQualifiedEnumMembers() {
|
|
94147
93614
|
if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
|
|
94148
93615
|
enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
|
|
94149
93616
|
context.enableSubstitution(79 /* Identifier */);
|
|
94150
93617
|
}
|
|
94151
93618
|
}
|
|
94152
|
-
function enableSubstitutionForClassAliases() {
|
|
94153
|
-
if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
|
|
94154
|
-
enabledSubstitutions |= 1 /* ClassAliases */;
|
|
94155
|
-
// We need to enable substitutions for identifiers. This allows us to
|
|
94156
|
-
// substitute class names inside of a class declaration.
|
|
94157
|
-
context.enableSubstitution(79 /* Identifier */);
|
|
94158
|
-
// Keep track of class aliases.
|
|
94159
|
-
classAliases = [];
|
|
94160
|
-
}
|
|
94161
|
-
}
|
|
94162
93619
|
function enableSubstitutionForNamespaceExports() {
|
|
94163
93620
|
if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
|
|
94164
93621
|
enabledSubstitutions |= 2 /* NamespaceExports */;
|
|
@@ -94243,32 +93700,9 @@ var ts;
|
|
|
94243
93700
|
return node;
|
|
94244
93701
|
}
|
|
94245
93702
|
function substituteExpressionIdentifier(node) {
|
|
94246
|
-
return
|
|
94247
|
-
|| trySubstituteNamespaceExportedName(node)
|
|
93703
|
+
return trySubstituteNamespaceExportedName(node)
|
|
94248
93704
|
|| node;
|
|
94249
93705
|
}
|
|
94250
|
-
function trySubstituteClassAlias(node) {
|
|
94251
|
-
if (enabledSubstitutions & 1 /* ClassAliases */) {
|
|
94252
|
-
if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
|
|
94253
|
-
// Due to the emit for class decorators, any reference to the class from inside of the class body
|
|
94254
|
-
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
|
|
94255
|
-
// behavior of class names in ES6.
|
|
94256
|
-
// Also, when emitting statics for class expressions, we must substitute a class alias for
|
|
94257
|
-
// constructor references in static property initializers.
|
|
94258
|
-
var declaration = resolver.getReferencedValueDeclaration(node);
|
|
94259
|
-
if (declaration) {
|
|
94260
|
-
var classAlias = classAliases[declaration.id]; // TODO: GH#18217
|
|
94261
|
-
if (classAlias) {
|
|
94262
|
-
var clone_2 = factory.cloneNode(classAlias);
|
|
94263
|
-
ts.setSourceMapRange(clone_2, node);
|
|
94264
|
-
ts.setCommentRange(clone_2, node);
|
|
94265
|
-
return clone_2;
|
|
94266
|
-
}
|
|
94267
|
-
}
|
|
94268
|
-
}
|
|
94269
|
-
}
|
|
94270
|
-
return undefined;
|
|
94271
|
-
}
|
|
94272
93706
|
function trySubstituteNamespaceExportedName(node) {
|
|
94273
93707
|
// If this is explicitly a local name, do not substitute.
|
|
94274
93708
|
if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
|
|
@@ -94406,7 +93840,7 @@ var ts;
|
|
|
94406
93840
|
return visited;
|
|
94407
93841
|
}
|
|
94408
93842
|
function visitorWorker(node, valueIsDiscarded) {
|
|
94409
|
-
if (node.transformFlags &
|
|
93843
|
+
if (node.transformFlags & 16777216 /* ContainsClassFields */) {
|
|
94410
93844
|
switch (node.kind) {
|
|
94411
93845
|
case 226 /* ClassExpression */:
|
|
94412
93846
|
case 257 /* ClassDeclaration */:
|
|
@@ -94421,8 +93855,8 @@ var ts;
|
|
|
94421
93855
|
return visitClassStaticBlockDeclaration(node);
|
|
94422
93856
|
}
|
|
94423
93857
|
}
|
|
94424
|
-
if (node.transformFlags &
|
|
94425
|
-
node.transformFlags &
|
|
93858
|
+
if (node.transformFlags & 16777216 /* ContainsClassFields */ ||
|
|
93859
|
+
node.transformFlags & 134217728 /* ContainsLexicalSuper */ &&
|
|
94426
93860
|
shouldTransformSuperInStaticInitializers &&
|
|
94427
93861
|
currentStaticPropertyDeclarationOrStaticBlock &&
|
|
94428
93862
|
currentClassLexicalEnvironment) {
|
|
@@ -94996,13 +94430,13 @@ var ts;
|
|
|
94996
94430
|
facts |= 2 /* NeedsClassConstructorReference */;
|
|
94997
94431
|
}
|
|
94998
94432
|
if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
|
|
94999
|
-
if (shouldTransformThisInStaticInitializers && member.transformFlags &
|
|
94433
|
+
if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
|
|
95000
94434
|
facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
|
|
95001
94435
|
if (!(facts & 1 /* ClassWasDecorated */)) {
|
|
95002
94436
|
facts |= 2 /* NeedsClassConstructorReference */;
|
|
95003
94437
|
}
|
|
95004
94438
|
}
|
|
95005
|
-
if (shouldTransformSuperInStaticInitializers && member.transformFlags &
|
|
94439
|
+
if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) {
|
|
95006
94440
|
if (!(facts & 1 /* ClassWasDecorated */)) {
|
|
95007
94441
|
facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
|
|
95008
94442
|
}
|
|
@@ -95587,10 +95021,10 @@ var ts;
|
|
|
95587
95021
|
if (declaration) {
|
|
95588
95022
|
var classAlias = classAliases[declaration.id]; // TODO: GH#18217
|
|
95589
95023
|
if (classAlias) {
|
|
95590
|
-
var
|
|
95591
|
-
ts.setSourceMapRange(
|
|
95592
|
-
ts.setCommentRange(
|
|
95593
|
-
return
|
|
95024
|
+
var clone_2 = factory.cloneNode(classAlias);
|
|
95025
|
+
ts.setSourceMapRange(clone_2, node);
|
|
95026
|
+
ts.setCommentRange(clone_2, node);
|
|
95027
|
+
return clone_2;
|
|
95594
95028
|
}
|
|
95595
95029
|
}
|
|
95596
95030
|
}
|
|
@@ -95952,6 +95386,965 @@ var ts;
|
|
|
95952
95386
|
})(ts || (ts = {}));
|
|
95953
95387
|
/*@internal*/
|
|
95954
95388
|
var ts;
|
|
95389
|
+
(function (ts) {
|
|
95390
|
+
function createRuntimeTypeSerializer(context) {
|
|
95391
|
+
var hoistVariableDeclaration = context.hoistVariableDeclaration;
|
|
95392
|
+
var resolver = context.getEmitResolver();
|
|
95393
|
+
var compilerOptions = context.getCompilerOptions();
|
|
95394
|
+
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
95395
|
+
var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
|
|
95396
|
+
var currentLexicalScope;
|
|
95397
|
+
var currentNameScope;
|
|
95398
|
+
return {
|
|
95399
|
+
serializeTypeNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeNode, node); },
|
|
95400
|
+
serializeTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeOfNode, node); },
|
|
95401
|
+
serializeParameterTypesOfNode: function (serializerContext, node, container) { return setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container); },
|
|
95402
|
+
serializeReturnTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node); },
|
|
95403
|
+
};
|
|
95404
|
+
function setSerializerContextAnd(serializerContext, cb, node, arg) {
|
|
95405
|
+
var savedCurrentLexicalScope = currentLexicalScope;
|
|
95406
|
+
var savedCurrentNameScope = currentNameScope;
|
|
95407
|
+
currentLexicalScope = serializerContext.currentLexicalScope;
|
|
95408
|
+
currentNameScope = serializerContext.currentNameScope;
|
|
95409
|
+
var result = arg === undefined ? cb(node) : cb(node, arg);
|
|
95410
|
+
currentLexicalScope = savedCurrentLexicalScope;
|
|
95411
|
+
currentNameScope = savedCurrentNameScope;
|
|
95412
|
+
return result;
|
|
95413
|
+
}
|
|
95414
|
+
function getAccessorTypeNode(node) {
|
|
95415
|
+
var accessors = resolver.getAllAccessorDeclarations(node);
|
|
95416
|
+
return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
|
|
95417
|
+
|| accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
|
|
95418
|
+
}
|
|
95419
|
+
/**
|
|
95420
|
+
* Serializes the type of a node for use with decorator type metadata.
|
|
95421
|
+
* @param node The node that should have its type serialized.
|
|
95422
|
+
*/
|
|
95423
|
+
function serializeTypeOfNode(node) {
|
|
95424
|
+
switch (node.kind) {
|
|
95425
|
+
case 167 /* PropertyDeclaration */:
|
|
95426
|
+
case 164 /* Parameter */:
|
|
95427
|
+
return serializeTypeNode(node.type);
|
|
95428
|
+
case 173 /* SetAccessor */:
|
|
95429
|
+
case 172 /* GetAccessor */:
|
|
95430
|
+
return serializeTypeNode(getAccessorTypeNode(node));
|
|
95431
|
+
case 257 /* ClassDeclaration */:
|
|
95432
|
+
case 226 /* ClassExpression */:
|
|
95433
|
+
case 169 /* MethodDeclaration */:
|
|
95434
|
+
return ts.factory.createIdentifier("Function");
|
|
95435
|
+
default:
|
|
95436
|
+
return ts.factory.createVoidZero();
|
|
95437
|
+
}
|
|
95438
|
+
}
|
|
95439
|
+
/**
|
|
95440
|
+
* Serializes the type of a node for use with decorator type metadata.
|
|
95441
|
+
* @param node The node that should have its type serialized.
|
|
95442
|
+
*/
|
|
95443
|
+
function serializeParameterTypesOfNode(node, container) {
|
|
95444
|
+
var valueDeclaration = ts.isClassLike(node)
|
|
95445
|
+
? ts.getFirstConstructorWithBody(node)
|
|
95446
|
+
: ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
|
|
95447
|
+
? node
|
|
95448
|
+
: undefined;
|
|
95449
|
+
var expressions = [];
|
|
95450
|
+
if (valueDeclaration) {
|
|
95451
|
+
var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
|
|
95452
|
+
var numParameters = parameters.length;
|
|
95453
|
+
for (var i = 0; i < numParameters; i++) {
|
|
95454
|
+
var parameter = parameters[i];
|
|
95455
|
+
if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
|
|
95456
|
+
continue;
|
|
95457
|
+
}
|
|
95458
|
+
if (parameter.dotDotDotToken) {
|
|
95459
|
+
expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
|
|
95460
|
+
}
|
|
95461
|
+
else {
|
|
95462
|
+
expressions.push(serializeTypeOfNode(parameter));
|
|
95463
|
+
}
|
|
95464
|
+
}
|
|
95465
|
+
}
|
|
95466
|
+
return ts.factory.createArrayLiteralExpression(expressions);
|
|
95467
|
+
}
|
|
95468
|
+
function getParametersOfDecoratedDeclaration(node, container) {
|
|
95469
|
+
if (container && node.kind === 172 /* GetAccessor */) {
|
|
95470
|
+
var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
|
|
95471
|
+
if (setAccessor) {
|
|
95472
|
+
return setAccessor.parameters;
|
|
95473
|
+
}
|
|
95474
|
+
}
|
|
95475
|
+
return node.parameters;
|
|
95476
|
+
}
|
|
95477
|
+
/**
|
|
95478
|
+
* Serializes the return type of a node for use with decorator type metadata.
|
|
95479
|
+
* @param node The node that should have its return type serialized.
|
|
95480
|
+
*/
|
|
95481
|
+
function serializeReturnTypeOfNode(node) {
|
|
95482
|
+
if (ts.isFunctionLike(node) && node.type) {
|
|
95483
|
+
return serializeTypeNode(node.type);
|
|
95484
|
+
}
|
|
95485
|
+
else if (ts.isAsyncFunction(node)) {
|
|
95486
|
+
return ts.factory.createIdentifier("Promise");
|
|
95487
|
+
}
|
|
95488
|
+
return ts.factory.createVoidZero();
|
|
95489
|
+
}
|
|
95490
|
+
/**
|
|
95491
|
+
* Serializes a type node for use with decorator type metadata.
|
|
95492
|
+
*
|
|
95493
|
+
* Types are serialized in the following fashion:
|
|
95494
|
+
* - Void types point to "undefined" (e.g. "void 0")
|
|
95495
|
+
* - Function and Constructor types point to the global "Function" constructor.
|
|
95496
|
+
* - Interface types with a call or construct signature types point to the global
|
|
95497
|
+
* "Function" constructor.
|
|
95498
|
+
* - Array and Tuple types point to the global "Array" constructor.
|
|
95499
|
+
* - Type predicates and booleans point to the global "Boolean" constructor.
|
|
95500
|
+
* - String literal types and strings point to the global "String" constructor.
|
|
95501
|
+
* - Enum and number types point to the global "Number" constructor.
|
|
95502
|
+
* - Symbol types point to the global "Symbol" constructor.
|
|
95503
|
+
* - Type references to classes (or class-like variables) point to the constructor for the class.
|
|
95504
|
+
* - Anything else points to the global "Object" constructor.
|
|
95505
|
+
*
|
|
95506
|
+
* @param node The type node to serialize.
|
|
95507
|
+
*/
|
|
95508
|
+
function serializeTypeNode(node) {
|
|
95509
|
+
if (node === undefined) {
|
|
95510
|
+
return ts.factory.createIdentifier("Object");
|
|
95511
|
+
}
|
|
95512
|
+
node = ts.skipTypeParentheses(node);
|
|
95513
|
+
switch (node.kind) {
|
|
95514
|
+
case 114 /* VoidKeyword */:
|
|
95515
|
+
case 153 /* UndefinedKeyword */:
|
|
95516
|
+
case 143 /* NeverKeyword */:
|
|
95517
|
+
return ts.factory.createVoidZero();
|
|
95518
|
+
case 179 /* FunctionType */:
|
|
95519
|
+
case 180 /* ConstructorType */:
|
|
95520
|
+
return ts.factory.createIdentifier("Function");
|
|
95521
|
+
case 183 /* ArrayType */:
|
|
95522
|
+
case 184 /* TupleType */:
|
|
95523
|
+
return ts.factory.createIdentifier("Array");
|
|
95524
|
+
case 177 /* TypePredicate */:
|
|
95525
|
+
return node.assertsModifier ?
|
|
95526
|
+
ts.factory.createVoidZero() :
|
|
95527
|
+
ts.factory.createIdentifier("Boolean");
|
|
95528
|
+
case 133 /* BooleanKeyword */:
|
|
95529
|
+
return ts.factory.createIdentifier("Boolean");
|
|
95530
|
+
case 198 /* TemplateLiteralType */:
|
|
95531
|
+
case 150 /* StringKeyword */:
|
|
95532
|
+
return ts.factory.createIdentifier("String");
|
|
95533
|
+
case 148 /* ObjectKeyword */:
|
|
95534
|
+
return ts.factory.createIdentifier("Object");
|
|
95535
|
+
case 196 /* LiteralType */:
|
|
95536
|
+
return serializeLiteralOfLiteralTypeNode(node.literal);
|
|
95537
|
+
case 147 /* NumberKeyword */:
|
|
95538
|
+
return ts.factory.createIdentifier("Number");
|
|
95539
|
+
case 158 /* BigIntKeyword */:
|
|
95540
|
+
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
95541
|
+
case 151 /* SymbolKeyword */:
|
|
95542
|
+
return getGlobalConstructor("Symbol", 2 /* ES2015 */);
|
|
95543
|
+
case 178 /* TypeReference */:
|
|
95544
|
+
return serializeTypeReferenceNode(node);
|
|
95545
|
+
case 188 /* IntersectionType */:
|
|
95546
|
+
return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true);
|
|
95547
|
+
case 187 /* UnionType */:
|
|
95548
|
+
return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false);
|
|
95549
|
+
case 189 /* ConditionalType */:
|
|
95550
|
+
return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false);
|
|
95551
|
+
case 193 /* TypeOperator */:
|
|
95552
|
+
if (node.operator === 145 /* ReadonlyKeyword */) {
|
|
95553
|
+
return serializeTypeNode(node.type);
|
|
95554
|
+
}
|
|
95555
|
+
break;
|
|
95556
|
+
case 181 /* TypeQuery */:
|
|
95557
|
+
case 194 /* IndexedAccessType */:
|
|
95558
|
+
case 195 /* MappedType */:
|
|
95559
|
+
case 182 /* TypeLiteral */:
|
|
95560
|
+
case 130 /* AnyKeyword */:
|
|
95561
|
+
case 155 /* UnknownKeyword */:
|
|
95562
|
+
case 192 /* ThisType */:
|
|
95563
|
+
case 200 /* ImportType */:
|
|
95564
|
+
break;
|
|
95565
|
+
// handle JSDoc types from an invalid parse
|
|
95566
|
+
case 312 /* JSDocAllType */:
|
|
95567
|
+
case 313 /* JSDocUnknownType */:
|
|
95568
|
+
case 317 /* JSDocFunctionType */:
|
|
95569
|
+
case 318 /* JSDocVariadicType */:
|
|
95570
|
+
case 319 /* JSDocNamepathType */:
|
|
95571
|
+
break;
|
|
95572
|
+
case 314 /* JSDocNullableType */:
|
|
95573
|
+
case 315 /* JSDocNonNullableType */:
|
|
95574
|
+
case 316 /* JSDocOptionalType */:
|
|
95575
|
+
return serializeTypeNode(node.type);
|
|
95576
|
+
default:
|
|
95577
|
+
return ts.Debug.failBadSyntaxKind(node);
|
|
95578
|
+
}
|
|
95579
|
+
return ts.factory.createIdentifier("Object");
|
|
95580
|
+
}
|
|
95581
|
+
function serializeLiteralOfLiteralTypeNode(node) {
|
|
95582
|
+
switch (node.kind) {
|
|
95583
|
+
case 10 /* StringLiteral */:
|
|
95584
|
+
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
95585
|
+
return ts.factory.createIdentifier("String");
|
|
95586
|
+
case 219 /* PrefixUnaryExpression */: {
|
|
95587
|
+
var operand = node.operand;
|
|
95588
|
+
switch (operand.kind) {
|
|
95589
|
+
case 8 /* NumericLiteral */:
|
|
95590
|
+
case 9 /* BigIntLiteral */:
|
|
95591
|
+
return serializeLiteralOfLiteralTypeNode(operand);
|
|
95592
|
+
default:
|
|
95593
|
+
return ts.Debug.failBadSyntaxKind(operand);
|
|
95594
|
+
}
|
|
95595
|
+
}
|
|
95596
|
+
case 8 /* NumericLiteral */:
|
|
95597
|
+
return ts.factory.createIdentifier("Number");
|
|
95598
|
+
case 9 /* BigIntLiteral */:
|
|
95599
|
+
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
95600
|
+
case 110 /* TrueKeyword */:
|
|
95601
|
+
case 95 /* FalseKeyword */:
|
|
95602
|
+
return ts.factory.createIdentifier("Boolean");
|
|
95603
|
+
case 104 /* NullKeyword */:
|
|
95604
|
+
return ts.factory.createVoidZero();
|
|
95605
|
+
default:
|
|
95606
|
+
return ts.Debug.failBadSyntaxKind(node);
|
|
95607
|
+
}
|
|
95608
|
+
}
|
|
95609
|
+
function serializeUnionOrIntersectionConstituents(types, isIntersection) {
|
|
95610
|
+
// Note when updating logic here also update `getEntityNameForDecoratorMetadata` in checker.ts so that aliases can be marked as referenced
|
|
95611
|
+
var serializedType;
|
|
95612
|
+
for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
|
|
95613
|
+
var typeNode = types_22[_i];
|
|
95614
|
+
typeNode = ts.skipTypeParentheses(typeNode);
|
|
95615
|
+
if (typeNode.kind === 143 /* NeverKeyword */) {
|
|
95616
|
+
if (isIntersection)
|
|
95617
|
+
return ts.factory.createVoidZero(); // Reduce to `never` in an intersection
|
|
95618
|
+
continue; // Elide `never` in a union
|
|
95619
|
+
}
|
|
95620
|
+
if (typeNode.kind === 155 /* UnknownKeyword */) {
|
|
95621
|
+
if (!isIntersection)
|
|
95622
|
+
return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union
|
|
95623
|
+
continue; // Elide `unknown` in an intersection
|
|
95624
|
+
}
|
|
95625
|
+
if (typeNode.kind === 130 /* AnyKeyword */) {
|
|
95626
|
+
return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection
|
|
95627
|
+
}
|
|
95628
|
+
if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) {
|
|
95629
|
+
continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
|
|
95630
|
+
}
|
|
95631
|
+
var serializedConstituent = serializeTypeNode(typeNode);
|
|
95632
|
+
if (ts.isIdentifier(serializedConstituent) && serializedConstituent.escapedText === "Object") {
|
|
95633
|
+
// One of the individual is global object, return immediately
|
|
95634
|
+
return serializedConstituent;
|
|
95635
|
+
}
|
|
95636
|
+
// If there exists union that is not `void 0` expression, check if the the common type is identifier.
|
|
95637
|
+
// anything more complex and we will just default to Object
|
|
95638
|
+
if (serializedType) {
|
|
95639
|
+
// Different types
|
|
95640
|
+
if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
|
|
95641
|
+
return ts.factory.createIdentifier("Object");
|
|
95642
|
+
}
|
|
95643
|
+
}
|
|
95644
|
+
else {
|
|
95645
|
+
// Initialize the union type
|
|
95646
|
+
serializedType = serializedConstituent;
|
|
95647
|
+
}
|
|
95648
|
+
}
|
|
95649
|
+
// If we were able to find common type, use it
|
|
95650
|
+
return serializedType !== null && serializedType !== void 0 ? serializedType : (ts.factory.createVoidZero()); // Fallback is only hit if all union constituents are null/undefined/never
|
|
95651
|
+
}
|
|
95652
|
+
function equateSerializedTypeNodes(left, right) {
|
|
95653
|
+
return (
|
|
95654
|
+
// temp vars used in fallback
|
|
95655
|
+
ts.isGeneratedIdentifier(left) ? ts.isGeneratedIdentifier(right) :
|
|
95656
|
+
// entity names
|
|
95657
|
+
ts.isIdentifier(left) ? ts.isIdentifier(right)
|
|
95658
|
+
&& left.escapedText === right.escapedText :
|
|
95659
|
+
ts.isPropertyAccessExpression(left) ? ts.isPropertyAccessExpression(right)
|
|
95660
|
+
&& equateSerializedTypeNodes(left.expression, right.expression)
|
|
95661
|
+
&& equateSerializedTypeNodes(left.name, right.name) :
|
|
95662
|
+
// `void 0`
|
|
95663
|
+
ts.isVoidExpression(left) ? ts.isVoidExpression(right)
|
|
95664
|
+
&& ts.isNumericLiteral(left.expression) && left.expression.text === "0"
|
|
95665
|
+
&& ts.isNumericLiteral(right.expression) && right.expression.text === "0" :
|
|
95666
|
+
// `"undefined"` or `"function"` in `typeof` checks
|
|
95667
|
+
ts.isStringLiteral(left) ? ts.isStringLiteral(right)
|
|
95668
|
+
&& left.text === right.text :
|
|
95669
|
+
// used in `typeof` checks for fallback
|
|
95670
|
+
ts.isTypeOfExpression(left) ? ts.isTypeOfExpression(right)
|
|
95671
|
+
&& equateSerializedTypeNodes(left.expression, right.expression) :
|
|
95672
|
+
// parens in `typeof` checks with temps
|
|
95673
|
+
ts.isParenthesizedExpression(left) ? ts.isParenthesizedExpression(right)
|
|
95674
|
+
&& equateSerializedTypeNodes(left.expression, right.expression) :
|
|
95675
|
+
// conditionals used in fallback
|
|
95676
|
+
ts.isConditionalExpression(left) ? ts.isConditionalExpression(right)
|
|
95677
|
+
&& equateSerializedTypeNodes(left.condition, right.condition)
|
|
95678
|
+
&& equateSerializedTypeNodes(left.whenTrue, right.whenTrue)
|
|
95679
|
+
&& equateSerializedTypeNodes(left.whenFalse, right.whenFalse) :
|
|
95680
|
+
// logical binary and assignments used in fallback
|
|
95681
|
+
ts.isBinaryExpression(left) ? ts.isBinaryExpression(right)
|
|
95682
|
+
&& left.operatorToken.kind === right.operatorToken.kind
|
|
95683
|
+
&& equateSerializedTypeNodes(left.left, right.left)
|
|
95684
|
+
&& equateSerializedTypeNodes(left.right, right.right) :
|
|
95685
|
+
false);
|
|
95686
|
+
}
|
|
95687
|
+
/**
|
|
95688
|
+
* Serializes a TypeReferenceNode to an appropriate JS constructor value for use with decorator type metadata.
|
|
95689
|
+
* @param node The type reference node.
|
|
95690
|
+
*/
|
|
95691
|
+
function serializeTypeReferenceNode(node) {
|
|
95692
|
+
var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope !== null && currentNameScope !== void 0 ? currentNameScope : currentLexicalScope);
|
|
95693
|
+
switch (kind) {
|
|
95694
|
+
case ts.TypeReferenceSerializationKind.Unknown:
|
|
95695
|
+
// From conditional type type reference that cannot be resolved is Similar to any or unknown
|
|
95696
|
+
if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
|
|
95697
|
+
return ts.factory.createIdentifier("Object");
|
|
95698
|
+
}
|
|
95699
|
+
var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
|
|
95700
|
+
var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
|
|
95701
|
+
return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createAssignment(temp, serialized), "function"),
|
|
95702
|
+
/*questionToken*/ undefined, temp,
|
|
95703
|
+
/*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
|
|
95704
|
+
case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
|
|
95705
|
+
return serializeEntityNameAsExpression(node.typeName);
|
|
95706
|
+
case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
|
|
95707
|
+
return ts.factory.createVoidZero();
|
|
95708
|
+
case ts.TypeReferenceSerializationKind.BigIntLikeType:
|
|
95709
|
+
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
95710
|
+
case ts.TypeReferenceSerializationKind.BooleanType:
|
|
95711
|
+
return ts.factory.createIdentifier("Boolean");
|
|
95712
|
+
case ts.TypeReferenceSerializationKind.NumberLikeType:
|
|
95713
|
+
return ts.factory.createIdentifier("Number");
|
|
95714
|
+
case ts.TypeReferenceSerializationKind.StringLikeType:
|
|
95715
|
+
return ts.factory.createIdentifier("String");
|
|
95716
|
+
case ts.TypeReferenceSerializationKind.ArrayLikeType:
|
|
95717
|
+
return ts.factory.createIdentifier("Array");
|
|
95718
|
+
case ts.TypeReferenceSerializationKind.ESSymbolType:
|
|
95719
|
+
return getGlobalConstructor("Symbol", 2 /* ES2015 */);
|
|
95720
|
+
case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
|
|
95721
|
+
return ts.factory.createIdentifier("Function");
|
|
95722
|
+
case ts.TypeReferenceSerializationKind.Promise:
|
|
95723
|
+
return ts.factory.createIdentifier("Promise");
|
|
95724
|
+
case ts.TypeReferenceSerializationKind.ObjectType:
|
|
95725
|
+
return ts.factory.createIdentifier("Object");
|
|
95726
|
+
default:
|
|
95727
|
+
return ts.Debug.assertNever(kind);
|
|
95728
|
+
}
|
|
95729
|
+
}
|
|
95730
|
+
/**
|
|
95731
|
+
* Produces an expression that results in `right` if `left` is not undefined at runtime:
|
|
95732
|
+
*
|
|
95733
|
+
* ```
|
|
95734
|
+
* typeof left !== "undefined" && right
|
|
95735
|
+
* ```
|
|
95736
|
+
*
|
|
95737
|
+
* We use `typeof L !== "undefined"` (rather than `L !== undefined`) since `L` may not be declared.
|
|
95738
|
+
* It's acceptable for this expression to result in `false` at runtime, as the result is intended to be
|
|
95739
|
+
* further checked by any containing expression.
|
|
95740
|
+
*/
|
|
95741
|
+
function createCheckedValue(left, right) {
|
|
95742
|
+
return ts.factory.createLogicalAnd(ts.factory.createStrictInequality(ts.factory.createTypeOfExpression(left), ts.factory.createStringLiteral("undefined")), right);
|
|
95743
|
+
}
|
|
95744
|
+
/**
|
|
95745
|
+
* Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
|
|
95746
|
+
* @param node The entity name to serialize.
|
|
95747
|
+
*/
|
|
95748
|
+
function serializeEntityNameAsExpressionFallback(node) {
|
|
95749
|
+
if (node.kind === 79 /* Identifier */) {
|
|
95750
|
+
// A -> typeof A !== "undefined" && A
|
|
95751
|
+
var copied = serializeEntityNameAsExpression(node);
|
|
95752
|
+
return createCheckedValue(copied, copied);
|
|
95753
|
+
}
|
|
95754
|
+
if (node.left.kind === 79 /* Identifier */) {
|
|
95755
|
+
// A.B -> typeof A !== "undefined" && A.B
|
|
95756
|
+
return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
|
|
95757
|
+
}
|
|
95758
|
+
// A.B.C -> typeof A !== "undefined" && (_a = A.B) !== void 0 && _a.C
|
|
95759
|
+
var left = serializeEntityNameAsExpressionFallback(node.left);
|
|
95760
|
+
var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
|
|
95761
|
+
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));
|
|
95762
|
+
}
|
|
95763
|
+
/**
|
|
95764
|
+
* Serializes an entity name as an expression for decorator type metadata.
|
|
95765
|
+
* @param node The entity name to serialize.
|
|
95766
|
+
*/
|
|
95767
|
+
function serializeEntityNameAsExpression(node) {
|
|
95768
|
+
switch (node.kind) {
|
|
95769
|
+
case 79 /* Identifier */:
|
|
95770
|
+
// Create a clone of the name with a new parent, and treat it as if it were
|
|
95771
|
+
// a source tree node for the purposes of the checker.
|
|
95772
|
+
var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
|
|
95773
|
+
name.original = undefined;
|
|
95774
|
+
ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
|
|
95775
|
+
return name;
|
|
95776
|
+
case 161 /* QualifiedName */:
|
|
95777
|
+
return serializeQualifiedNameAsExpression(node);
|
|
95778
|
+
}
|
|
95779
|
+
}
|
|
95780
|
+
/**
|
|
95781
|
+
* Serializes an qualified name as an expression for decorator type metadata.
|
|
95782
|
+
* @param node The qualified name to serialize.
|
|
95783
|
+
*/
|
|
95784
|
+
function serializeQualifiedNameAsExpression(node) {
|
|
95785
|
+
return ts.factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
|
|
95786
|
+
}
|
|
95787
|
+
function getGlobalConstructorWithFallback(name) {
|
|
95788
|
+
return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createIdentifier(name), "function"),
|
|
95789
|
+
/*questionToken*/ undefined, ts.factory.createIdentifier(name),
|
|
95790
|
+
/*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
|
|
95791
|
+
}
|
|
95792
|
+
function getGlobalConstructor(name, minLanguageVersion) {
|
|
95793
|
+
return languageVersion < minLanguageVersion ?
|
|
95794
|
+
getGlobalConstructorWithFallback(name) :
|
|
95795
|
+
ts.factory.createIdentifier(name);
|
|
95796
|
+
}
|
|
95797
|
+
}
|
|
95798
|
+
ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer;
|
|
95799
|
+
})(ts || (ts = {}));
|
|
95800
|
+
/*@internal*/
|
|
95801
|
+
var ts;
|
|
95802
|
+
(function (ts) {
|
|
95803
|
+
function transformLegacyDecorators(context) {
|
|
95804
|
+
var factory = context.factory, emitHelpers = context.getEmitHelperFactory, hoistVariableDeclaration = context.hoistVariableDeclaration;
|
|
95805
|
+
var resolver = context.getEmitResolver();
|
|
95806
|
+
var compilerOptions = context.getCompilerOptions();
|
|
95807
|
+
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
95808
|
+
// Save the previous transformation hooks.
|
|
95809
|
+
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
95810
|
+
// Set new transformation hooks.
|
|
95811
|
+
context.onSubstituteNode = onSubstituteNode;
|
|
95812
|
+
/**
|
|
95813
|
+
* A map that keeps track of aliases created for classes with decorators to avoid issues
|
|
95814
|
+
* with the double-binding behavior of classes.
|
|
95815
|
+
*/
|
|
95816
|
+
var classAliases;
|
|
95817
|
+
return ts.chainBundle(context, transformSourceFile);
|
|
95818
|
+
function transformSourceFile(node) {
|
|
95819
|
+
var visited = ts.visitEachChild(node, visitor, context);
|
|
95820
|
+
ts.addEmitHelpers(visited, context.readEmitHelpers());
|
|
95821
|
+
return visited;
|
|
95822
|
+
}
|
|
95823
|
+
function visitor(node) {
|
|
95824
|
+
if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) {
|
|
95825
|
+
return node;
|
|
95826
|
+
}
|
|
95827
|
+
switch (node.kind) {
|
|
95828
|
+
case 165 /* Decorator */:
|
|
95829
|
+
// Decorators are elided. They will be emitted as part of `visitClassDeclaration`.
|
|
95830
|
+
return undefined;
|
|
95831
|
+
case 257 /* ClassDeclaration */:
|
|
95832
|
+
return visitClassDeclaration(node);
|
|
95833
|
+
case 226 /* ClassExpression */:
|
|
95834
|
+
return visitClassExpression(node);
|
|
95835
|
+
case 171 /* Constructor */:
|
|
95836
|
+
return visitConstructorDeclaration(node);
|
|
95837
|
+
case 169 /* MethodDeclaration */:
|
|
95838
|
+
return visitMethodDeclaration(node);
|
|
95839
|
+
case 173 /* SetAccessor */:
|
|
95840
|
+
return visitSetAccessorDeclaration(node);
|
|
95841
|
+
case 172 /* GetAccessor */:
|
|
95842
|
+
return visitGetAccessorDeclaration(node);
|
|
95843
|
+
case 170 /* ClassStaticBlockDeclaration */:
|
|
95844
|
+
return visitClassStaticBlockDeclaration(node);
|
|
95845
|
+
case 167 /* PropertyDeclaration */:
|
|
95846
|
+
return visitPropertyDeclaration(node);
|
|
95847
|
+
case 164 /* Parameter */:
|
|
95848
|
+
return visitParameterDeclaration(node);
|
|
95849
|
+
default:
|
|
95850
|
+
return ts.visitEachChild(node, visitor, context);
|
|
95851
|
+
}
|
|
95852
|
+
}
|
|
95853
|
+
function visitClassDeclaration(node) {
|
|
95854
|
+
if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
|
|
95855
|
+
return ts.visitEachChild(node, visitor, context);
|
|
95856
|
+
var classStatement = ts.some(node.decorators) ?
|
|
95857
|
+
createClassDeclarationHeadWithDecorators(node, node.name) :
|
|
95858
|
+
createClassDeclarationHeadWithoutDecorators(node, node.name);
|
|
95859
|
+
var statements = [classStatement];
|
|
95860
|
+
// Write any decorators of the node.
|
|
95861
|
+
addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
|
|
95862
|
+
addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
|
|
95863
|
+
addConstructorDecorationStatement(statements, node);
|
|
95864
|
+
if (statements.length > 1) {
|
|
95865
|
+
// Add a DeclarationMarker as a marker for the end of the declaration
|
|
95866
|
+
statements.push(factory.createEndOfDeclarationMarker(node));
|
|
95867
|
+
ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
|
|
95868
|
+
}
|
|
95869
|
+
return ts.singleOrMany(statements);
|
|
95870
|
+
}
|
|
95871
|
+
/**
|
|
95872
|
+
* Transforms a non-decorated class declaration.
|
|
95873
|
+
*
|
|
95874
|
+
* @param node A ClassDeclaration node.
|
|
95875
|
+
* @param name The name of the class.
|
|
95876
|
+
*/
|
|
95877
|
+
function createClassDeclarationHeadWithoutDecorators(node, name) {
|
|
95878
|
+
// ${modifiers} class ${name} ${heritageClauses} {
|
|
95879
|
+
// ${members}
|
|
95880
|
+
// }
|
|
95881
|
+
return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, name,
|
|
95882
|
+
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
|
|
95883
|
+
}
|
|
95884
|
+
/**
|
|
95885
|
+
* Transforms a decorated class declaration and appends the resulting statements. If
|
|
95886
|
+
* the class requires an alias to avoid issues with double-binding, the alias is returned.
|
|
95887
|
+
*/
|
|
95888
|
+
function createClassDeclarationHeadWithDecorators(node, name) {
|
|
95889
|
+
// When we emit an ES6 class that has a class decorator, we must tailor the
|
|
95890
|
+
// emit to certain specific cases.
|
|
95891
|
+
//
|
|
95892
|
+
// In the simplest case, we emit the class declaration as a let declaration, and
|
|
95893
|
+
// evaluate decorators after the close of the class body:
|
|
95894
|
+
//
|
|
95895
|
+
// [Example 1]
|
|
95896
|
+
// ---------------------------------------------------------------------
|
|
95897
|
+
// TypeScript | Javascript
|
|
95898
|
+
// ---------------------------------------------------------------------
|
|
95899
|
+
// @dec | let C = class C {
|
|
95900
|
+
// class C { | }
|
|
95901
|
+
// } | C = __decorate([dec], C);
|
|
95902
|
+
// ---------------------------------------------------------------------
|
|
95903
|
+
// @dec | let C = class C {
|
|
95904
|
+
// export class C { | }
|
|
95905
|
+
// } | C = __decorate([dec], C);
|
|
95906
|
+
// | export { C };
|
|
95907
|
+
// ---------------------------------------------------------------------
|
|
95908
|
+
//
|
|
95909
|
+
// If a class declaration contains a reference to itself *inside* of the class body,
|
|
95910
|
+
// this introduces two bindings to the class: One outside of the class body, and one
|
|
95911
|
+
// inside of the class body. If we apply decorators as in [Example 1] above, there
|
|
95912
|
+
// is the possibility that the decorator `dec` will return a new value for the
|
|
95913
|
+
// constructor, which would result in the binding inside of the class no longer
|
|
95914
|
+
// pointing to the same reference as the binding outside of the class.
|
|
95915
|
+
//
|
|
95916
|
+
// As a result, we must instead rewrite all references to the class *inside* of the
|
|
95917
|
+
// class body to instead point to a local temporary alias for the class:
|
|
95918
|
+
//
|
|
95919
|
+
// [Example 2]
|
|
95920
|
+
// ---------------------------------------------------------------------
|
|
95921
|
+
// TypeScript | Javascript
|
|
95922
|
+
// ---------------------------------------------------------------------
|
|
95923
|
+
// @dec | let C = C_1 = class C {
|
|
95924
|
+
// class C { | static x() { return C_1.y; }
|
|
95925
|
+
// static x() { return C.y; } | }
|
|
95926
|
+
// static y = 1; | C.y = 1;
|
|
95927
|
+
// } | C = C_1 = __decorate([dec], C);
|
|
95928
|
+
// | var C_1;
|
|
95929
|
+
// ---------------------------------------------------------------------
|
|
95930
|
+
// @dec | let C = class C {
|
|
95931
|
+
// export class C { | static x() { return C_1.y; }
|
|
95932
|
+
// static x() { return C.y; } | }
|
|
95933
|
+
// static y = 1; | C.y = 1;
|
|
95934
|
+
// } | C = C_1 = __decorate([dec], C);
|
|
95935
|
+
// | export { C };
|
|
95936
|
+
// | var C_1;
|
|
95937
|
+
// ---------------------------------------------------------------------
|
|
95938
|
+
//
|
|
95939
|
+
// If a class declaration is the default export of a module, we instead emit
|
|
95940
|
+
// the export after the decorated declaration:
|
|
95941
|
+
//
|
|
95942
|
+
// [Example 3]
|
|
95943
|
+
// ---------------------------------------------------------------------
|
|
95944
|
+
// TypeScript | Javascript
|
|
95945
|
+
// ---------------------------------------------------------------------
|
|
95946
|
+
// @dec | let default_1 = class {
|
|
95947
|
+
// export default class { | }
|
|
95948
|
+
// } | default_1 = __decorate([dec], default_1);
|
|
95949
|
+
// | export default default_1;
|
|
95950
|
+
// ---------------------------------------------------------------------
|
|
95951
|
+
// @dec | let C = class C {
|
|
95952
|
+
// export default class C { | }
|
|
95953
|
+
// } | C = __decorate([dec], C);
|
|
95954
|
+
// | export default C;
|
|
95955
|
+
// ---------------------------------------------------------------------
|
|
95956
|
+
//
|
|
95957
|
+
// If the class declaration is the default export and a reference to itself
|
|
95958
|
+
// inside of the class body, we must emit both an alias for the class *and*
|
|
95959
|
+
// move the export after the declaration:
|
|
95960
|
+
//
|
|
95961
|
+
// [Example 4]
|
|
95962
|
+
// ---------------------------------------------------------------------
|
|
95963
|
+
// TypeScript | Javascript
|
|
95964
|
+
// ---------------------------------------------------------------------
|
|
95965
|
+
// @dec | let C = class C {
|
|
95966
|
+
// export default class C { | static x() { return C_1.y; }
|
|
95967
|
+
// static x() { return C.y; } | }
|
|
95968
|
+
// static y = 1; | C.y = 1;
|
|
95969
|
+
// } | C = C_1 = __decorate([dec], C);
|
|
95970
|
+
// | export default C;
|
|
95971
|
+
// | var C_1;
|
|
95972
|
+
// ---------------------------------------------------------------------
|
|
95973
|
+
//
|
|
95974
|
+
var location = ts.moveRangePastModifiers(node);
|
|
95975
|
+
var classAlias = getClassAliasIfNeeded(node);
|
|
95976
|
+
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
|
95977
|
+
// without any block-scoped variable collision handling
|
|
95978
|
+
var declName = languageVersion <= 2 /* ES2015 */ ?
|
|
95979
|
+
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
|
95980
|
+
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
|
95981
|
+
// ... = class ${name} ${heritageClauses} {
|
|
95982
|
+
// ${members}
|
|
95983
|
+
// }
|
|
95984
|
+
var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
|
|
95985
|
+
var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
|
|
95986
|
+
var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
|
|
95987
|
+
ts.setOriginalNode(classExpression, node);
|
|
95988
|
+
ts.setTextRange(classExpression, location);
|
|
95989
|
+
// let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
|
|
95990
|
+
// or decoratedClassAlias if the class contain self-reference.
|
|
95991
|
+
var statement = factory.createVariableStatement(
|
|
95992
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
95993
|
+
factory.createVariableDeclaration(declName,
|
|
95994
|
+
/*exclamationToken*/ undefined,
|
|
95995
|
+
/*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
|
|
95996
|
+
], 1 /* Let */));
|
|
95997
|
+
ts.setOriginalNode(statement, node);
|
|
95998
|
+
ts.setTextRange(statement, location);
|
|
95999
|
+
ts.setCommentRange(statement, node);
|
|
96000
|
+
return statement;
|
|
96001
|
+
}
|
|
96002
|
+
function visitClassExpression(node) {
|
|
96003
|
+
// Legacy decorators were not supported on class expressions
|
|
96004
|
+
return factory.updateClassExpression(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.name,
|
|
96005
|
+
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
|
|
96006
|
+
}
|
|
96007
|
+
function visitConstructorDeclaration(node) {
|
|
96008
|
+
return factory.updateConstructorDeclaration(node,
|
|
96009
|
+
/*decorators*/ undefined, node.modifiers, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock));
|
|
96010
|
+
}
|
|
96011
|
+
function finishClassElement(updated, original) {
|
|
96012
|
+
if (updated !== original) {
|
|
96013
|
+
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
96014
|
+
// we need to emit the comments for the original range.
|
|
96015
|
+
ts.setCommentRange(updated, original);
|
|
96016
|
+
ts.setSourceMapRange(updated, ts.moveRangePastModifiers(original));
|
|
96017
|
+
}
|
|
96018
|
+
return updated;
|
|
96019
|
+
}
|
|
96020
|
+
function visitMethodDeclaration(node) {
|
|
96021
|
+
return finishClassElement(factory.updateMethodDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName),
|
|
96022
|
+
/*questionToken*/ undefined,
|
|
96023
|
+
/*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
|
|
96024
|
+
/*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
|
|
96025
|
+
}
|
|
96026
|
+
function visitGetAccessorDeclaration(node) {
|
|
96027
|
+
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),
|
|
96028
|
+
/*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
|
|
96029
|
+
}
|
|
96030
|
+
function visitSetAccessorDeclaration(node) {
|
|
96031
|
+
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);
|
|
96032
|
+
}
|
|
96033
|
+
function visitClassStaticBlockDeclaration(node) {
|
|
96034
|
+
return factory.updateClassStaticBlockDeclaration(node,
|
|
96035
|
+
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.body, visitor, ts.isBlock));
|
|
96036
|
+
}
|
|
96037
|
+
function visitPropertyDeclaration(node) {
|
|
96038
|
+
if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
|
|
96039
|
+
return undefined;
|
|
96040
|
+
}
|
|
96041
|
+
return finishClassElement(factory.updatePropertyDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName),
|
|
96042
|
+
/*questionOrExclamationToken*/ undefined,
|
|
96043
|
+
/*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
|
|
96044
|
+
}
|
|
96045
|
+
function visitParameterDeclaration(node) {
|
|
96046
|
+
var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators),
|
|
96047
|
+
/*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
|
|
96048
|
+
/*questionToken*/ undefined,
|
|
96049
|
+
/*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
|
|
96050
|
+
if (updated !== node) {
|
|
96051
|
+
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
96052
|
+
// we need to emit the comments for the original range.
|
|
96053
|
+
ts.setCommentRange(updated, node);
|
|
96054
|
+
ts.setTextRange(updated, ts.moveRangePastModifiers(node));
|
|
96055
|
+
ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
|
|
96056
|
+
ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */);
|
|
96057
|
+
}
|
|
96058
|
+
return updated;
|
|
96059
|
+
}
|
|
96060
|
+
/**
|
|
96061
|
+
* Transforms all of the decorators for a declaration into an array of expressions.
|
|
96062
|
+
*
|
|
96063
|
+
* @param allDecorators An object containing all of the decorators for the declaration.
|
|
96064
|
+
*/
|
|
96065
|
+
function transformAllDecoratorsOfDeclaration(allDecorators) {
|
|
96066
|
+
if (!allDecorators) {
|
|
96067
|
+
return undefined;
|
|
96068
|
+
}
|
|
96069
|
+
var decoratorExpressions = [];
|
|
96070
|
+
ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
|
|
96071
|
+
ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
|
|
96072
|
+
return decoratorExpressions;
|
|
96073
|
+
}
|
|
96074
|
+
/**
|
|
96075
|
+
* Generates statements used to apply decorators to either the static or instance members
|
|
96076
|
+
* of a class.
|
|
96077
|
+
*
|
|
96078
|
+
* @param node The class node.
|
|
96079
|
+
* @param isStatic A value indicating whether to generate statements for static or
|
|
96080
|
+
* instance members.
|
|
96081
|
+
*/
|
|
96082
|
+
function addClassElementDecorationStatements(statements, node, isStatic) {
|
|
96083
|
+
ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), function (expr) { return factory.createExpressionStatement(expr); }));
|
|
96084
|
+
}
|
|
96085
|
+
/**
|
|
96086
|
+
* Determines whether a class member is either a static or an instance member of a class
|
|
96087
|
+
* that is decorated, or has parameters that are decorated.
|
|
96088
|
+
*
|
|
96089
|
+
* @param member The class member.
|
|
96090
|
+
*/
|
|
96091
|
+
function isDecoratedClassElement(member, isStaticElement, parent) {
|
|
96092
|
+
return ts.nodeOrChildIsDecorated(member, parent)
|
|
96093
|
+
&& isStaticElement === ts.isStatic(member);
|
|
96094
|
+
}
|
|
96095
|
+
/**
|
|
96096
|
+
* Gets either the static or instance members of a class that are decorated, or have
|
|
96097
|
+
* parameters that are decorated.
|
|
96098
|
+
*
|
|
96099
|
+
* @param node The class containing the member.
|
|
96100
|
+
* @param isStatic A value indicating whether to retrieve static or instance members of
|
|
96101
|
+
* the class.
|
|
96102
|
+
*/
|
|
96103
|
+
function getDecoratedClassElements(node, isStatic) {
|
|
96104
|
+
return ts.filter(node.members, function (m) { return isDecoratedClassElement(m, isStatic, node); });
|
|
96105
|
+
}
|
|
96106
|
+
/**
|
|
96107
|
+
* Generates expressions used to apply decorators to either the static or instance members
|
|
96108
|
+
* of a class.
|
|
96109
|
+
*
|
|
96110
|
+
* @param node The class node.
|
|
96111
|
+
* @param isStatic A value indicating whether to generate expressions for static or
|
|
96112
|
+
* instance members.
|
|
96113
|
+
*/
|
|
96114
|
+
function generateClassElementDecorationExpressions(node, isStatic) {
|
|
96115
|
+
var members = getDecoratedClassElements(node, isStatic);
|
|
96116
|
+
var expressions;
|
|
96117
|
+
for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
|
|
96118
|
+
var member = members_8[_i];
|
|
96119
|
+
expressions = ts.append(expressions, generateClassElementDecorationExpression(node, member));
|
|
96120
|
+
}
|
|
96121
|
+
return expressions;
|
|
96122
|
+
}
|
|
96123
|
+
/**
|
|
96124
|
+
* Generates an expression used to evaluate class element decorators at runtime.
|
|
96125
|
+
*
|
|
96126
|
+
* @param node The class node that contains the member.
|
|
96127
|
+
* @param member The class member.
|
|
96128
|
+
*/
|
|
96129
|
+
function generateClassElementDecorationExpression(node, member) {
|
|
96130
|
+
var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
|
|
96131
|
+
var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
|
|
96132
|
+
if (!decoratorExpressions) {
|
|
96133
|
+
return undefined;
|
|
96134
|
+
}
|
|
96135
|
+
// Emit the call to __decorate. Given the following:
|
|
96136
|
+
//
|
|
96137
|
+
// class C {
|
|
96138
|
+
// @dec method(@dec2 x) {}
|
|
96139
|
+
// @dec get accessor() {}
|
|
96140
|
+
// @dec prop;
|
|
96141
|
+
// }
|
|
96142
|
+
//
|
|
96143
|
+
// The emit for a method is:
|
|
96144
|
+
//
|
|
96145
|
+
// __decorate([
|
|
96146
|
+
// dec,
|
|
96147
|
+
// __param(0, dec2),
|
|
96148
|
+
// __metadata("design:type", Function),
|
|
96149
|
+
// __metadata("design:paramtypes", [Object]),
|
|
96150
|
+
// __metadata("design:returntype", void 0)
|
|
96151
|
+
// ], C.prototype, "method", null);
|
|
96152
|
+
//
|
|
96153
|
+
// The emit for an accessor is:
|
|
96154
|
+
//
|
|
96155
|
+
// __decorate([
|
|
96156
|
+
// dec
|
|
96157
|
+
// ], C.prototype, "accessor", null);
|
|
96158
|
+
//
|
|
96159
|
+
// The emit for a property is:
|
|
96160
|
+
//
|
|
96161
|
+
// __decorate([
|
|
96162
|
+
// dec
|
|
96163
|
+
// ], C.prototype, "prop");
|
|
96164
|
+
//
|
|
96165
|
+
var prefix = getClassMemberPrefix(node, member);
|
|
96166
|
+
var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
|
|
96167
|
+
var descriptor = languageVersion > 0 /* ES3 */
|
|
96168
|
+
? member.kind === 167 /* PropertyDeclaration */
|
|
96169
|
+
// We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
|
|
96170
|
+
// should not invoke `Object.getOwnPropertyDescriptor`.
|
|
96171
|
+
? factory.createVoidZero()
|
|
96172
|
+
// We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
|
|
96173
|
+
// We have this extra argument here so that we can inject an explicit property descriptor at a later date.
|
|
96174
|
+
: factory.createNull()
|
|
96175
|
+
: undefined;
|
|
96176
|
+
var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
|
|
96177
|
+
ts.setEmitFlags(helper, 1536 /* NoComments */);
|
|
96178
|
+
ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member));
|
|
96179
|
+
return helper;
|
|
96180
|
+
}
|
|
96181
|
+
/**
|
|
96182
|
+
* Generates a __decorate helper call for a class constructor.
|
|
96183
|
+
*
|
|
96184
|
+
* @param node The class node.
|
|
96185
|
+
*/
|
|
96186
|
+
function addConstructorDecorationStatement(statements, node) {
|
|
96187
|
+
var expression = generateConstructorDecorationExpression(node);
|
|
96188
|
+
if (expression) {
|
|
96189
|
+
statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
|
|
96190
|
+
}
|
|
96191
|
+
}
|
|
96192
|
+
/**
|
|
96193
|
+
* Generates a __decorate helper call for a class constructor.
|
|
96194
|
+
*
|
|
96195
|
+
* @param node The class node.
|
|
96196
|
+
*/
|
|
96197
|
+
function generateConstructorDecorationExpression(node) {
|
|
96198
|
+
var allDecorators = ts.getAllDecoratorsOfClass(node);
|
|
96199
|
+
var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
|
|
96200
|
+
if (!decoratorExpressions) {
|
|
96201
|
+
return undefined;
|
|
96202
|
+
}
|
|
96203
|
+
var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
|
|
96204
|
+
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
|
96205
|
+
// without any block-scoped variable collision handling
|
|
96206
|
+
var localName = languageVersion <= 2 /* ES2015 */ ?
|
|
96207
|
+
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
|
96208
|
+
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
|
96209
|
+
var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
|
|
96210
|
+
var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
|
|
96211
|
+
ts.setEmitFlags(expression, 1536 /* NoComments */);
|
|
96212
|
+
ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node));
|
|
96213
|
+
return expression;
|
|
96214
|
+
}
|
|
96215
|
+
/**
|
|
96216
|
+
* Transforms a decorator into an expression.
|
|
96217
|
+
*
|
|
96218
|
+
* @param decorator The decorator node.
|
|
96219
|
+
*/
|
|
96220
|
+
function transformDecorator(decorator) {
|
|
96221
|
+
return ts.visitNode(decorator.expression, visitor, ts.isExpression);
|
|
96222
|
+
}
|
|
96223
|
+
/**
|
|
96224
|
+
* Transforms the decorators of a parameter.
|
|
96225
|
+
*
|
|
96226
|
+
* @param decorators The decorators for the parameter at the provided offset.
|
|
96227
|
+
* @param parameterOffset The offset of the parameter.
|
|
96228
|
+
*/
|
|
96229
|
+
function transformDecoratorsOfParameter(decorators, parameterOffset) {
|
|
96230
|
+
var expressions;
|
|
96231
|
+
if (decorators) {
|
|
96232
|
+
expressions = [];
|
|
96233
|
+
for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
|
|
96234
|
+
var decorator = decorators_1[_i];
|
|
96235
|
+
var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
|
|
96236
|
+
ts.setTextRange(helper, decorator.expression);
|
|
96237
|
+
ts.setEmitFlags(helper, 1536 /* NoComments */);
|
|
96238
|
+
expressions.push(helper);
|
|
96239
|
+
}
|
|
96240
|
+
}
|
|
96241
|
+
return expressions;
|
|
96242
|
+
}
|
|
96243
|
+
/**
|
|
96244
|
+
* Gets an expression that represents a property name (for decorated properties or enums).
|
|
96245
|
+
* For a computed property, a name is generated for the node.
|
|
96246
|
+
*
|
|
96247
|
+
* @param member The member whose name should be converted into an expression.
|
|
96248
|
+
*/
|
|
96249
|
+
function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
|
|
96250
|
+
var name = member.name;
|
|
96251
|
+
if (ts.isPrivateIdentifier(name)) {
|
|
96252
|
+
return factory.createIdentifier("");
|
|
96253
|
+
}
|
|
96254
|
+
else if (ts.isComputedPropertyName(name)) {
|
|
96255
|
+
return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
|
|
96256
|
+
? factory.getGeneratedNameForNode(name)
|
|
96257
|
+
: name.expression;
|
|
96258
|
+
}
|
|
96259
|
+
else if (ts.isIdentifier(name)) {
|
|
96260
|
+
return factory.createStringLiteral(ts.idText(name));
|
|
96261
|
+
}
|
|
96262
|
+
else {
|
|
96263
|
+
return factory.cloneNode(name);
|
|
96264
|
+
}
|
|
96265
|
+
}
|
|
96266
|
+
function enableSubstitutionForClassAliases() {
|
|
96267
|
+
if (!classAliases) {
|
|
96268
|
+
// We need to enable substitutions for identifiers. This allows us to
|
|
96269
|
+
// substitute class names inside of a class declaration.
|
|
96270
|
+
context.enableSubstitution(79 /* Identifier */);
|
|
96271
|
+
// Keep track of class aliases.
|
|
96272
|
+
classAliases = [];
|
|
96273
|
+
}
|
|
96274
|
+
}
|
|
96275
|
+
/**
|
|
96276
|
+
* Gets a local alias for a class declaration if it is a decorated class with an internal
|
|
96277
|
+
* reference to the static side of the class. This is necessary to avoid issues with
|
|
96278
|
+
* double-binding semantics for the class name.
|
|
96279
|
+
*/
|
|
96280
|
+
function getClassAliasIfNeeded(node) {
|
|
96281
|
+
if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
|
|
96282
|
+
enableSubstitutionForClassAliases();
|
|
96283
|
+
var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
|
|
96284
|
+
classAliases[ts.getOriginalNodeId(node)] = classAlias;
|
|
96285
|
+
hoistVariableDeclaration(classAlias);
|
|
96286
|
+
return classAlias;
|
|
96287
|
+
}
|
|
96288
|
+
}
|
|
96289
|
+
function getClassPrototype(node) {
|
|
96290
|
+
return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
|
|
96291
|
+
}
|
|
96292
|
+
function getClassMemberPrefix(node, member) {
|
|
96293
|
+
return ts.isStatic(member)
|
|
96294
|
+
? factory.getDeclarationName(node)
|
|
96295
|
+
: getClassPrototype(node);
|
|
96296
|
+
}
|
|
96297
|
+
/**
|
|
96298
|
+
* Hooks node substitutions.
|
|
96299
|
+
*
|
|
96300
|
+
* @param hint A hint as to the intended usage of the node.
|
|
96301
|
+
* @param node The node to substitute.
|
|
96302
|
+
*/
|
|
96303
|
+
function onSubstituteNode(hint, node) {
|
|
96304
|
+
node = previousOnSubstituteNode(hint, node);
|
|
96305
|
+
if (hint === 1 /* Expression */) {
|
|
96306
|
+
return substituteExpression(node);
|
|
96307
|
+
}
|
|
96308
|
+
return node;
|
|
96309
|
+
}
|
|
96310
|
+
function substituteExpression(node) {
|
|
96311
|
+
switch (node.kind) {
|
|
96312
|
+
case 79 /* Identifier */:
|
|
96313
|
+
return substituteExpressionIdentifier(node);
|
|
96314
|
+
}
|
|
96315
|
+
return node;
|
|
96316
|
+
}
|
|
96317
|
+
function substituteExpressionIdentifier(node) {
|
|
96318
|
+
var _a;
|
|
96319
|
+
return (_a = trySubstituteClassAlias(node)) !== null && _a !== void 0 ? _a : node;
|
|
96320
|
+
}
|
|
96321
|
+
function trySubstituteClassAlias(node) {
|
|
96322
|
+
if (classAliases) {
|
|
96323
|
+
if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
|
|
96324
|
+
// Due to the emit for class decorators, any reference to the class from inside of the class body
|
|
96325
|
+
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
|
|
96326
|
+
// behavior of class names in ES6.
|
|
96327
|
+
// Also, when emitting statics for class expressions, we must substitute a class alias for
|
|
96328
|
+
// constructor references in static property initializers.
|
|
96329
|
+
var declaration = resolver.getReferencedValueDeclaration(node);
|
|
96330
|
+
if (declaration) {
|
|
96331
|
+
var classAlias = classAliases[declaration.id]; // TODO: GH#18217
|
|
96332
|
+
if (classAlias) {
|
|
96333
|
+
var clone_3 = factory.cloneNode(classAlias);
|
|
96334
|
+
ts.setSourceMapRange(clone_3, node);
|
|
96335
|
+
ts.setCommentRange(clone_3, node);
|
|
96336
|
+
return clone_3;
|
|
96337
|
+
}
|
|
96338
|
+
}
|
|
96339
|
+
}
|
|
96340
|
+
}
|
|
96341
|
+
return undefined;
|
|
96342
|
+
}
|
|
96343
|
+
}
|
|
96344
|
+
ts.transformLegacyDecorators = transformLegacyDecorators;
|
|
96345
|
+
})(ts || (ts = {}));
|
|
96346
|
+
/*@internal*/
|
|
96347
|
+
var ts;
|
|
95955
96348
|
(function (ts) {
|
|
95956
96349
|
var ES2017SubstitutionFlags;
|
|
95957
96350
|
(function (ES2017SubstitutionFlags) {
|
|
@@ -96800,7 +97193,7 @@ var ts;
|
|
|
96800
97193
|
return objects;
|
|
96801
97194
|
}
|
|
96802
97195
|
function visitObjectLiteralExpression(node) {
|
|
96803
|
-
if (node.transformFlags &
|
|
97196
|
+
if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96804
97197
|
// spread elements emit like so:
|
|
96805
97198
|
// non-spread elements are chunked together into object literals, and then all are passed to __assign:
|
|
96806
97199
|
// { a, ...o, b } => __assign(__assign({a}, o), {b});
|
|
@@ -96873,7 +97266,7 @@ var ts;
|
|
|
96873
97266
|
* expression of an `ExpressionStatement`).
|
|
96874
97267
|
*/
|
|
96875
97268
|
function visitBinaryExpression(node, expressionResultIsUnused) {
|
|
96876
|
-
if (ts.isDestructuringAssignment(node) && node.left.transformFlags &
|
|
97269
|
+
if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96877
97270
|
return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
|
|
96878
97271
|
}
|
|
96879
97272
|
if (node.operatorToken.kind === 27 /* CommaToken */) {
|
|
@@ -96904,7 +97297,7 @@ var ts;
|
|
|
96904
97297
|
function visitCatchClause(node) {
|
|
96905
97298
|
if (node.variableDeclaration &&
|
|
96906
97299
|
ts.isBindingPattern(node.variableDeclaration.name) &&
|
|
96907
|
-
node.variableDeclaration.name.transformFlags &
|
|
97300
|
+
node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96908
97301
|
var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
|
|
96909
97302
|
var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
|
|
96910
97303
|
var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
|
|
@@ -96945,7 +97338,7 @@ var ts;
|
|
|
96945
97338
|
}
|
|
96946
97339
|
function visitVariableDeclarationWorker(node, exportedVariableStatement) {
|
|
96947
97340
|
// If we are here it is because the name contains a binding pattern with a rest somewhere in it.
|
|
96948
|
-
if (ts.isBindingPattern(node.name) && node.name.transformFlags &
|
|
97341
|
+
if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96949
97342
|
return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
|
|
96950
97343
|
/*rval*/ undefined, exportedVariableStatement);
|
|
96951
97344
|
}
|
|
@@ -96964,7 +97357,7 @@ var ts;
|
|
|
96964
97357
|
*/
|
|
96965
97358
|
function visitForOfStatement(node, outermostLabeledStatement) {
|
|
96966
97359
|
var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
|
|
96967
|
-
if (node.initializer.transformFlags &
|
|
97360
|
+
if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96968
97361
|
node = transformForOfStatementWithObjectRest(node);
|
|
96969
97362
|
}
|
|
96970
97363
|
var result = node.awaitModifier ?
|
|
@@ -97077,7 +97470,7 @@ var ts;
|
|
|
97077
97470
|
/*type*/ undefined,
|
|
97078
97471
|
/*initializer*/ undefined);
|
|
97079
97472
|
}
|
|
97080
|
-
if (node.transformFlags &
|
|
97473
|
+
if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
97081
97474
|
// Binding patterns are converted into a generated name and are
|
|
97082
97475
|
// evaluated inside the function body.
|
|
97083
97476
|
return factory.updateParameterDeclaration(node,
|
|
@@ -97095,7 +97488,7 @@ var ts;
|
|
|
97095
97488
|
if (parameters) {
|
|
97096
97489
|
parameters.add(parameter);
|
|
97097
97490
|
}
|
|
97098
|
-
else if (parameter.transformFlags &
|
|
97491
|
+
else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
97099
97492
|
parameters = new ts.Set();
|
|
97100
97493
|
}
|
|
97101
97494
|
}
|
|
@@ -97318,7 +97711,7 @@ var ts;
|
|
|
97318
97711
|
statements = ts.append(statements, statement);
|
|
97319
97712
|
}
|
|
97320
97713
|
}
|
|
97321
|
-
else if (parameter.transformFlags &
|
|
97714
|
+
else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
97322
97715
|
containsPrecedingObjectRestOrSpread = true;
|
|
97323
97716
|
var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
|
|
97324
97717
|
/*doNotRecordTempVariablesInLine*/ false,
|
|
@@ -98690,7 +99083,7 @@ var ts;
|
|
|
98690
99083
|
&& !node.expression;
|
|
98691
99084
|
}
|
|
98692
99085
|
function isOrMayContainReturnCompletion(node) {
|
|
98693
|
-
return node.transformFlags &
|
|
99086
|
+
return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */
|
|
98694
99087
|
&& (ts.isReturnStatement(node)
|
|
98695
99088
|
|| ts.isIfStatement(node)
|
|
98696
99089
|
|| ts.isWithStatement(node)
|
|
@@ -99254,7 +99647,7 @@ var ts;
|
|
|
99254
99647
|
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
99255
99648
|
insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
|
|
99256
99649
|
if (isDerivedClass || superCallExpression) {
|
|
99257
|
-
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags &
|
|
99650
|
+
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
|
|
99258
99651
|
// If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
|
|
99259
99652
|
// following representation:
|
|
99260
99653
|
//
|
|
@@ -99799,7 +100192,7 @@ var ts;
|
|
|
99799
100192
|
* @param node An ArrowFunction node.
|
|
99800
100193
|
*/
|
|
99801
100194
|
function visitArrowFunction(node) {
|
|
99802
|
-
if (node.transformFlags &
|
|
100195
|
+
if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
99803
100196
|
hierarchyFacts |= 65536 /* CapturedLexicalThis */;
|
|
99804
100197
|
}
|
|
99805
100198
|
var savedConvertedLoopState = convertedLoopState;
|
|
@@ -100085,7 +100478,7 @@ var ts;
|
|
|
100085
100478
|
* @param node A VariableDeclarationList node.
|
|
100086
100479
|
*/
|
|
100087
100480
|
function visitVariableDeclarationList(node) {
|
|
100088
|
-
if (node.flags & 3 /* BlockScoped */ || node.transformFlags &
|
|
100481
|
+
if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) {
|
|
100089
100482
|
if (node.flags & 3 /* BlockScoped */) {
|
|
100090
100483
|
enableSubstitutionsForBlockScopedBindings();
|
|
100091
100484
|
}
|
|
@@ -100098,7 +100491,7 @@ var ts;
|
|
|
100098
100491
|
ts.setCommentRange(declarationList, node);
|
|
100099
100492
|
// If the first or last declaration is a binding pattern, we need to modify
|
|
100100
100493
|
// the source map range for the declaration list.
|
|
100101
|
-
if (node.transformFlags &
|
|
100494
|
+
if (node.transformFlags & 524288 /* ContainsBindingPattern */
|
|
100102
100495
|
&& (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
|
|
100103
100496
|
ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
|
|
100104
100497
|
}
|
|
@@ -100422,7 +100815,7 @@ var ts;
|
|
|
100422
100815
|
var numInitialProperties = -1, hasComputed = false;
|
|
100423
100816
|
for (var i = 0; i < properties.length; i++) {
|
|
100424
100817
|
var property = properties[i];
|
|
100425
|
-
if ((property.transformFlags &
|
|
100818
|
+
if ((property.transformFlags & 1048576 /* ContainsYield */ &&
|
|
100426
100819
|
hierarchyFacts & 4 /* AsyncFunctionBody */)
|
|
100427
100820
|
|| (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) {
|
|
100428
100821
|
numInitialProperties = i;
|
|
@@ -100695,7 +101088,7 @@ var ts;
|
|
|
100695
101088
|
*/
|
|
100696
101089
|
function createFunctionForInitializerOfForStatement(node, currentState) {
|
|
100697
101090
|
var functionName = factory.createUniqueName("_loop_init");
|
|
100698
|
-
var containsYield = (node.initializer.transformFlags &
|
|
101091
|
+
var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0;
|
|
100699
101092
|
var emitFlags = 0 /* None */;
|
|
100700
101093
|
if (currentState.containsLexicalThis)
|
|
100701
101094
|
emitFlags |= 8 /* CapturesThis */;
|
|
@@ -100810,7 +101203,7 @@ var ts;
|
|
|
100810
101203
|
var loopBody = factory.createBlock(statements, /*multiLine*/ true);
|
|
100811
101204
|
if (ts.isBlock(statement))
|
|
100812
101205
|
ts.setOriginalNode(loopBody, statement);
|
|
100813
|
-
var containsYield = (node.statement.transformFlags &
|
|
101206
|
+
var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0;
|
|
100814
101207
|
var emitFlags = 524288 /* ReuseTempVariableScope */;
|
|
100815
101208
|
if (currentState.containsLexicalThis)
|
|
100816
101209
|
emitFlags |= 8 /* CapturesThis */;
|
|
@@ -101292,7 +101685,7 @@ var ts;
|
|
|
101292
101685
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
101293
101686
|
// We are here either because SuperKeyword was used somewhere in the expression, or
|
|
101294
101687
|
// because we contain a SpreadElementExpression.
|
|
101295
|
-
if (node.transformFlags &
|
|
101688
|
+
if (node.transformFlags & 32768 /* ContainsRestOrSpread */ ||
|
|
101296
101689
|
node.expression.kind === 106 /* SuperKeyword */ ||
|
|
101297
101690
|
ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
|
|
101298
101691
|
var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
|
|
@@ -101300,7 +101693,7 @@ var ts;
|
|
|
101300
101693
|
ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
|
|
101301
101694
|
}
|
|
101302
101695
|
var resultingCall = void 0;
|
|
101303
|
-
if (node.transformFlags &
|
|
101696
|
+
if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
|
|
101304
101697
|
// [source]
|
|
101305
101698
|
// f(...a, b)
|
|
101306
101699
|
// x.m(...a, b)
|
|
@@ -102142,10 +102535,10 @@ var ts;
|
|
|
102142
102535
|
case 247 /* ReturnStatement */:
|
|
102143
102536
|
return visitReturnStatement(node);
|
|
102144
102537
|
default:
|
|
102145
|
-
if (node.transformFlags &
|
|
102538
|
+
if (node.transformFlags & 1048576 /* ContainsYield */) {
|
|
102146
102539
|
return visitJavaScriptContainingYield(node);
|
|
102147
102540
|
}
|
|
102148
|
-
else if (node.transformFlags & (2048 /* ContainsGenerator */ |
|
|
102541
|
+
else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) {
|
|
102149
102542
|
return ts.visitEachChild(node, visitor, context);
|
|
102150
102543
|
}
|
|
102151
102544
|
else {
|
|
@@ -102350,7 +102743,7 @@ var ts;
|
|
|
102350
102743
|
* @param node The node to visit.
|
|
102351
102744
|
*/
|
|
102352
102745
|
function visitVariableStatement(node) {
|
|
102353
|
-
if (node.transformFlags &
|
|
102746
|
+
if (node.transformFlags & 1048576 /* ContainsYield */) {
|
|
102354
102747
|
transformAndEmitVariableDeclarationList(node.declarationList);
|
|
102355
102748
|
return undefined;
|
|
102356
102749
|
}
|
|
@@ -103408,7 +103801,7 @@ var ts;
|
|
|
103408
103801
|
}
|
|
103409
103802
|
}
|
|
103410
103803
|
function containsYield(node) {
|
|
103411
|
-
return !!node && (node.transformFlags &
|
|
103804
|
+
return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0;
|
|
103412
103805
|
}
|
|
103413
103806
|
function countInitialNodesWithoutYield(nodes) {
|
|
103414
103807
|
var numNodes = nodes.length;
|
|
@@ -104457,7 +104850,7 @@ var ts;
|
|
|
104457
104850
|
function transformSourceFile(node) {
|
|
104458
104851
|
if (node.isDeclarationFile ||
|
|
104459
104852
|
!(ts.isEffectiveExternalModule(node, compilerOptions) ||
|
|
104460
|
-
node.transformFlags &
|
|
104853
|
+
node.transformFlags & 8388608 /* ContainsDynamicImport */ ||
|
|
104461
104854
|
(ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
|
|
104462
104855
|
return node;
|
|
104463
104856
|
}
|
|
@@ -104794,7 +105187,7 @@ var ts;
|
|
|
104794
105187
|
function visitorWorker(node, valueIsDiscarded) {
|
|
104795
105188
|
// This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
|
|
104796
105189
|
// as export/import statements are only transformed at the top level of a file.
|
|
104797
|
-
if (!(node.transformFlags & (
|
|
105190
|
+
if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
|
|
104798
105191
|
return node;
|
|
104799
105192
|
}
|
|
104800
105193
|
switch (node.kind) {
|
|
@@ -104945,7 +105338,7 @@ var ts;
|
|
|
104945
105338
|
var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
|
|
104946
105339
|
// 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.
|
|
104947
105340
|
var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
|
|
104948
|
-
var containsLexicalThis = !!(node.transformFlags &
|
|
105341
|
+
var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
|
|
104949
105342
|
switch (compilerOptions.module) {
|
|
104950
105343
|
case ts.ModuleKind.AMD:
|
|
104951
105344
|
return createImportCallExpressionAMD(argument, containsLexicalThis);
|
|
@@ -105932,7 +106325,7 @@ var ts;
|
|
|
105932
106325
|
* @param node The SourceFile node.
|
|
105933
106326
|
*/
|
|
105934
106327
|
function transformSourceFile(node) {
|
|
105935
|
-
if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags &
|
|
106328
|
+
if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) {
|
|
105936
106329
|
return node;
|
|
105937
106330
|
}
|
|
105938
106331
|
var id = ts.getOriginalNodeId(node);
|
|
@@ -106101,7 +106494,7 @@ var ts;
|
|
|
106101
106494
|
// - Temporary variables will appear at the top rather than at the bottom of the file
|
|
106102
106495
|
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
|
|
106103
106496
|
var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
|
|
106104
|
-
var modifiers = node.transformFlags &
|
|
106497
|
+
var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ?
|
|
106105
106498
|
factory.createModifiersFromModifierFlags(256 /* Async */) :
|
|
106106
106499
|
undefined;
|
|
106107
106500
|
var moduleObject = factory.createObjectLiteralExpression([
|
|
@@ -107010,7 +107403,7 @@ var ts;
|
|
|
107010
107403
|
* @param node The node to visit.
|
|
107011
107404
|
*/
|
|
107012
107405
|
function visitorWorker(node, valueIsDiscarded) {
|
|
107013
|
-
if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ |
|
|
107406
|
+
if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
|
|
107014
107407
|
return node;
|
|
107015
107408
|
}
|
|
107016
107409
|
switch (node.kind) {
|
|
@@ -109553,6 +109946,7 @@ var ts;
|
|
|
109553
109946
|
var transformers = [];
|
|
109554
109947
|
ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
|
|
109555
109948
|
transformers.push(ts.transformTypeScript);
|
|
109949
|
+
transformers.push(ts.transformLegacyDecorators);
|
|
109556
109950
|
transformers.push(ts.transformClassFields);
|
|
109557
109951
|
if (ts.getJSXTransformEnabled(compilerOptions)) {
|
|
109558
109952
|
transformers.push(ts.transformJsx);
|
|
@@ -125852,7 +126246,7 @@ var ts;
|
|
|
125852
126246
|
* @param typeAcquisition is used to customize the typing acquisition process
|
|
125853
126247
|
* @param compilerOptions are used as a source for typing inference
|
|
125854
126248
|
*/
|
|
125855
|
-
function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
|
|
126249
|
+
function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
|
|
125856
126250
|
if (!typeAcquisition || !typeAcquisition.enable) {
|
|
125857
126251
|
return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
|
|
125858
126252
|
}
|
|
@@ -125870,12 +126264,14 @@ var ts;
|
|
|
125870
126264
|
addInferredTypings(typeAcquisition.include, "Explicitly included types");
|
|
125871
126265
|
var exclude = typeAcquisition.exclude || [];
|
|
125872
126266
|
// Directories to search for package.json, bower.json and other typing information
|
|
125873
|
-
|
|
125874
|
-
|
|
125875
|
-
|
|
125876
|
-
|
|
125877
|
-
|
|
125878
|
-
|
|
126267
|
+
if (!compilerOptions.types) {
|
|
126268
|
+
var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
|
|
126269
|
+
possibleSearchDirs.add(projectRootPath);
|
|
126270
|
+
possibleSearchDirs.forEach(function (searchDir) {
|
|
126271
|
+
getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
|
|
126272
|
+
getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
|
|
126273
|
+
});
|
|
126274
|
+
}
|
|
125879
126275
|
if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
|
|
125880
126276
|
getTypingNamesFromSourceFileNames(fileNames);
|
|
125881
126277
|
}
|
|
@@ -126251,7 +126647,7 @@ var ts;
|
|
|
126251
126647
|
if (this.safeList === undefined) {
|
|
126252
126648
|
this.initializeSafeList();
|
|
126253
126649
|
}
|
|
126254
|
-
var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports, this.typesRegistry);
|
|
126650
|
+
var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports, this.typesRegistry, req.compilerOptions);
|
|
126255
126651
|
if (this.log.isEnabled()) {
|
|
126256
126652
|
this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult));
|
|
126257
126653
|
}
|