@typescript-deploys/pr-build 5.5.0-pr-58028-14 → 5.5.0-pr-58045-49
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 +354 -244
- package/lib/typescript.d.ts +0 -57
- package/lib/typescript.js +404 -273
- package/package.json +2 -3
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20240404`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -7369,7 +7369,6 @@ var Diagnostics = {
|
|
|
7369
7369
|
Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
|
|
7370
7370
|
Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
|
|
7371
7371
|
Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
|
|
7372
|
-
Default_type_arguments_to_parameter_s_constraint_or_unknown_instead_of_any_for_instance_checks: diag(6805, 3 /* Message */, "Default_type_arguments_to_parameter_s_constraint_or_unknown_instead_of_any_for_instance_checks_6805", "Default type arguments to parameter's constraint or 'unknown' instead of 'any' for instance checks."),
|
|
7373
7372
|
one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
|
|
7374
7373
|
one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
|
|
7375
7374
|
type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
|
|
@@ -11748,8 +11747,11 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
|
|
|
11748
11747
|
if (includeJsDoc && hasJSDocNodes(node)) {
|
|
11749
11748
|
return getTokenPosOfNode(node.jsDoc[0], sourceFile);
|
|
11750
11749
|
}
|
|
11751
|
-
if (node.kind === 352 /* SyntaxList */
|
|
11752
|
-
|
|
11750
|
+
if (node.kind === 352 /* SyntaxList */) {
|
|
11751
|
+
const first2 = firstOrUndefined(getNodeChildren(node));
|
|
11752
|
+
if (first2) {
|
|
11753
|
+
return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
|
|
11754
|
+
}
|
|
11753
11755
|
}
|
|
11754
11756
|
return skipTrivia(
|
|
11755
11757
|
(sourceFile || getSourceFileOfNode(node)).text,
|
|
@@ -16597,12 +16599,6 @@ var computedOptions = createComputedCompilerOptions({
|
|
|
16597
16599
|
computeValue: (compilerOptions) => {
|
|
16598
16600
|
return getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
|
|
16599
16601
|
}
|
|
16600
|
-
},
|
|
16601
|
-
strictInstanceOfTypeParameters: {
|
|
16602
|
-
dependencies: ["strict"],
|
|
16603
|
-
computeValue: (compilerOptions) => {
|
|
16604
|
-
return getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
|
|
16605
|
-
}
|
|
16606
16602
|
}
|
|
16607
16603
|
});
|
|
16608
16604
|
var getEmitScriptTarget = computedOptions.target.computeValue;
|
|
@@ -17694,79 +17690,81 @@ function replaceFirstStar(s, replacement) {
|
|
|
17694
17690
|
function getNameFromImportAttribute(node) {
|
|
17695
17691
|
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17696
17692
|
}
|
|
17697
|
-
function isSyntacticallyString
|
|
17698
|
-
|
|
17699
|
-
switch (expr.kind) {
|
|
17700
|
-
case 226 /* BinaryExpression */:
|
|
17701
|
-
const left = expr.left;
|
|
17702
|
-
const right = expr.right;
|
|
17703
|
-
return expr.operatorToken.kind === 40 /* PlusToken */ && (isSyntacticallyString(left) || isSyntacticallyString(right));
|
|
17704
|
-
case 228 /* TemplateExpression */:
|
|
17705
|
-
case 11 /* StringLiteral */:
|
|
17706
|
-
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
17707
|
-
return true;
|
|
17708
|
-
}
|
|
17709
|
-
return false;
|
|
17693
|
+
function evaluatorResult(value, isSyntacticallyString = false, resolvedOtherFiles = false) {
|
|
17694
|
+
return { value, isSyntacticallyString, resolvedOtherFiles };
|
|
17710
17695
|
}
|
|
17711
17696
|
function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
|
|
17712
17697
|
function evaluate(expr, location) {
|
|
17698
|
+
let isSyntacticallyString = false;
|
|
17699
|
+
let resolvedOtherFiles = false;
|
|
17700
|
+
expr = skipParentheses(expr);
|
|
17713
17701
|
switch (expr.kind) {
|
|
17714
17702
|
case 224 /* PrefixUnaryExpression */:
|
|
17715
|
-
const
|
|
17716
|
-
|
|
17703
|
+
const result = evaluate(expr.operand, location);
|
|
17704
|
+
resolvedOtherFiles = result.resolvedOtherFiles;
|
|
17705
|
+
if (typeof result.value === "number") {
|
|
17717
17706
|
switch (expr.operator) {
|
|
17718
17707
|
case 40 /* PlusToken */:
|
|
17719
|
-
return value;
|
|
17708
|
+
return evaluatorResult(result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17720
17709
|
case 41 /* MinusToken */:
|
|
17721
|
-
return -value;
|
|
17710
|
+
return evaluatorResult(-result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17722
17711
|
case 55 /* TildeToken */:
|
|
17723
|
-
return ~value;
|
|
17712
|
+
return evaluatorResult(~result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17724
17713
|
}
|
|
17725
17714
|
}
|
|
17726
17715
|
break;
|
|
17727
|
-
case 226 /* BinaryExpression */:
|
|
17716
|
+
case 226 /* BinaryExpression */: {
|
|
17728
17717
|
const left = evaluate(expr.left, location);
|
|
17729
17718
|
const right = evaluate(expr.right, location);
|
|
17730
|
-
|
|
17719
|
+
isSyntacticallyString = (left.isSyntacticallyString || right.isSyntacticallyString) && expr.operatorToken.kind === 40 /* PlusToken */;
|
|
17720
|
+
resolvedOtherFiles = left.resolvedOtherFiles || right.resolvedOtherFiles;
|
|
17721
|
+
if (typeof left.value === "number" && typeof right.value === "number") {
|
|
17731
17722
|
switch (expr.operatorToken.kind) {
|
|
17732
17723
|
case 52 /* BarToken */:
|
|
17733
|
-
return left | right;
|
|
17724
|
+
return evaluatorResult(left.value | right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17734
17725
|
case 51 /* AmpersandToken */:
|
|
17735
|
-
return left & right;
|
|
17726
|
+
return evaluatorResult(left.value & right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17736
17727
|
case 49 /* GreaterThanGreaterThanToken */:
|
|
17737
|
-
return left >> right;
|
|
17728
|
+
return evaluatorResult(left.value >> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17738
17729
|
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
17739
|
-
return left >>> right;
|
|
17730
|
+
return evaluatorResult(left.value >>> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17740
17731
|
case 48 /* LessThanLessThanToken */:
|
|
17741
|
-
return left << right;
|
|
17732
|
+
return evaluatorResult(left.value << right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17742
17733
|
case 53 /* CaretToken */:
|
|
17743
|
-
return left ^ right;
|
|
17734
|
+
return evaluatorResult(left.value ^ right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17744
17735
|
case 42 /* AsteriskToken */:
|
|
17745
|
-
return left * right;
|
|
17736
|
+
return evaluatorResult(left.value * right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17746
17737
|
case 44 /* SlashToken */:
|
|
17747
|
-
return left / right;
|
|
17738
|
+
return evaluatorResult(left.value / right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17748
17739
|
case 40 /* PlusToken */:
|
|
17749
|
-
return left + right;
|
|
17740
|
+
return evaluatorResult(left.value + right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17750
17741
|
case 41 /* MinusToken */:
|
|
17751
|
-
return left - right;
|
|
17742
|
+
return evaluatorResult(left.value - right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17752
17743
|
case 45 /* PercentToken */:
|
|
17753
|
-
return left % right;
|
|
17744
|
+
return evaluatorResult(left.value % right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17754
17745
|
case 43 /* AsteriskAsteriskToken */:
|
|
17755
|
-
return left ** right;
|
|
17746
|
+
return evaluatorResult(left.value ** right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
17756
17747
|
}
|
|
17757
|
-
} else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17758
|
-
return
|
|
17748
|
+
} else if ((typeof left.value === "string" || typeof left.value === "number") && (typeof right.value === "string" || typeof right.value === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17749
|
+
return evaluatorResult(
|
|
17750
|
+
"" + left.value + right.value,
|
|
17751
|
+
isSyntacticallyString,
|
|
17752
|
+
resolvedOtherFiles
|
|
17753
|
+
);
|
|
17759
17754
|
}
|
|
17760
17755
|
break;
|
|
17756
|
+
}
|
|
17761
17757
|
case 11 /* StringLiteral */:
|
|
17762
17758
|
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
17763
|
-
return
|
|
17759
|
+
return evaluatorResult(
|
|
17760
|
+
expr.text,
|
|
17761
|
+
/*isSyntacticallyString*/
|
|
17762
|
+
true
|
|
17763
|
+
);
|
|
17764
17764
|
case 228 /* TemplateExpression */:
|
|
17765
17765
|
return evaluateTemplateExpression(expr, location);
|
|
17766
17766
|
case 9 /* NumericLiteral */:
|
|
17767
|
-
return +expr.text;
|
|
17768
|
-
case 217 /* ParenthesizedExpression */:
|
|
17769
|
-
return evaluate(expr.expression, location);
|
|
17767
|
+
return evaluatorResult(+expr.text);
|
|
17770
17768
|
case 80 /* Identifier */:
|
|
17771
17769
|
return evaluateEntityNameExpression(expr, location);
|
|
17772
17770
|
case 211 /* PropertyAccessExpression */:
|
|
@@ -17777,19 +17775,36 @@ function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameEx
|
|
|
17777
17775
|
case 212 /* ElementAccessExpression */:
|
|
17778
17776
|
return evaluateElementAccessExpression(expr, location);
|
|
17779
17777
|
}
|
|
17780
|
-
return
|
|
17778
|
+
return evaluatorResult(
|
|
17779
|
+
/*value*/
|
|
17780
|
+
void 0,
|
|
17781
|
+
isSyntacticallyString,
|
|
17782
|
+
resolvedOtherFiles
|
|
17783
|
+
);
|
|
17781
17784
|
}
|
|
17782
17785
|
function evaluateTemplateExpression(expr, location) {
|
|
17783
17786
|
let result = expr.head.text;
|
|
17787
|
+
let resolvedOtherFiles = false;
|
|
17784
17788
|
for (const span of expr.templateSpans) {
|
|
17785
|
-
const
|
|
17786
|
-
if (value === void 0) {
|
|
17787
|
-
return
|
|
17789
|
+
const spanResult = evaluate(span.expression, location);
|
|
17790
|
+
if (spanResult.value === void 0) {
|
|
17791
|
+
return evaluatorResult(
|
|
17792
|
+
/*value*/
|
|
17793
|
+
void 0,
|
|
17794
|
+
/*isSyntacticallyString*/
|
|
17795
|
+
true
|
|
17796
|
+
);
|
|
17788
17797
|
}
|
|
17789
|
-
result += value;
|
|
17798
|
+
result += spanResult.value;
|
|
17790
17799
|
result += span.literal.text;
|
|
17800
|
+
resolvedOtherFiles || (resolvedOtherFiles = spanResult.resolvedOtherFiles);
|
|
17791
17801
|
}
|
|
17792
|
-
return
|
|
17802
|
+
return evaluatorResult(
|
|
17803
|
+
result,
|
|
17804
|
+
/*isSyntacticallyString*/
|
|
17805
|
+
true,
|
|
17806
|
+
resolvedOtherFiles
|
|
17807
|
+
);
|
|
17793
17808
|
}
|
|
17794
17809
|
return evaluate;
|
|
17795
17810
|
}
|
|
@@ -21933,7 +21948,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21933
21948
|
}
|
|
21934
21949
|
function createSyntaxList(children) {
|
|
21935
21950
|
const node = createBaseNode(352 /* SyntaxList */);
|
|
21936
|
-
node
|
|
21951
|
+
setNodeChildren(node, children);
|
|
21937
21952
|
return node;
|
|
21938
21953
|
}
|
|
21939
21954
|
function createNotEmittedStatement(original) {
|
|
@@ -24710,6 +24725,19 @@ function isJSDocImportTag(node) {
|
|
|
24710
24725
|
return node.kind === 351 /* JSDocImportTag */;
|
|
24711
24726
|
}
|
|
24712
24727
|
|
|
24728
|
+
// src/compiler/factory/nodeChildren.ts
|
|
24729
|
+
var nodeChildren = /* @__PURE__ */ new WeakMap();
|
|
24730
|
+
function getNodeChildren(node) {
|
|
24731
|
+
return nodeChildren.get(node);
|
|
24732
|
+
}
|
|
24733
|
+
function setNodeChildren(node, children) {
|
|
24734
|
+
nodeChildren.set(node, children);
|
|
24735
|
+
return children;
|
|
24736
|
+
}
|
|
24737
|
+
function unsetNodeChildren(node) {
|
|
24738
|
+
nodeChildren.delete(node);
|
|
24739
|
+
}
|
|
24740
|
+
|
|
24713
24741
|
// src/compiler/factory/utilities.ts
|
|
24714
24742
|
function createEmptyExports(factory2) {
|
|
24715
24743
|
return factory2.createExportDeclaration(
|
|
@@ -33341,9 +33369,7 @@ var IncrementalParser;
|
|
|
33341
33369
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
33342
33370
|
text = oldText.substring(node.pos, node.end);
|
|
33343
33371
|
}
|
|
33344
|
-
|
|
33345
|
-
node._children = void 0;
|
|
33346
|
-
}
|
|
33372
|
+
unsetNodeChildren(node);
|
|
33347
33373
|
setTextRangePosEnd(node, node.pos + delta, node.end + delta);
|
|
33348
33374
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
33349
33375
|
Debug.assert(text === newText.substring(node.pos, node.end));
|
|
@@ -33357,7 +33383,6 @@ var IncrementalParser;
|
|
|
33357
33383
|
checkNodePositions(node, aggressiveChecks);
|
|
33358
33384
|
}
|
|
33359
33385
|
function visitArray2(array) {
|
|
33360
|
-
array._children = void 0;
|
|
33361
33386
|
setTextRangePosEnd(array, array.pos + delta, array.end + delta);
|
|
33362
33387
|
for (const node of array) {
|
|
33363
33388
|
visitNode3(node);
|
|
@@ -33429,7 +33454,7 @@ var IncrementalParser;
|
|
|
33429
33454
|
const fullEnd = child.end;
|
|
33430
33455
|
if (fullEnd >= changeStart) {
|
|
33431
33456
|
child.intersectsChange = true;
|
|
33432
|
-
child
|
|
33457
|
+
unsetNodeChildren(child);
|
|
33433
33458
|
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
33434
33459
|
forEachChild(child, visitNode3, visitArray2);
|
|
33435
33460
|
if (hasJSDocNodes(child)) {
|
|
@@ -33459,7 +33484,6 @@ var IncrementalParser;
|
|
|
33459
33484
|
const fullEnd = array.end;
|
|
33460
33485
|
if (fullEnd >= changeStart) {
|
|
33461
33486
|
array.intersectsChange = true;
|
|
33462
|
-
array._children = void 0;
|
|
33463
33487
|
adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
33464
33488
|
for (const node of array) {
|
|
33465
33489
|
visitNode3(node);
|
|
@@ -34569,16 +34593,6 @@ var commandOptionsWithoutBuild = [
|
|
|
34569
34593
|
description: Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
|
|
34570
34594
|
defaultValueDescription: Diagnostics.false_unless_strict_is_set
|
|
34571
34595
|
},
|
|
34572
|
-
{
|
|
34573
|
-
name: "strictInstanceOfTypeParameters",
|
|
34574
|
-
type: "boolean",
|
|
34575
|
-
affectsSemanticDiagnostics: true,
|
|
34576
|
-
affectsBuildInfo: true,
|
|
34577
|
-
strictFlag: true,
|
|
34578
|
-
category: Diagnostics.Type_Checking,
|
|
34579
|
-
description: Diagnostics.Default_type_arguments_to_parameter_s_constraint_or_unknown_instead_of_any_for_instance_checks,
|
|
34580
|
-
defaultValueDescription: false
|
|
34581
|
-
},
|
|
34582
34596
|
{
|
|
34583
34597
|
name: "noImplicitThis",
|
|
34584
34598
|
type: "boolean",
|
|
@@ -43519,7 +43533,6 @@ function createTypeChecker(host) {
|
|
|
43519
43533
|
var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
|
|
43520
43534
|
var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
|
|
43521
43535
|
var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
|
|
43522
|
-
var strictInstanceOfTypeParameters = getStrictOptionValue(compilerOptions, "strictInstanceOfTypeParameters");
|
|
43523
43536
|
var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
|
|
43524
43537
|
var checkBinaryExpression = createCheckBinaryExpression();
|
|
43525
43538
|
var emitResolver = createResolver();
|
|
@@ -43560,6 +43573,7 @@ function createTypeChecker(host) {
|
|
|
43560
43573
|
isArgumentsSymbol: (symbol) => symbol === argumentsSymbol,
|
|
43561
43574
|
isUnknownSymbol: (symbol) => symbol === unknownSymbol,
|
|
43562
43575
|
getMergedSymbol,
|
|
43576
|
+
symbolIsValue,
|
|
43563
43577
|
getDiagnostics,
|
|
43564
43578
|
getGlobalDiagnostics,
|
|
43565
43579
|
getRecursionIdentity,
|
|
@@ -49128,68 +49142,7 @@ function createTypeChecker(host) {
|
|
|
49128
49142
|
/*skipUnionExpanding*/
|
|
49129
49143
|
true
|
|
49130
49144
|
)[0];
|
|
49131
|
-
|
|
49132
|
-
if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
|
|
49133
|
-
let pushFakeScope2 = function(kind2, addAll) {
|
|
49134
|
-
Debug.assert(context.enclosingDeclaration);
|
|
49135
|
-
let existingFakeScope;
|
|
49136
|
-
if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
|
|
49137
|
-
existingFakeScope = context.enclosingDeclaration;
|
|
49138
|
-
} else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
|
|
49139
|
-
existingFakeScope = context.enclosingDeclaration.parent;
|
|
49140
|
-
}
|
|
49141
|
-
Debug.assertOptionalNode(existingFakeScope, isBlock);
|
|
49142
|
-
const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
|
|
49143
|
-
let newLocals;
|
|
49144
|
-
addAll((name, symbol) => {
|
|
49145
|
-
if (!locals.has(name)) {
|
|
49146
|
-
newLocals = append(newLocals, name);
|
|
49147
|
-
locals.set(name, symbol);
|
|
49148
|
-
}
|
|
49149
|
-
});
|
|
49150
|
-
if (!newLocals)
|
|
49151
|
-
return;
|
|
49152
|
-
const oldCleanup = cleanup;
|
|
49153
|
-
function undo() {
|
|
49154
|
-
forEach(newLocals, (s) => locals.delete(s));
|
|
49155
|
-
oldCleanup == null ? void 0 : oldCleanup();
|
|
49156
|
-
}
|
|
49157
|
-
if (existingFakeScope) {
|
|
49158
|
-
cleanup = undo;
|
|
49159
|
-
} else {
|
|
49160
|
-
const fakeScope = parseNodeFactory.createBlock(emptyArray);
|
|
49161
|
-
getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
|
|
49162
|
-
fakeScope.locals = locals;
|
|
49163
|
-
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
49164
|
-
setParent(fakeScope, saveEnclosingDeclaration);
|
|
49165
|
-
context.enclosingDeclaration = fakeScope;
|
|
49166
|
-
cleanup = () => {
|
|
49167
|
-
context.enclosingDeclaration = saveEnclosingDeclaration;
|
|
49168
|
-
undo();
|
|
49169
|
-
};
|
|
49170
|
-
}
|
|
49171
|
-
};
|
|
49172
|
-
var pushFakeScope = pushFakeScope2;
|
|
49173
|
-
pushFakeScope2(
|
|
49174
|
-
"params",
|
|
49175
|
-
(add) => {
|
|
49176
|
-
for (const param of expandedParams) {
|
|
49177
|
-
add(param.escapedName, param);
|
|
49178
|
-
}
|
|
49179
|
-
}
|
|
49180
|
-
);
|
|
49181
|
-
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
49182
|
-
pushFakeScope2(
|
|
49183
|
-
"typeParams",
|
|
49184
|
-
(add) => {
|
|
49185
|
-
for (const typeParam of signature.typeParameters ?? emptyArray) {
|
|
49186
|
-
const typeParamName = typeParameterToName(typeParam, context).escapedText;
|
|
49187
|
-
add(typeParamName, typeParam.symbol);
|
|
49188
|
-
}
|
|
49189
|
-
}
|
|
49190
|
-
);
|
|
49191
|
-
}
|
|
49192
|
-
}
|
|
49145
|
+
const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters);
|
|
49193
49146
|
const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */));
|
|
49194
49147
|
const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
|
|
49195
49148
|
if (thisParameter) {
|
|
@@ -49280,6 +49233,111 @@ function createTypeChecker(host) {
|
|
|
49280
49233
|
cleanup == null ? void 0 : cleanup();
|
|
49281
49234
|
return node;
|
|
49282
49235
|
}
|
|
49236
|
+
function isNewScopeNode(node) {
|
|
49237
|
+
return isFunctionLike(node) || isJSDocSignature(node) || isMappedTypeNode(node);
|
|
49238
|
+
}
|
|
49239
|
+
function getTypeParametersInScope(node) {
|
|
49240
|
+
return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).typeParameters : isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
|
|
49241
|
+
}
|
|
49242
|
+
function getParametersInScope(node) {
|
|
49243
|
+
return isFunctionLike(node) || isJSDocSignature(node) ? getExpandedParameters(
|
|
49244
|
+
getSignatureFromDeclaration(node),
|
|
49245
|
+
/*skipUnionExpanding*/
|
|
49246
|
+
true
|
|
49247
|
+
)[0] : void 0;
|
|
49248
|
+
}
|
|
49249
|
+
function enterNewScope(context, declaration, expandedParams, typeParameters) {
|
|
49250
|
+
let cleanup;
|
|
49251
|
+
if (context.enclosingDeclaration && declaration && declaration !== context.enclosingDeclaration && !isInJSFile(declaration) && (some(expandedParams) || some(typeParameters))) {
|
|
49252
|
+
let pushFakeScope2 = function(kind, addAll) {
|
|
49253
|
+
Debug.assert(context.enclosingDeclaration);
|
|
49254
|
+
let existingFakeScope;
|
|
49255
|
+
if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind) {
|
|
49256
|
+
existingFakeScope = context.enclosingDeclaration;
|
|
49257
|
+
} else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind) {
|
|
49258
|
+
existingFakeScope = context.enclosingDeclaration.parent;
|
|
49259
|
+
}
|
|
49260
|
+
Debug.assertOptionalNode(existingFakeScope, isBlock);
|
|
49261
|
+
const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
|
|
49262
|
+
let newLocals;
|
|
49263
|
+
addAll((name, symbol) => {
|
|
49264
|
+
if (!locals.has(name)) {
|
|
49265
|
+
newLocals = append(newLocals, name);
|
|
49266
|
+
locals.set(name, symbol);
|
|
49267
|
+
}
|
|
49268
|
+
});
|
|
49269
|
+
if (!newLocals)
|
|
49270
|
+
return;
|
|
49271
|
+
const oldCleanup = cleanup;
|
|
49272
|
+
function undo() {
|
|
49273
|
+
forEach(newLocals, (s) => locals.delete(s));
|
|
49274
|
+
oldCleanup == null ? void 0 : oldCleanup();
|
|
49275
|
+
}
|
|
49276
|
+
if (existingFakeScope) {
|
|
49277
|
+
cleanup = undo;
|
|
49278
|
+
} else {
|
|
49279
|
+
const fakeScope = parseNodeFactory.createBlock(emptyArray);
|
|
49280
|
+
getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind;
|
|
49281
|
+
fakeScope.locals = locals;
|
|
49282
|
+
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
49283
|
+
setParent(fakeScope, saveEnclosingDeclaration);
|
|
49284
|
+
context.enclosingDeclaration = fakeScope;
|
|
49285
|
+
cleanup = () => {
|
|
49286
|
+
context.enclosingDeclaration = saveEnclosingDeclaration;
|
|
49287
|
+
undo();
|
|
49288
|
+
};
|
|
49289
|
+
}
|
|
49290
|
+
};
|
|
49291
|
+
var pushFakeScope = pushFakeScope2;
|
|
49292
|
+
pushFakeScope2(
|
|
49293
|
+
"params",
|
|
49294
|
+
(add) => {
|
|
49295
|
+
for (const param of expandedParams ?? emptyArray) {
|
|
49296
|
+
if (!forEach(param.declarations, (d) => {
|
|
49297
|
+
if (isParameter(d) && isBindingPattern(d.name)) {
|
|
49298
|
+
bindPattern(d.name);
|
|
49299
|
+
return true;
|
|
49300
|
+
}
|
|
49301
|
+
return void 0;
|
|
49302
|
+
function bindPattern(p) {
|
|
49303
|
+
forEach(p.elements, (e) => {
|
|
49304
|
+
switch (e.kind) {
|
|
49305
|
+
case 232 /* OmittedExpression */:
|
|
49306
|
+
return;
|
|
49307
|
+
case 208 /* BindingElement */:
|
|
49308
|
+
return bindElement(e);
|
|
49309
|
+
default:
|
|
49310
|
+
return Debug.assertNever(e);
|
|
49311
|
+
}
|
|
49312
|
+
});
|
|
49313
|
+
}
|
|
49314
|
+
function bindElement(e) {
|
|
49315
|
+
if (isBindingPattern(e.name)) {
|
|
49316
|
+
return bindPattern(e.name);
|
|
49317
|
+
}
|
|
49318
|
+
const symbol = getSymbolOfDeclaration(e);
|
|
49319
|
+
add(symbol.escapedName, symbol);
|
|
49320
|
+
}
|
|
49321
|
+
})) {
|
|
49322
|
+
add(param.escapedName, param);
|
|
49323
|
+
}
|
|
49324
|
+
}
|
|
49325
|
+
}
|
|
49326
|
+
);
|
|
49327
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
49328
|
+
pushFakeScope2(
|
|
49329
|
+
"typeParams",
|
|
49330
|
+
(add) => {
|
|
49331
|
+
for (const typeParam of typeParameters ?? emptyArray) {
|
|
49332
|
+
const typeParamName = typeParameterToName(typeParam, context).escapedText;
|
|
49333
|
+
add(typeParamName, typeParam.symbol);
|
|
49334
|
+
}
|
|
49335
|
+
}
|
|
49336
|
+
);
|
|
49337
|
+
}
|
|
49338
|
+
return cleanup;
|
|
49339
|
+
}
|
|
49340
|
+
}
|
|
49283
49341
|
function tryGetThisParameterDeclaration(signature, context) {
|
|
49284
49342
|
if (signature.thisParameter) {
|
|
49285
49343
|
return symbolToParameterDeclaration(signature.thisParameter, context);
|
|
@@ -49898,6 +49956,9 @@ function createTypeChecker(host) {
|
|
|
49898
49956
|
if (initial.typeParameterSymbolList) {
|
|
49899
49957
|
initial.typeParameterSymbolList = new Set(initial.typeParameterSymbolList);
|
|
49900
49958
|
}
|
|
49959
|
+
if (initial.typeParameterNamesByTextNextNameCount) {
|
|
49960
|
+
initial.typeParameterNamesByTextNextNameCount = new Map(initial.typeParameterNamesByTextNextNameCount);
|
|
49961
|
+
}
|
|
49901
49962
|
initial.tracker = new SymbolTrackerImpl(initial, initial.tracker.inner, initial.tracker.moduleResolverHost);
|
|
49902
49963
|
return initial;
|
|
49903
49964
|
}
|
|
@@ -49905,7 +49966,16 @@ function createTypeChecker(host) {
|
|
|
49905
49966
|
return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
|
|
49906
49967
|
}
|
|
49907
49968
|
function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
|
|
49908
|
-
|
|
49969
|
+
if (!(getObjectFlags(type) & 4 /* Reference */))
|
|
49970
|
+
return true;
|
|
49971
|
+
if (!isTypeReferenceNode(existing))
|
|
49972
|
+
return true;
|
|
49973
|
+
void getTypeFromTypeReference(existing);
|
|
49974
|
+
const symbol = getNodeLinks(existing).resolvedSymbol;
|
|
49975
|
+
const existingTarget = symbol && getDeclaredTypeOfSymbol(symbol);
|
|
49976
|
+
if (!existingTarget || existingTarget !== type.target)
|
|
49977
|
+
return true;
|
|
49978
|
+
return length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
|
|
49909
49979
|
}
|
|
49910
49980
|
function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
|
|
49911
49981
|
while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
|
|
@@ -50010,14 +50080,27 @@ function createTypeChecker(host) {
|
|
|
50010
50080
|
} else {
|
|
50011
50081
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
50012
50082
|
}
|
|
50013
|
-
|
|
50083
|
+
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
|
|
50084
|
+
}
|
|
50085
|
+
return { introducesError, node };
|
|
50086
|
+
function attachSymbolToLeftmostIdentifier(node2) {
|
|
50087
|
+
if (node2 === leftmost) {
|
|
50014
50088
|
const type = getDeclaredTypeOfSymbol(sym);
|
|
50015
|
-
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(
|
|
50089
|
+
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node2);
|
|
50016
50090
|
name.symbol = sym;
|
|
50017
|
-
return
|
|
50091
|
+
return setTextRange(setEmitFlags(setOriginalNode(name, node2), 16777216 /* NoAsciiEscaping */), node2);
|
|
50092
|
+
}
|
|
50093
|
+
const updated = visitEachChild(
|
|
50094
|
+
node2,
|
|
50095
|
+
(c) => attachSymbolToLeftmostIdentifier(c),
|
|
50096
|
+
/*context*/
|
|
50097
|
+
void 0
|
|
50098
|
+
);
|
|
50099
|
+
if (updated !== node2) {
|
|
50100
|
+
setTextRange(updated, node2);
|
|
50018
50101
|
}
|
|
50102
|
+
return updated;
|
|
50019
50103
|
}
|
|
50020
|
-
return { introducesError, node };
|
|
50021
50104
|
}
|
|
50022
50105
|
function tryReuseExistingTypeNodeHelper(context, existing) {
|
|
50023
50106
|
if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
|
|
@@ -50030,6 +50113,22 @@ function createTypeChecker(host) {
|
|
|
50030
50113
|
}
|
|
50031
50114
|
return transformed === existing ? setTextRange(factory.cloneNode(existing), existing) : transformed;
|
|
50032
50115
|
function visitExistingNodeTreeSymbols(node) {
|
|
50116
|
+
const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
|
|
50117
|
+
const result = visitExistingNodeTreeSymbolsWorker(node);
|
|
50118
|
+
onExitNewScope == null ? void 0 : onExitNewScope();
|
|
50119
|
+
return result;
|
|
50120
|
+
}
|
|
50121
|
+
function onEnterNewScope(node) {
|
|
50122
|
+
const oldContex = context;
|
|
50123
|
+
context = cloneNodeBuilderContext(context);
|
|
50124
|
+
const cleanup = enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
|
|
50125
|
+
return onExitNewScope;
|
|
50126
|
+
function onExitNewScope() {
|
|
50127
|
+
cleanup == null ? void 0 : cleanup();
|
|
50128
|
+
context = oldContex;
|
|
50129
|
+
}
|
|
50130
|
+
}
|
|
50131
|
+
function visitExistingNodeTreeSymbolsWorker(node) {
|
|
50033
50132
|
if (isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) {
|
|
50034
50133
|
return factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
50035
50134
|
}
|
|
@@ -50162,11 +50261,12 @@ function createTypeChecker(host) {
|
|
|
50162
50261
|
return visited;
|
|
50163
50262
|
}
|
|
50164
50263
|
if (isEntityName(node) || isEntityNameExpression(node)) {
|
|
50264
|
+
if (isDeclarationName(node)) {
|
|
50265
|
+
return node;
|
|
50266
|
+
}
|
|
50165
50267
|
const { introducesError, node: result } = trackExistingEntityName(node, context);
|
|
50166
50268
|
hadError = hadError || introducesError;
|
|
50167
|
-
|
|
50168
|
-
return result;
|
|
50169
|
-
}
|
|
50269
|
+
return result;
|
|
50170
50270
|
}
|
|
50171
50271
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
50172
50272
|
const visited = visitEachChild(
|
|
@@ -50180,6 +50280,21 @@ function createTypeChecker(host) {
|
|
|
50180
50280
|
setEmitFlags(clone, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
|
|
50181
50281
|
return clone;
|
|
50182
50282
|
}
|
|
50283
|
+
if (isConditionalTypeNode(node)) {
|
|
50284
|
+
const checkType = visitNode(node.checkType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50285
|
+
const disposeScope = onEnterNewScope(node);
|
|
50286
|
+
const extendType = visitNode(node.extendsType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50287
|
+
const trueType2 = visitNode(node.trueType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50288
|
+
disposeScope();
|
|
50289
|
+
const falseType2 = visitNode(node.falseType, visitExistingNodeTreeSymbols, isTypeNode);
|
|
50290
|
+
return factory.updateConditionalTypeNode(
|
|
50291
|
+
node,
|
|
50292
|
+
checkType,
|
|
50293
|
+
extendType,
|
|
50294
|
+
trueType2,
|
|
50295
|
+
falseType2
|
|
50296
|
+
);
|
|
50297
|
+
}
|
|
50183
50298
|
return visitEachChild(
|
|
50184
50299
|
node,
|
|
50185
50300
|
visitExistingNodeTreeSymbols,
|
|
@@ -52051,32 +52166,9 @@ function createTypeChecker(host) {
|
|
|
52051
52166
|
}
|
|
52052
52167
|
}).parent;
|
|
52053
52168
|
}
|
|
52054
|
-
function getInstanceTypeOfClassSymbol(classSymbol) {
|
|
52055
|
-
const classType = getDeclaredTypeOfSymbol(classSymbol);
|
|
52056
|
-
const objectFlags = getObjectFlags(classType);
|
|
52057
|
-
if (!(objectFlags & 3 /* ClassOrInterface */) || !classType.typeParameters) {
|
|
52058
|
-
return classType;
|
|
52059
|
-
}
|
|
52060
|
-
const variances = getVariances(classType);
|
|
52061
|
-
const isJs = some(classSymbol.declarations, isInJSFile);
|
|
52062
|
-
const inferredTypes = calculateInferredTypeArguments(classType.typeParameters, isJs);
|
|
52063
|
-
const typeArguments = map(inferredTypes, (inferredType, i) => {
|
|
52064
|
-
if (!strictInstanceOfTypeParameters) {
|
|
52065
|
-
return anyType;
|
|
52066
|
-
}
|
|
52067
|
-
const variance = variances[i];
|
|
52068
|
-
switch (variance & 7 /* VarianceMask */) {
|
|
52069
|
-
case 2 /* Contravariant */:
|
|
52070
|
-
case 3 /* Bivariant */:
|
|
52071
|
-
return neverType;
|
|
52072
|
-
}
|
|
52073
|
-
return inferredType || unknownType;
|
|
52074
|
-
});
|
|
52075
|
-
return createTypeReference(classType, typeArguments);
|
|
52076
|
-
}
|
|
52077
52169
|
function getTypeOfPrototypeProperty(prototype) {
|
|
52078
|
-
const
|
|
52079
|
-
return
|
|
52170
|
+
const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
|
|
52171
|
+
return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, (_) => anyType)) : classType;
|
|
52080
52172
|
}
|
|
52081
52173
|
function getTypeOfPropertyOfType(type, name) {
|
|
52082
52174
|
const prop = getPropertyOfType(type, name);
|
|
@@ -53703,7 +53795,7 @@ function createTypeChecker(host) {
|
|
|
53703
53795
|
for (const member of declaration.members) {
|
|
53704
53796
|
if (hasBindableName(member)) {
|
|
53705
53797
|
const memberSymbol = getSymbolOfDeclaration(member);
|
|
53706
|
-
const value = getEnumMemberValue(member);
|
|
53798
|
+
const value = getEnumMemberValue(member).value;
|
|
53707
53799
|
const memberType = getFreshTypeOfLiteralType(
|
|
53708
53800
|
value !== void 0 ? getEnumLiteralType(value, getSymbolId(symbol), memberSymbol) : createComputedEnumType(memberSymbol)
|
|
53709
53801
|
);
|
|
@@ -55777,26 +55869,6 @@ function createTypeChecker(host) {
|
|
|
55777
55869
|
}
|
|
55778
55870
|
return typeArguments && typeArguments.slice();
|
|
55779
55871
|
}
|
|
55780
|
-
function calculateInferredTypeArguments(typeParameters, isJavaScriptImplicitAny) {
|
|
55781
|
-
const numTypeParameters = length(typeParameters);
|
|
55782
|
-
if (!numTypeParameters) {
|
|
55783
|
-
return [];
|
|
55784
|
-
}
|
|
55785
|
-
const result = [];
|
|
55786
|
-
for (let i = 0; i < numTypeParameters; i++) {
|
|
55787
|
-
result[i] = errorType;
|
|
55788
|
-
}
|
|
55789
|
-
const baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
|
|
55790
|
-
for (let i = 0; i < numTypeParameters; i++) {
|
|
55791
|
-
let inferredType = getBaseConstraintOfType(typeParameters[i]);
|
|
55792
|
-
if (isJavaScriptImplicitAny && inferredType && (isTypeIdenticalTo(inferredType, unknownType) || isTypeIdenticalTo(inferredType, emptyObjectType))) {
|
|
55793
|
-
inferredType = anyType;
|
|
55794
|
-
}
|
|
55795
|
-
result[i] = inferredType ? instantiateType(inferredType, createTypeMapper(typeParameters, result)) : baseDefaultType;
|
|
55796
|
-
}
|
|
55797
|
-
result.length = typeParameters.length;
|
|
55798
|
-
return result;
|
|
55799
|
-
}
|
|
55800
55872
|
function getSignatureFromDeclaration(declaration) {
|
|
55801
55873
|
const links = getNodeLinks(declaration);
|
|
55802
55874
|
if (!links.resolvedSignature) {
|
|
@@ -60859,8 +60931,8 @@ function createTypeChecker(host) {
|
|
|
60859
60931
|
}
|
|
60860
60932
|
return false;
|
|
60861
60933
|
}
|
|
60862
|
-
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */));
|
|
60863
|
-
const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */));
|
|
60934
|
+
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
|
|
60935
|
+
const targetValue = getEnumMemberValue(getDeclarationOfKind(targetProperty, 306 /* EnumMember */)).value;
|
|
60864
60936
|
if (sourceValue !== targetValue) {
|
|
60865
60937
|
const sourceIsString = typeof sourceValue === "string";
|
|
60866
60938
|
const targetIsString = typeof targetValue === "string";
|
|
@@ -67106,8 +67178,8 @@ function createTypeChecker(host) {
|
|
|
67106
67178
|
if (symbol === void 0) {
|
|
67107
67179
|
return type;
|
|
67108
67180
|
}
|
|
67109
|
-
const classSymbol =
|
|
67110
|
-
const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) :
|
|
67181
|
+
const classSymbol = symbol.parent;
|
|
67182
|
+
const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol);
|
|
67111
67183
|
return getNarrowedType(
|
|
67112
67184
|
type,
|
|
67113
67185
|
targetType,
|
|
@@ -74564,17 +74636,18 @@ function createTypeChecker(host) {
|
|
|
74564
74636
|
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || { flags: 2 /* Start */ };
|
|
74565
74637
|
const trueCondition = {
|
|
74566
74638
|
flags: 32 /* TrueCondition */,
|
|
74567
|
-
|
|
74568
|
-
|
|
74639
|
+
antecedent,
|
|
74640
|
+
node: expr
|
|
74569
74641
|
};
|
|
74570
74642
|
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
74571
74643
|
if (trueType2 === initType)
|
|
74572
74644
|
return void 0;
|
|
74573
74645
|
const falseCondition = {
|
|
74574
|
-
|
|
74575
|
-
|
|
74646
|
+
flags: 64 /* FalseCondition */,
|
|
74647
|
+
antecedent,
|
|
74648
|
+
node: expr
|
|
74576
74649
|
};
|
|
74577
|
-
const falseSubtype = getFlowTypeOfReference(param.name,
|
|
74650
|
+
const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
|
|
74578
74651
|
return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
|
|
74579
74652
|
}
|
|
74580
74653
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
@@ -75967,7 +76040,7 @@ function createTypeChecker(host) {
|
|
|
75967
76040
|
) || unknownType, isTemplateLiteralContextualType)) {
|
|
75968
76041
|
return getTemplateLiteralType(texts, types);
|
|
75969
76042
|
}
|
|
75970
|
-
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node);
|
|
76043
|
+
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
|
|
75971
76044
|
return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
|
|
75972
76045
|
}
|
|
75973
76046
|
function isTemplateLiteralContextualType(type) {
|
|
@@ -80872,14 +80945,14 @@ function createTypeChecker(host) {
|
|
|
80872
80945
|
let autoValue = 0;
|
|
80873
80946
|
let previous;
|
|
80874
80947
|
for (const member of node.members) {
|
|
80875
|
-
const
|
|
80876
|
-
getNodeLinks(member).enumMemberValue =
|
|
80877
|
-
autoValue = typeof value === "number" ? value + 1 : void 0;
|
|
80948
|
+
const result = computeEnumMemberValue(member, autoValue, previous);
|
|
80949
|
+
getNodeLinks(member).enumMemberValue = result;
|
|
80950
|
+
autoValue = typeof result.value === "number" ? result.value + 1 : void 0;
|
|
80878
80951
|
previous = member;
|
|
80879
80952
|
}
|
|
80880
80953
|
}
|
|
80881
80954
|
}
|
|
80882
|
-
function
|
|
80955
|
+
function computeEnumMemberValue(member, autoValue, previous) {
|
|
80883
80956
|
if (isComputedNonLiteralName(member.name)) {
|
|
80884
80957
|
error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
80885
80958
|
} else {
|
|
@@ -80889,34 +80962,43 @@ function createTypeChecker(host) {
|
|
|
80889
80962
|
}
|
|
80890
80963
|
}
|
|
80891
80964
|
if (member.initializer) {
|
|
80892
|
-
return
|
|
80965
|
+
return computeConstantEnumMemberValue(member);
|
|
80893
80966
|
}
|
|
80894
80967
|
if (member.parent.flags & 33554432 /* Ambient */ && !isEnumConst(member.parent)) {
|
|
80895
|
-
return
|
|
80968
|
+
return evaluatorResult(
|
|
80969
|
+
/*value*/
|
|
80970
|
+
void 0
|
|
80971
|
+
);
|
|
80896
80972
|
}
|
|
80897
80973
|
if (autoValue === void 0) {
|
|
80898
80974
|
error(member.name, Diagnostics.Enum_member_must_have_initializer);
|
|
80899
|
-
return
|
|
80900
|
-
|
|
80901
|
-
|
|
80902
|
-
error(
|
|
80903
|
-
member.name,
|
|
80904
|
-
Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
|
|
80975
|
+
return evaluatorResult(
|
|
80976
|
+
/*value*/
|
|
80977
|
+
void 0
|
|
80905
80978
|
);
|
|
80906
80979
|
}
|
|
80907
|
-
|
|
80980
|
+
if (getIsolatedModules(compilerOptions) && (previous == null ? void 0 : previous.initializer)) {
|
|
80981
|
+
const prevValue = getEnumMemberValue(previous);
|
|
80982
|
+
if (!(typeof prevValue.value === "number" && !prevValue.resolvedOtherFiles)) {
|
|
80983
|
+
error(
|
|
80984
|
+
member.name,
|
|
80985
|
+
Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
|
|
80986
|
+
);
|
|
80987
|
+
}
|
|
80988
|
+
}
|
|
80989
|
+
return evaluatorResult(autoValue);
|
|
80908
80990
|
}
|
|
80909
|
-
function
|
|
80991
|
+
function computeConstantEnumMemberValue(member) {
|
|
80910
80992
|
const isConstEnum = isEnumConst(member.parent);
|
|
80911
80993
|
const initializer = member.initializer;
|
|
80912
|
-
const
|
|
80913
|
-
if (value !== void 0) {
|
|
80914
|
-
if (isConstEnum && typeof value === "number" && !isFinite(value)) {
|
|
80994
|
+
const result = evaluate(initializer, member);
|
|
80995
|
+
if (result.value !== void 0) {
|
|
80996
|
+
if (isConstEnum && typeof result.value === "number" && !isFinite(result.value)) {
|
|
80915
80997
|
error(
|
|
80916
80998
|
initializer,
|
|
80917
|
-
isNaN(value) ? Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN : Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value
|
|
80999
|
+
isNaN(result.value) ? Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN : Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value
|
|
80918
81000
|
);
|
|
80919
|
-
} else if (getIsolatedModules(compilerOptions) && typeof value === "string" && !isSyntacticallyString
|
|
81001
|
+
} else if (getIsolatedModules(compilerOptions) && typeof result.value === "string" && !result.isSyntacticallyString) {
|
|
80920
81002
|
error(
|
|
80921
81003
|
initializer,
|
|
80922
81004
|
Diagnostics._0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled,
|
|
@@ -80930,19 +81012,7 @@ function createTypeChecker(host) {
|
|
|
80930
81012
|
} else {
|
|
80931
81013
|
checkTypeAssignableTo(checkExpression(initializer), numberType, initializer, Diagnostics.Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values);
|
|
80932
81014
|
}
|
|
80933
|
-
return
|
|
80934
|
-
}
|
|
80935
|
-
function isSyntacticallyNumericConstant(expr) {
|
|
80936
|
-
expr = skipOuterExpressions(expr);
|
|
80937
|
-
switch (expr.kind) {
|
|
80938
|
-
case 224 /* PrefixUnaryExpression */:
|
|
80939
|
-
return isSyntacticallyNumericConstant(expr.operand);
|
|
80940
|
-
case 226 /* BinaryExpression */:
|
|
80941
|
-
return isSyntacticallyNumericConstant(expr.left) && isSyntacticallyNumericConstant(expr.right);
|
|
80942
|
-
case 9 /* NumericLiteral */:
|
|
80943
|
-
return true;
|
|
80944
|
-
}
|
|
80945
|
-
return false;
|
|
81015
|
+
return result;
|
|
80946
81016
|
}
|
|
80947
81017
|
function evaluateEntityNameExpression(expr, location) {
|
|
80948
81018
|
const symbol = resolveEntityName(
|
|
@@ -80952,7 +81022,10 @@ function createTypeChecker(host) {
|
|
|
80952
81022
|
true
|
|
80953
81023
|
);
|
|
80954
81024
|
if (!symbol)
|
|
80955
|
-
return
|
|
81025
|
+
return evaluatorResult(
|
|
81026
|
+
/*value*/
|
|
81027
|
+
void 0
|
|
81028
|
+
);
|
|
80956
81029
|
if (expr.kind === 80 /* Identifier */) {
|
|
80957
81030
|
const identifier = expr;
|
|
80958
81031
|
if (isInfinityOrNaNString(identifier.escapedText) && symbol === getGlobalSymbol(
|
|
@@ -80961,7 +81034,11 @@ function createTypeChecker(host) {
|
|
|
80961
81034
|
/*diagnostic*/
|
|
80962
81035
|
void 0
|
|
80963
81036
|
)) {
|
|
80964
|
-
return
|
|
81037
|
+
return evaluatorResult(
|
|
81038
|
+
+identifier.escapedText,
|
|
81039
|
+
/*isSyntacticallyString*/
|
|
81040
|
+
false
|
|
81041
|
+
);
|
|
80965
81042
|
}
|
|
80966
81043
|
}
|
|
80967
81044
|
if (symbol.flags & 8 /* EnumMember */) {
|
|
@@ -80970,9 +81047,23 @@ function createTypeChecker(host) {
|
|
|
80970
81047
|
if (isConstantVariable(symbol)) {
|
|
80971
81048
|
const declaration = symbol.valueDeclaration;
|
|
80972
81049
|
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
|
|
80973
|
-
|
|
81050
|
+
const result = evaluate(declaration.initializer, declaration);
|
|
81051
|
+
if (location && getSourceFileOfNode(location) !== getSourceFileOfNode(declaration)) {
|
|
81052
|
+
return evaluatorResult(
|
|
81053
|
+
result.value,
|
|
81054
|
+
/*isSyntacticallyString*/
|
|
81055
|
+
false,
|
|
81056
|
+
/*resolvedOtherFiles*/
|
|
81057
|
+
true
|
|
81058
|
+
);
|
|
81059
|
+
}
|
|
81060
|
+
return result;
|
|
80974
81061
|
}
|
|
80975
81062
|
}
|
|
81063
|
+
return evaluatorResult(
|
|
81064
|
+
/*value*/
|
|
81065
|
+
void 0
|
|
81066
|
+
);
|
|
80976
81067
|
}
|
|
80977
81068
|
function evaluateElementAccessExpression(expr, location) {
|
|
80978
81069
|
const root = expr.expression;
|
|
@@ -80987,20 +81078,31 @@ function createTypeChecker(host) {
|
|
|
80987
81078
|
const name = escapeLeadingUnderscores(expr.argumentExpression.text);
|
|
80988
81079
|
const member = rootSymbol.exports.get(name);
|
|
80989
81080
|
if (member) {
|
|
81081
|
+
Debug.assert(getSourceFileOfNode(member.valueDeclaration) === getSourceFileOfNode(rootSymbol.valueDeclaration));
|
|
80990
81082
|
return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
|
|
80991
81083
|
}
|
|
80992
81084
|
}
|
|
80993
81085
|
}
|
|
81086
|
+
return evaluatorResult(
|
|
81087
|
+
/*value*/
|
|
81088
|
+
void 0
|
|
81089
|
+
);
|
|
80994
81090
|
}
|
|
80995
81091
|
function evaluateEnumMember(expr, symbol, location) {
|
|
80996
81092
|
const declaration = symbol.valueDeclaration;
|
|
80997
81093
|
if (!declaration || declaration === location) {
|
|
80998
81094
|
error(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(symbol));
|
|
80999
|
-
return
|
|
81095
|
+
return evaluatorResult(
|
|
81096
|
+
/*value*/
|
|
81097
|
+
void 0
|
|
81098
|
+
);
|
|
81000
81099
|
}
|
|
81001
81100
|
if (!isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
|
|
81002
81101
|
error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
|
|
81003
|
-
return
|
|
81102
|
+
return evaluatorResult(
|
|
81103
|
+
/*value*/
|
|
81104
|
+
0
|
|
81105
|
+
);
|
|
81004
81106
|
}
|
|
81005
81107
|
return getEnumMemberValue(declaration);
|
|
81006
81108
|
}
|
|
@@ -83141,7 +83243,10 @@ function createTypeChecker(host) {
|
|
|
83141
83243
|
}
|
|
83142
83244
|
function getEnumMemberValue(node) {
|
|
83143
83245
|
computeEnumMemberValues(node.parent);
|
|
83144
|
-
return getNodeLinks(node).enumMemberValue
|
|
83246
|
+
return getNodeLinks(node).enumMemberValue ?? evaluatorResult(
|
|
83247
|
+
/*value*/
|
|
83248
|
+
void 0
|
|
83249
|
+
);
|
|
83145
83250
|
}
|
|
83146
83251
|
function canHaveConstantValue(node) {
|
|
83147
83252
|
switch (node.kind) {
|
|
@@ -83154,13 +83259,13 @@ function createTypeChecker(host) {
|
|
|
83154
83259
|
}
|
|
83155
83260
|
function getConstantValue2(node) {
|
|
83156
83261
|
if (node.kind === 306 /* EnumMember */) {
|
|
83157
|
-
return getEnumMemberValue(node);
|
|
83262
|
+
return getEnumMemberValue(node).value;
|
|
83158
83263
|
}
|
|
83159
83264
|
const symbol = getNodeLinks(node).resolvedSymbol;
|
|
83160
83265
|
if (symbol && symbol.flags & 8 /* EnumMember */) {
|
|
83161
83266
|
const member = symbol.valueDeclaration;
|
|
83162
83267
|
if (isEnumConst(member.parent)) {
|
|
83163
|
-
return getEnumMemberValue(member);
|
|
83268
|
+
return getEnumMemberValue(member).value;
|
|
83164
83269
|
}
|
|
83165
83270
|
}
|
|
83166
83271
|
return void 0;
|
|
@@ -83535,6 +83640,10 @@ function createTypeChecker(host) {
|
|
|
83535
83640
|
const node = getParseTreeNode(nodeIn, canHaveConstantValue);
|
|
83536
83641
|
return node ? getConstantValue2(node) : void 0;
|
|
83537
83642
|
},
|
|
83643
|
+
getEnumMemberValue: (nodeIn) => {
|
|
83644
|
+
const node = getParseTreeNode(nodeIn, isEnumMember);
|
|
83645
|
+
return node ? getEnumMemberValue(node) : void 0;
|
|
83646
|
+
},
|
|
83538
83647
|
collectLinkedAliases,
|
|
83539
83648
|
getReferencedValueDeclaration,
|
|
83540
83649
|
getReferencedValueDeclarations,
|
|
@@ -89753,7 +89862,8 @@ function transformTypeScript(context) {
|
|
|
89753
89862
|
/*generateNameForComputedPropertyName*/
|
|
89754
89863
|
false
|
|
89755
89864
|
);
|
|
89756
|
-
const
|
|
89865
|
+
const evaluated = resolver.getEnumMemberValue(member);
|
|
89866
|
+
const valueExpression = transformEnumMemberDeclarationValue(member, evaluated == null ? void 0 : evaluated.value);
|
|
89757
89867
|
const innerAssignment = factory2.createAssignment(
|
|
89758
89868
|
factory2.createElementAccessExpression(
|
|
89759
89869
|
currentNamespaceContainerName,
|
|
@@ -89761,7 +89871,7 @@ function transformTypeScript(context) {
|
|
|
89761
89871
|
),
|
|
89762
89872
|
valueExpression
|
|
89763
89873
|
);
|
|
89764
|
-
const outerAssignment =
|
|
89874
|
+
const outerAssignment = typeof (evaluated == null ? void 0 : evaluated.value) === "string" || (evaluated == null ? void 0 : evaluated.isSyntacticallyString) ? innerAssignment : factory2.createAssignment(
|
|
89765
89875
|
factory2.createElementAccessExpression(
|
|
89766
89876
|
currentNamespaceContainerName,
|
|
89767
89877
|
innerAssignment
|
|
@@ -89778,10 +89888,9 @@ function transformTypeScript(context) {
|
|
|
89778
89888
|
member
|
|
89779
89889
|
);
|
|
89780
89890
|
}
|
|
89781
|
-
function transformEnumMemberDeclarationValue(member) {
|
|
89782
|
-
|
|
89783
|
-
|
|
89784
|
-
return typeof value === "string" ? factory2.createStringLiteral(value) : value < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-value)) : factory2.createNumericLiteral(value);
|
|
89891
|
+
function transformEnumMemberDeclarationValue(member, constantValue) {
|
|
89892
|
+
if (constantValue !== void 0) {
|
|
89893
|
+
return typeof constantValue === "string" ? factory2.createStringLiteral(constantValue) : constantValue < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-constantValue)) : factory2.createNumericLiteral(constantValue);
|
|
89785
89894
|
} else {
|
|
89786
89895
|
enableSubstitutionForNonQualifiedEnumMembers();
|
|
89787
89896
|
if (member.initializer) {
|
|
@@ -111121,6 +111230,7 @@ var notImplementedResolver = {
|
|
|
111121
111230
|
isEntityNameVisible: notImplemented,
|
|
111122
111231
|
// Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
|
|
111123
111232
|
getConstantValue: notImplemented,
|
|
111233
|
+
getEnumMemberValue: notImplemented,
|
|
111124
111234
|
getReferencedValueDeclaration: notImplemented,
|
|
111125
111235
|
getReferencedValueDeclarations: notImplemented,
|
|
111126
111236
|
getTypeReferenceSerializationKind: notImplemented,
|