typescript 4.8.0-dev.20220705 → 4.8.0-dev.20220708
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/lib.es2022.error.d.ts +2 -2
- package/lib/tsc.js +227 -146
- package/lib/tsserver.js +459 -334
- package/lib/tsserverlibrary.d.ts +9 -1
- package/lib/tsserverlibrary.js +459 -334
- package/lib/typescript.d.ts +9 -1
- package/lib/typescript.js +459 -334
- package/lib/typescriptServices.d.ts +9 -1
- package/lib/typescriptServices.js +459 -334
- package/lib/typingsInstaller.js +251 -163
- 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.20220708";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -2045,7 +2045,7 @@ var ts;
|
|
|
2045
2045
|
* and 1 insertion/deletion at 3 characters)
|
|
2046
2046
|
*/
|
|
2047
2047
|
function getSpellingSuggestion(name, candidates, getName) {
|
|
2048
|
-
var maximumLengthDifference = Math.
|
|
2048
|
+
var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
|
|
2049
2049
|
var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
|
|
2050
2050
|
var bestCandidate;
|
|
2051
2051
|
for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
|
|
@@ -2774,6 +2774,22 @@ var ts;
|
|
|
2774
2774
|
return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true);
|
|
2775
2775
|
}
|
|
2776
2776
|
Debug.formatFlowFlags = formatFlowFlags;
|
|
2777
|
+
function formatRelationComparisonResult(result) {
|
|
2778
|
+
return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true);
|
|
2779
|
+
}
|
|
2780
|
+
Debug.formatRelationComparisonResult = formatRelationComparisonResult;
|
|
2781
|
+
function formatCheckMode(mode) {
|
|
2782
|
+
return formatEnum(mode, ts.CheckMode, /*isFlags*/ true);
|
|
2783
|
+
}
|
|
2784
|
+
Debug.formatCheckMode = formatCheckMode;
|
|
2785
|
+
function formatSignatureCheckMode(mode) {
|
|
2786
|
+
return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true);
|
|
2787
|
+
}
|
|
2788
|
+
Debug.formatSignatureCheckMode = formatSignatureCheckMode;
|
|
2789
|
+
function formatTypeFacts(facts) {
|
|
2790
|
+
return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true);
|
|
2791
|
+
}
|
|
2792
|
+
Debug.formatTypeFacts = formatTypeFacts;
|
|
2777
2793
|
var isDebugInfoEnabled = false;
|
|
2778
2794
|
var extendedDebugModule;
|
|
2779
2795
|
function extendedDebug() {
|
|
@@ -4726,6 +4742,7 @@ var ts;
|
|
|
4726
4742
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4727
4743
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4728
4744
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4745
|
+
NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4729
4746
|
// Error handling
|
|
4730
4747
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4731
4748
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -4766,6 +4783,7 @@ var ts;
|
|
|
4766
4783
|
TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4767
4784
|
TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4768
4785
|
TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4786
|
+
TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4769
4787
|
// Error Handling
|
|
4770
4788
|
TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
|
|
4771
4789
|
// TypeFormatFlags exclusive
|
|
@@ -4777,7 +4795,7 @@ var ts;
|
|
|
4777
4795
|
TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
|
|
4778
4796
|
TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
|
|
4779
4797
|
/** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
|
|
4780
|
-
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] =
|
|
4798
|
+
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
|
|
4781
4799
|
})(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
|
|
4782
4800
|
var SymbolFormatFlags;
|
|
4783
4801
|
(function (SymbolFormatFlags) {
|
|
@@ -9011,6 +9029,7 @@ var ts;
|
|
|
9011
9029
|
The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
9012
9030
|
_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
|
|
9013
9031
|
We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
|
|
9032
|
+
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
9014
9033
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
9015
9034
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
9016
9035
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -19509,7 +19528,8 @@ var ts;
|
|
|
19509
19528
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
|
|
19510
19529
|
if (isWrite === void 0) { isWrite = false; }
|
|
19511
19530
|
if (s.valueDeclaration) {
|
|
19512
|
-
var declaration = (isWrite && s.declarations && ts.find(s.declarations,
|
|
19531
|
+
var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
|
|
19532
|
+
|| (s.flags & 32768 /* GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
|
|
19513
19533
|
var flags = ts.getCombinedModifierFlags(declaration);
|
|
19514
19534
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
|
|
19515
19535
|
}
|
|
@@ -20184,7 +20204,7 @@ var ts;
|
|
|
20184
20204
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20185
20205
|
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20186
20206
|
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20187
|
-
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20207
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20188
20208
|
}
|
|
20189
20209
|
function getSetExternalModuleIndicator(options) {
|
|
20190
20210
|
// TODO: Should this callback be cached?
|
|
@@ -20207,10 +20227,7 @@ var ts;
|
|
|
20207
20227
|
if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
|
|
20208
20228
|
checks.push(isFileModuleFromUsingJSXTag);
|
|
20209
20229
|
}
|
|
20210
|
-
|
|
20211
|
-
if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
20212
|
-
checks.push(isFileForcedToBeModuleByFormat);
|
|
20213
|
-
}
|
|
20230
|
+
checks.push(isFileForcedToBeModuleByFormat);
|
|
20214
20231
|
var combined_1 = ts.or.apply(void 0, checks);
|
|
20215
20232
|
var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
|
|
20216
20233
|
return callback;
|
|
@@ -33930,10 +33947,10 @@ var ts;
|
|
|
33930
33947
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
33931
33948
|
var modifiers = parseModifiers();
|
|
33932
33949
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
33933
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
|
|
33950
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
|
|
33934
33951
|
}
|
|
33935
33952
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
33936
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
|
|
33953
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
|
|
33937
33954
|
}
|
|
33938
33955
|
if (isIndexSignature()) {
|
|
33939
33956
|
return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
|
|
@@ -35979,10 +35996,10 @@ var ts;
|
|
|
35979
35996
|
var decorators = parseDecorators();
|
|
35980
35997
|
var modifiers = parseModifiers();
|
|
35981
35998
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
35982
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
35999
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
35983
36000
|
}
|
|
35984
36001
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
35985
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
36002
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
35986
36003
|
}
|
|
35987
36004
|
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
|
35988
36005
|
var tokenIsIdentifier = isIdentifier();
|
|
@@ -36674,9 +36691,15 @@ var ts;
|
|
|
36674
36691
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
|
|
36675
36692
|
}
|
|
36676
36693
|
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
|
|
36677
|
-
if (token() !== 18 /* OpenBraceToken */
|
|
36678
|
-
|
|
36679
|
-
|
|
36694
|
+
if (token() !== 18 /* OpenBraceToken */) {
|
|
36695
|
+
if (flags & 4 /* Type */) {
|
|
36696
|
+
parseTypeMemberSemicolon();
|
|
36697
|
+
return;
|
|
36698
|
+
}
|
|
36699
|
+
if (canParseSemicolon()) {
|
|
36700
|
+
parseSemicolon();
|
|
36701
|
+
return;
|
|
36702
|
+
}
|
|
36680
36703
|
}
|
|
36681
36704
|
return parseFunctionBlock(flags, diagnosticMessage);
|
|
36682
36705
|
}
|
|
@@ -36880,12 +36903,12 @@ var ts;
|
|
|
36880
36903
|
}
|
|
36881
36904
|
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
|
|
36882
36905
|
}
|
|
36883
|
-
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
|
|
36906
|
+
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
|
|
36884
36907
|
var name = parsePropertyName();
|
|
36885
36908
|
var typeParameters = parseTypeParameters();
|
|
36886
36909
|
var parameters = parseParameters(0 /* None */);
|
|
36887
36910
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
36888
|
-
var body = parseFunctionBlockOrSemicolon(
|
|
36911
|
+
var body = parseFunctionBlockOrSemicolon(flags);
|
|
36889
36912
|
var node = kind === 172 /* GetAccessor */
|
|
36890
36913
|
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
|
|
36891
36914
|
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
|
|
@@ -37072,10 +37095,10 @@ var ts;
|
|
|
37072
37095
|
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
37073
37096
|
}
|
|
37074
37097
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
37075
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
37098
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
37076
37099
|
}
|
|
37077
37100
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
37078
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
37101
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
37079
37102
|
}
|
|
37080
37103
|
if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
|
|
37081
37104
|
var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -44386,6 +44409,7 @@ var ts;
|
|
|
44386
44409
|
return toSearchResult(/*value*/ undefined);
|
|
44387
44410
|
}
|
|
44388
44411
|
/**
|
|
44412
|
+
* @internal
|
|
44389
44413
|
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
|
44390
44414
|
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
|
44391
44415
|
*/
|
|
@@ -44408,6 +44432,7 @@ var ts;
|
|
|
44408
44432
|
return 1;
|
|
44409
44433
|
return 0;
|
|
44410
44434
|
}
|
|
44435
|
+
ts.comparePatternKeys = comparePatternKeys;
|
|
44411
44436
|
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
44412
44437
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44413
44438
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
@@ -48479,7 +48504,7 @@ var ts;
|
|
|
48479
48504
|
// Masks
|
|
48480
48505
|
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
48481
48506
|
TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
|
|
48482
|
-
})(TypeFacts || (TypeFacts = {}));
|
|
48507
|
+
})(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
|
|
48483
48508
|
var typeofNEFacts = new ts.Map(ts.getEntries({
|
|
48484
48509
|
string: 256 /* TypeofNEString */,
|
|
48485
48510
|
number: 512 /* TypeofNENumber */,
|
|
@@ -48514,7 +48539,7 @@ var ts;
|
|
|
48514
48539
|
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
48515
48540
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
48516
48541
|
// we need to preserve generic types instead of substituting them for constraints
|
|
48517
|
-
})(CheckMode || (CheckMode = {}));
|
|
48542
|
+
})(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
|
|
48518
48543
|
var SignatureCheckMode;
|
|
48519
48544
|
(function (SignatureCheckMode) {
|
|
48520
48545
|
SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
|
|
@@ -48522,7 +48547,7 @@ var ts;
|
|
|
48522
48547
|
SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
|
|
48523
48548
|
SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
|
|
48524
48549
|
SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
|
|
48525
|
-
})(SignatureCheckMode || (SignatureCheckMode = {}));
|
|
48550
|
+
})(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
|
|
48526
48551
|
var IntersectionState;
|
|
48527
48552
|
(function (IntersectionState) {
|
|
48528
48553
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
@@ -48874,7 +48899,7 @@ var ts;
|
|
|
48874
48899
|
},
|
|
48875
48900
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
48876
48901
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
48877
|
-
return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
|
|
48902
|
+
return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
|
|
48878
48903
|
},
|
|
48879
48904
|
getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
|
|
48880
48905
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -48882,7 +48907,7 @@ var ts;
|
|
|
48882
48907
|
},
|
|
48883
48908
|
getContextualTypeForJsxAttribute: function (nodeIn) {
|
|
48884
48909
|
var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
|
|
48885
|
-
return node && getContextualTypeForJsxAttribute(node);
|
|
48910
|
+
return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
|
|
48886
48911
|
},
|
|
48887
48912
|
isContextSensitive: isContextSensitive,
|
|
48888
48913
|
getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
|
|
@@ -49088,6 +49113,7 @@ var ts;
|
|
|
49088
49113
|
var stringMappingTypes = new ts.Map();
|
|
49089
49114
|
var substitutionTypes = new ts.Map();
|
|
49090
49115
|
var subtypeReductionCache = new ts.Map();
|
|
49116
|
+
var cachedTypes = new ts.Map();
|
|
49091
49117
|
var evolvingArrayTypes = [];
|
|
49092
49118
|
var undefinedProperties = new ts.Map();
|
|
49093
49119
|
var markerTypes = new ts.Set();
|
|
@@ -49341,6 +49367,14 @@ var ts;
|
|
|
49341
49367
|
];
|
|
49342
49368
|
initializeTypeChecker();
|
|
49343
49369
|
return checker;
|
|
49370
|
+
function getCachedType(key) {
|
|
49371
|
+
return key ? cachedTypes.get(key) : undefined;
|
|
49372
|
+
}
|
|
49373
|
+
function setCachedType(key, type) {
|
|
49374
|
+
if (key)
|
|
49375
|
+
cachedTypes.set(key, type);
|
|
49376
|
+
return type;
|
|
49377
|
+
}
|
|
49344
49378
|
function getJsxNamespace(location) {
|
|
49345
49379
|
if (location) {
|
|
49346
49380
|
var file = ts.getSourceFileOfNode(location);
|
|
@@ -50205,6 +50239,7 @@ var ts;
|
|
|
50205
50239
|
if (ctor && ctor.locals) {
|
|
50206
50240
|
if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
|
|
50207
50241
|
// Remember the property node, it will be used later to report appropriate error
|
|
50242
|
+
ts.Debug.assertNode(location, ts.isPropertyDeclaration);
|
|
50208
50243
|
propertyWithInvalidInitializer = location;
|
|
50209
50244
|
}
|
|
50210
50245
|
}
|
|
@@ -50394,11 +50429,27 @@ var ts;
|
|
|
50394
50429
|
}
|
|
50395
50430
|
}
|
|
50396
50431
|
}
|
|
50432
|
+
// The invalid initializer error is needed in two situation:
|
|
50433
|
+
// 1. When result is undefined, after checking for a missing "this."
|
|
50434
|
+
// 2. When result is defined
|
|
50435
|
+
function checkAndReportErrorForInvalidInitializer() {
|
|
50436
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
50437
|
+
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50438
|
+
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50439
|
+
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
50440
|
+
error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
|
|
50441
|
+
? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
|
|
50442
|
+
: ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
|
|
50443
|
+
return true;
|
|
50444
|
+
}
|
|
50445
|
+
return false;
|
|
50446
|
+
}
|
|
50397
50447
|
if (!result) {
|
|
50398
50448
|
if (nameNotFoundMessage) {
|
|
50399
50449
|
addLazyDiagnostic(function () {
|
|
50400
50450
|
if (!errorLocation ||
|
|
50401
50451
|
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
50452
|
+
!checkAndReportErrorForInvalidInitializer() &&
|
|
50402
50453
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50403
50454
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50404
50455
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
@@ -50406,7 +50457,16 @@ var ts;
|
|
|
50406
50457
|
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50407
50458
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50408
50459
|
var suggestion = void 0;
|
|
50409
|
-
|
|
50460
|
+
var suggestedLib = void 0;
|
|
50461
|
+
// Report missing lib first
|
|
50462
|
+
if (nameArg) {
|
|
50463
|
+
suggestedLib = getSuggestedLibForNonExistentName(nameArg);
|
|
50464
|
+
if (suggestedLib) {
|
|
50465
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
|
|
50466
|
+
}
|
|
50467
|
+
}
|
|
50468
|
+
// then spelling suggestions
|
|
50469
|
+
if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
50410
50470
|
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
50411
50471
|
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
50412
50472
|
if (isGlobalScopeAugmentationDeclaration) {
|
|
@@ -50425,16 +50485,9 @@ var ts;
|
|
|
50425
50485
|
}
|
|
50426
50486
|
}
|
|
50427
50487
|
}
|
|
50428
|
-
|
|
50429
|
-
|
|
50430
|
-
|
|
50431
|
-
if (lib) {
|
|
50432
|
-
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
|
|
50433
|
-
}
|
|
50434
|
-
else {
|
|
50435
|
-
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
50436
|
-
}
|
|
50437
|
-
}
|
|
50488
|
+
// And then fall back to unspecified "not found"
|
|
50489
|
+
if (!suggestion && !suggestedLib && nameArg) {
|
|
50490
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
50438
50491
|
}
|
|
50439
50492
|
suggestionCount++;
|
|
50440
50493
|
}
|
|
@@ -50442,12 +50495,7 @@ var ts;
|
|
|
50442
50495
|
}
|
|
50443
50496
|
return undefined;
|
|
50444
50497
|
}
|
|
50445
|
-
if (
|
|
50446
|
-
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50447
|
-
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50448
|
-
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
50449
|
-
var propertyName = propertyWithInvalidInitializer.name;
|
|
50450
|
-
error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
|
|
50498
|
+
else if (checkAndReportErrorForInvalidInitializer()) {
|
|
50451
50499
|
return undefined;
|
|
50452
50500
|
}
|
|
50453
50501
|
// Perform extra checks only if error reporting was requested
|
|
@@ -52596,13 +52644,25 @@ var ts;
|
|
|
52596
52644
|
&& isDeclarationVisible(declaration.parent)) {
|
|
52597
52645
|
return addVisibleAlias(declaration, declaration);
|
|
52598
52646
|
}
|
|
52599
|
-
else if (
|
|
52600
|
-
&& ts.
|
|
52601
|
-
|
|
52602
|
-
|
|
52603
|
-
|
|
52604
|
-
|
|
52605
|
-
|
|
52647
|
+
else if (ts.isBindingElement(declaration)) {
|
|
52648
|
+
if (symbol.flags & 2097152 /* Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement
|
|
52649
|
+
&& ts.isVariableDeclaration(declaration.parent.parent)
|
|
52650
|
+
&& ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
|
|
52651
|
+
&& !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
|
|
52652
|
+
&& declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
|
|
52653
|
+
&& isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
|
|
52654
|
+
return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
|
|
52655
|
+
}
|
|
52656
|
+
else if (symbol.flags & 2 /* BlockScopedVariable */) {
|
|
52657
|
+
var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
|
|
52658
|
+
if (ts.hasSyntacticModifier(variableStatement, 1 /* Export */)) {
|
|
52659
|
+
return true;
|
|
52660
|
+
}
|
|
52661
|
+
if (!isDeclarationVisible(variableStatement.parent)) {
|
|
52662
|
+
return false;
|
|
52663
|
+
}
|
|
52664
|
+
return addVisibleAlias(declaration, variableStatement);
|
|
52665
|
+
}
|
|
52606
52666
|
}
|
|
52607
52667
|
// Declaration is not visible
|
|
52608
52668
|
return false;
|
|
@@ -52735,7 +52795,7 @@ var ts;
|
|
|
52735
52795
|
}
|
|
52736
52796
|
function toNodeBuilderFlags(flags) {
|
|
52737
52797
|
if (flags === void 0) { flags = 0 /* None */; }
|
|
52738
|
-
return flags &
|
|
52798
|
+
return flags & 848330091 /* NodeBuilderFlagsMask */;
|
|
52739
52799
|
}
|
|
52740
52800
|
function isClassInstanceSide(type) {
|
|
52741
52801
|
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
|
|
@@ -53123,6 +53183,10 @@ var ts;
|
|
|
53123
53183
|
}
|
|
53124
53184
|
return typeToTypeNodeHelper(type, context);
|
|
53125
53185
|
}
|
|
53186
|
+
function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
|
|
53187
|
+
return isMappedTypeWithKeyofConstraintDeclaration(type)
|
|
53188
|
+
&& !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
|
|
53189
|
+
}
|
|
53126
53190
|
function createMappedTypeNodeFromType(type) {
|
|
53127
53191
|
ts.Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
53128
53192
|
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
|
|
@@ -53132,7 +53196,7 @@ var ts;
|
|
|
53132
53196
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
53133
53197
|
// We have a { [P in keyof T]: X }
|
|
53134
53198
|
// We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
|
|
53135
|
-
if (
|
|
53199
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53136
53200
|
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
53137
53201
|
var name = typeParameterToName(newParam, context);
|
|
53138
53202
|
newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
@@ -53148,11 +53212,12 @@ var ts;
|
|
|
53148
53212
|
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
53149
53213
|
context.approximateLength += 10;
|
|
53150
53214
|
var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
53151
|
-
if (
|
|
53215
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53152
53216
|
// homomorphic mapped type with a non-homomorphic naive inlining
|
|
53153
53217
|
// wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
|
|
53154
53218
|
// type stays homomorphic
|
|
53155
|
-
|
|
53219
|
+
var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
|
|
53220
|
+
return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
|
|
53156
53221
|
}
|
|
53157
53222
|
return result;
|
|
53158
53223
|
}
|
|
@@ -53714,7 +53779,7 @@ var ts;
|
|
|
53714
53779
|
var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
|
|
53715
53780
|
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
|
|
53716
53781
|
var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
|
|
53717
|
-
var thisParameter = tryGetThisParameterDeclaration(signature, context);
|
|
53782
|
+
var thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context);
|
|
53718
53783
|
if (thisParameter) {
|
|
53719
53784
|
parameters.unshift(thisParameter);
|
|
53720
53785
|
}
|
|
@@ -54773,12 +54838,11 @@ var ts;
|
|
|
54773
54838
|
if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
|
|
54774
54839
|
var oldContext = context;
|
|
54775
54840
|
context = cloneNodeBuilderContext(context);
|
|
54776
|
-
|
|
54841
|
+
serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
|
|
54777
54842
|
if (context.reportedDiagnostic) {
|
|
54778
54843
|
oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
|
|
54779
54844
|
}
|
|
54780
54845
|
context = oldContext;
|
|
54781
|
-
return result;
|
|
54782
54846
|
}
|
|
54783
54847
|
}
|
|
54784
54848
|
// Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
|
|
@@ -57835,7 +57899,7 @@ var ts;
|
|
|
57835
57899
|
error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
57836
57900
|
}
|
|
57837
57901
|
else {
|
|
57838
|
-
error(ts.isNamedDeclaration(declaration) ? declaration.name
|
|
57902
|
+
error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
57839
57903
|
}
|
|
57840
57904
|
}
|
|
57841
57905
|
links.declaredType = type;
|
|
@@ -62298,19 +62362,22 @@ var ts;
|
|
|
62298
62362
|
* to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
|
|
62299
62363
|
*/
|
|
62300
62364
|
function isPossiblyReducibleByInstantiation(type) {
|
|
62301
|
-
|
|
62302
|
-
|
|
62303
|
-
|
|
62304
|
-
|
|
62365
|
+
var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
|
|
62366
|
+
return getReducedType(uniqueFilled) !== uniqueFilled;
|
|
62367
|
+
}
|
|
62368
|
+
function shouldDeferIndexType(type) {
|
|
62369
|
+
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
|
|
62370
|
+
isGenericTupleType(type) ||
|
|
62371
|
+
isGenericMappedType(type) && !hasDistributiveNameType(type) ||
|
|
62372
|
+
type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
|
|
62373
|
+
type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
|
|
62305
62374
|
}
|
|
62306
62375
|
function getIndexType(type, stringsOnly, noIndexSignatures) {
|
|
62307
62376
|
if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
|
|
62308
62377
|
type = getReducedType(type);
|
|
62309
|
-
return type
|
|
62310
|
-
?
|
|
62311
|
-
|
|
62312
|
-
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
62313
|
-
type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
62378
|
+
return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
62379
|
+
type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
62380
|
+
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
62314
62381
|
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
|
|
62315
62382
|
type === wildcardType ? wildcardType :
|
|
62316
62383
|
type.flags & 2 /* Unknown */ ? neverType :
|
|
@@ -66103,13 +66170,20 @@ var ts;
|
|
|
66103
66170
|
return result;
|
|
66104
66171
|
}
|
|
66105
66172
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66173
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
66174
|
+
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66175
|
+
if (result) {
|
|
66176
|
+
resetErrorInfo(saveErrorInfo);
|
|
66177
|
+
}
|
|
66178
|
+
return result;
|
|
66179
|
+
}
|
|
66180
|
+
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
66106
66181
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
66107
66182
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
66108
66183
|
}
|
|
66109
66184
|
var result;
|
|
66110
66185
|
var originalErrorInfo;
|
|
66111
66186
|
var varianceCheckFailed = false;
|
|
66112
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
66113
66187
|
var sourceFlags = source.flags;
|
|
66114
66188
|
var targetFlags = target.flags;
|
|
66115
66189
|
if (relation === identityRelation) {
|
|
@@ -66173,7 +66247,6 @@ var ts;
|
|
|
66173
66247
|
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66174
66248
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66175
66249
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66176
|
-
resetErrorInfo(saveErrorInfo);
|
|
66177
66250
|
return result;
|
|
66178
66251
|
}
|
|
66179
66252
|
}
|
|
@@ -66298,7 +66371,6 @@ var ts;
|
|
|
66298
66371
|
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
66299
66372
|
}
|
|
66300
66373
|
if (result) {
|
|
66301
|
-
resetErrorInfo(saveErrorInfo);
|
|
66302
66374
|
return result;
|
|
66303
66375
|
}
|
|
66304
66376
|
if (reportErrors) {
|
|
@@ -66401,7 +66473,6 @@ var ts;
|
|
|
66401
66473
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66402
66474
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66403
66475
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
66404
|
-
resetErrorInfo(saveErrorInfo);
|
|
66405
66476
|
return 3 /* Maybe */;
|
|
66406
66477
|
}
|
|
66407
66478
|
var c = target;
|
|
@@ -66416,7 +66487,6 @@ var ts;
|
|
|
66416
66487
|
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
66417
66488
|
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
66418
66489
|
if (result) {
|
|
66419
|
-
resetErrorInfo(saveErrorInfo);
|
|
66420
66490
|
return result;
|
|
66421
66491
|
}
|
|
66422
66492
|
}
|
|
@@ -66448,12 +66518,10 @@ var ts;
|
|
|
66448
66518
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
66449
66519
|
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
|
|
66450
66520
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66451
|
-
resetErrorInfo(saveErrorInfo);
|
|
66452
66521
|
return result;
|
|
66453
66522
|
}
|
|
66454
66523
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
66455
66524
|
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
66456
|
-
resetErrorInfo(saveErrorInfo);
|
|
66457
66525
|
return result;
|
|
66458
66526
|
}
|
|
66459
66527
|
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
@@ -66462,7 +66530,6 @@ var ts;
|
|
|
66462
66530
|
var indexConstraint = getConstraintOfType(source.indexType);
|
|
66463
66531
|
if (indexConstraint) {
|
|
66464
66532
|
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
66465
|
-
resetErrorInfo(saveErrorInfo);
|
|
66466
66533
|
return result;
|
|
66467
66534
|
}
|
|
66468
66535
|
}
|
|
@@ -66471,7 +66538,6 @@ var ts;
|
|
|
66471
66538
|
}
|
|
66472
66539
|
else if (sourceFlags & 4194304 /* Index */) {
|
|
66473
66540
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
66474
|
-
resetErrorInfo(saveErrorInfo);
|
|
66475
66541
|
return result;
|
|
66476
66542
|
}
|
|
66477
66543
|
}
|
|
@@ -66479,7 +66545,6 @@ var ts;
|
|
|
66479
66545
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66480
66546
|
var constraint = getBaseConstraintOfType(source);
|
|
66481
66547
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66482
|
-
resetErrorInfo(saveErrorInfo);
|
|
66483
66548
|
return result;
|
|
66484
66549
|
}
|
|
66485
66550
|
}
|
|
@@ -66490,14 +66555,12 @@ var ts;
|
|
|
66490
66555
|
return 0 /* False */;
|
|
66491
66556
|
}
|
|
66492
66557
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66493
|
-
resetErrorInfo(saveErrorInfo);
|
|
66494
66558
|
return result;
|
|
66495
66559
|
}
|
|
66496
66560
|
}
|
|
66497
66561
|
else {
|
|
66498
66562
|
var constraint = getBaseConstraintOfType(source);
|
|
66499
66563
|
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66500
|
-
resetErrorInfo(saveErrorInfo);
|
|
66501
66564
|
return result;
|
|
66502
66565
|
}
|
|
66503
66566
|
}
|
|
@@ -66506,7 +66569,6 @@ var ts;
|
|
|
66506
66569
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66507
66570
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66508
66571
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
66509
|
-
resetErrorInfo(saveErrorInfo);
|
|
66510
66572
|
return 3 /* Maybe */;
|
|
66511
66573
|
}
|
|
66512
66574
|
if (targetFlags & 16777216 /* Conditional */) {
|
|
@@ -66529,7 +66591,6 @@ var ts;
|
|
|
66529
66591
|
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
66530
66592
|
}
|
|
66531
66593
|
if (result) {
|
|
66532
|
-
resetErrorInfo(saveErrorInfo);
|
|
66533
66594
|
return result;
|
|
66534
66595
|
}
|
|
66535
66596
|
}
|
|
@@ -66540,7 +66601,6 @@ var ts;
|
|
|
66540
66601
|
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
66541
66602
|
if (distributiveConstraint) {
|
|
66542
66603
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66543
|
-
resetErrorInfo(saveErrorInfo);
|
|
66544
66604
|
return result;
|
|
66545
66605
|
}
|
|
66546
66606
|
}
|
|
@@ -66550,7 +66610,6 @@ var ts;
|
|
|
66550
66610
|
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
66551
66611
|
if (defaultConstraint) {
|
|
66552
66612
|
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66553
|
-
resetErrorInfo(saveErrorInfo);
|
|
66554
66613
|
return result;
|
|
66555
66614
|
}
|
|
66556
66615
|
}
|
|
@@ -66563,7 +66622,6 @@ var ts;
|
|
|
66563
66622
|
if (isGenericMappedType(target)) {
|
|
66564
66623
|
if (isGenericMappedType(source)) {
|
|
66565
66624
|
if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
|
|
66566
|
-
resetErrorInfo(saveErrorInfo);
|
|
66567
66625
|
return result;
|
|
66568
66626
|
}
|
|
66569
66627
|
}
|
|
@@ -68018,9 +68076,14 @@ var ts;
|
|
|
68018
68076
|
type.flags & 256 /* NumberLiteral */ ? numberType :
|
|
68019
68077
|
type.flags & 2048 /* BigIntLiteral */ ? bigintType :
|
|
68020
68078
|
type.flags & 512 /* BooleanLiteral */ ? booleanType :
|
|
68021
|
-
type.flags & 1048576 /* Union */ ?
|
|
68079
|
+
type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) :
|
|
68022
68080
|
type;
|
|
68023
68081
|
}
|
|
68082
|
+
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
68083
|
+
var _a;
|
|
68084
|
+
var key = "B" + getTypeId(type);
|
|
68085
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
68086
|
+
}
|
|
68024
68087
|
function getWidenedLiteralType(type) {
|
|
68025
68088
|
return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
|
|
68026
68089
|
type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
|
|
@@ -69904,6 +69967,15 @@ var ts;
|
|
|
69904
69967
|
var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
|
|
69905
69968
|
return key && key + "." + propName;
|
|
69906
69969
|
}
|
|
69970
|
+
break;
|
|
69971
|
+
case 201 /* ObjectBindingPattern */:
|
|
69972
|
+
case 202 /* ArrayBindingPattern */:
|
|
69973
|
+
case 256 /* FunctionDeclaration */:
|
|
69974
|
+
case 213 /* FunctionExpression */:
|
|
69975
|
+
case 214 /* ArrowFunction */:
|
|
69976
|
+
case 169 /* MethodDeclaration */:
|
|
69977
|
+
// Handle pseudo-references originating in getNarrowedTypeOfSymbol.
|
|
69978
|
+
return getNodeId(node) + "#" + getTypeId(declaredType);
|
|
69907
69979
|
}
|
|
69908
69980
|
return undefined;
|
|
69909
69981
|
}
|
|
@@ -70163,23 +70235,25 @@ var ts;
|
|
|
70163
70235
|
// For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
|
|
70164
70236
|
// we remove type string.
|
|
70165
70237
|
function getAssignmentReducedType(declaredType, assignedType) {
|
|
70166
|
-
|
|
70167
|
-
|
|
70168
|
-
|
|
70169
|
-
}
|
|
70170
|
-
var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70171
|
-
if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
|
|
70172
|
-
reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
|
|
70173
|
-
}
|
|
70174
|
-
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70175
|
-
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70176
|
-
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70177
|
-
// is not assignable to the declared type.)
|
|
70178
|
-
if (isTypeAssignableTo(assignedType, reducedType)) {
|
|
70179
|
-
return reducedType;
|
|
70180
|
-
}
|
|
70238
|
+
var _a;
|
|
70239
|
+
if (declaredType === assignedType) {
|
|
70240
|
+
return declaredType;
|
|
70181
70241
|
}
|
|
70182
|
-
|
|
70242
|
+
if (assignedType.flags & 131072 /* Never */) {
|
|
70243
|
+
return assignedType;
|
|
70244
|
+
}
|
|
70245
|
+
var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
|
|
70246
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
|
|
70247
|
+
}
|
|
70248
|
+
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
70249
|
+
var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70250
|
+
// Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type.
|
|
70251
|
+
var reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
70252
|
+
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70253
|
+
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70254
|
+
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70255
|
+
// is not assignable to the declared type.)
|
|
70256
|
+
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
70183
70257
|
}
|
|
70184
70258
|
function isFunctionObjectType(type) {
|
|
70185
70259
|
// We do a quick check for a "bind" property before performing the more expensive subtype
|
|
@@ -71585,7 +71659,7 @@ var ts;
|
|
|
71585
71659
|
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
71586
71660
|
? getTypeOfSymbol(classSymbol)
|
|
71587
71661
|
: getDeclaredTypeOfSymbol(classSymbol);
|
|
71588
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
71662
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
71589
71663
|
}
|
|
71590
71664
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
71591
71665
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
@@ -71836,9 +71910,15 @@ var ts;
|
|
|
71836
71910
|
if (!nonConstructorTypeInUnion)
|
|
71837
71911
|
return type;
|
|
71838
71912
|
}
|
|
71839
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
71913
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
71914
|
+
}
|
|
71915
|
+
function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
|
|
71916
|
+
var _a;
|
|
71917
|
+
var key = type.flags & 1048576 /* Union */ ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
|
|
71918
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
|
|
71840
71919
|
}
|
|
71841
|
-
function
|
|
71920
|
+
function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
|
|
71921
|
+
var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
|
|
71842
71922
|
if (!assumeTrue) {
|
|
71843
71923
|
return filterType(type, function (t) { return !isRelated(t, candidate); });
|
|
71844
71924
|
}
|
|
@@ -71886,7 +71966,7 @@ var ts;
|
|
|
71886
71966
|
var predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
71887
71967
|
if (predicateArgument) {
|
|
71888
71968
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
71889
|
-
return getNarrowedType(type, predicate.type, assumeTrue,
|
|
71969
|
+
return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false);
|
|
71890
71970
|
}
|
|
71891
71971
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
|
|
71892
71972
|
!(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
@@ -71894,7 +71974,7 @@ var ts;
|
|
|
71894
71974
|
}
|
|
71895
71975
|
var access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
71896
71976
|
if (access) {
|
|
71897
|
-
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue,
|
|
71977
|
+
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); });
|
|
71898
71978
|
}
|
|
71899
71979
|
}
|
|
71900
71980
|
}
|
|
@@ -72071,7 +72151,7 @@ var ts;
|
|
|
72071
72151
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
72072
72152
|
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
72073
72153
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
72074
|
-
: getContextualType(node));
|
|
72154
|
+
: getContextualType(node, /*contextFlags*/ undefined));
|
|
72075
72155
|
return contextualType && !isGenericType(contextualType);
|
|
72076
72156
|
}
|
|
72077
72157
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -72233,9 +72313,7 @@ var ts;
|
|
|
72233
72313
|
getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
|
|
72234
72314
|
return getTypeOfSymbol(symbol);
|
|
72235
72315
|
}
|
|
72236
|
-
|
|
72237
|
-
// for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that
|
|
72238
|
-
if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
|
|
72316
|
+
if (shouldMarkIdentifierAliasReferenced(node)) {
|
|
72239
72317
|
markAliasReferenced(symbol, node);
|
|
72240
72318
|
}
|
|
72241
72319
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
@@ -72369,6 +72447,25 @@ var ts;
|
|
|
72369
72447
|
}
|
|
72370
72448
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
72371
72449
|
}
|
|
72450
|
+
function shouldMarkIdentifierAliasReferenced(node) {
|
|
72451
|
+
var _a;
|
|
72452
|
+
var parent = node.parent;
|
|
72453
|
+
if (parent) {
|
|
72454
|
+
// A property access expression LHS? checkPropertyAccessExpression will handle that.
|
|
72455
|
+
if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
|
|
72456
|
+
return false;
|
|
72457
|
+
}
|
|
72458
|
+
// Next two check for an identifier inside a type only export.
|
|
72459
|
+
if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
|
|
72460
|
+
return false;
|
|
72461
|
+
}
|
|
72462
|
+
var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
72463
|
+
if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
|
|
72464
|
+
return false;
|
|
72465
|
+
}
|
|
72466
|
+
}
|
|
72467
|
+
return true;
|
|
72468
|
+
}
|
|
72372
72469
|
function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
|
|
72373
72470
|
return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); });
|
|
72374
72471
|
}
|
|
@@ -72918,7 +73015,7 @@ var ts;
|
|
|
72918
73015
|
// We have an object literal method. Check if the containing object literal has a contextual type
|
|
72919
73016
|
// that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
|
|
72920
73017
|
// any directly enclosing object literals.
|
|
72921
|
-
var contextualType = getApparentTypeOfContextualType(containingLiteral);
|
|
73018
|
+
var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
|
|
72922
73019
|
var literal = containingLiteral;
|
|
72923
73020
|
var type = contextualType;
|
|
72924
73021
|
while (type) {
|
|
@@ -72930,7 +73027,7 @@ var ts;
|
|
|
72930
73027
|
break;
|
|
72931
73028
|
}
|
|
72932
73029
|
literal = literal.parent.parent;
|
|
72933
|
-
type = getApparentTypeOfContextualType(literal);
|
|
73030
|
+
type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
|
|
72934
73031
|
}
|
|
72935
73032
|
// There was no contextual ThisType<T> for the containing object literal, so the contextual type
|
|
72936
73033
|
// for 'this' is the non-null form of the contextual type for the containing object literal or
|
|
@@ -72987,7 +73084,7 @@ var ts;
|
|
|
72987
73084
|
tryGetTypeAtPosition(contextualSignature, index);
|
|
72988
73085
|
}
|
|
72989
73086
|
}
|
|
72990
|
-
function getContextualTypeForVariableLikeDeclaration(declaration) {
|
|
73087
|
+
function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
|
|
72991
73088
|
var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
|
|
72992
73089
|
if (typeNode) {
|
|
72993
73090
|
return getTypeFromTypeNode(typeNode);
|
|
@@ -72996,18 +73093,18 @@ var ts;
|
|
|
72996
73093
|
case 164 /* Parameter */:
|
|
72997
73094
|
return getContextuallyTypedParameterType(declaration);
|
|
72998
73095
|
case 203 /* BindingElement */:
|
|
72999
|
-
return getContextualTypeForBindingElement(declaration);
|
|
73096
|
+
return getContextualTypeForBindingElement(declaration, contextFlags);
|
|
73000
73097
|
case 167 /* PropertyDeclaration */:
|
|
73001
73098
|
if (ts.isStatic(declaration)) {
|
|
73002
|
-
return getContextualTypeForStaticPropertyDeclaration(declaration);
|
|
73099
|
+
return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
|
|
73003
73100
|
}
|
|
73004
73101
|
// By default, do nothing and return undefined - only the above cases have context implied by a parent
|
|
73005
73102
|
}
|
|
73006
73103
|
}
|
|
73007
|
-
function getContextualTypeForBindingElement(declaration) {
|
|
73104
|
+
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
73008
73105
|
var parent = declaration.parent.parent;
|
|
73009
73106
|
var name = declaration.propertyName || declaration.name;
|
|
73010
|
-
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
73107
|
+
var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
|
|
73011
73108
|
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
73012
73109
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
73013
73110
|
return undefined;
|
|
@@ -73023,8 +73120,8 @@ var ts;
|
|
|
73023
73120
|
return getTypeOfPropertyOfType(parentType, text);
|
|
73024
73121
|
}
|
|
73025
73122
|
}
|
|
73026
|
-
function getContextualTypeForStaticPropertyDeclaration(declaration) {
|
|
73027
|
-
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
|
|
73123
|
+
function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
|
|
73124
|
+
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
|
|
73028
73125
|
if (!parentType)
|
|
73029
73126
|
return undefined;
|
|
73030
73127
|
return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
|
|
@@ -73040,7 +73137,7 @@ var ts;
|
|
|
73040
73137
|
function getContextualTypeForInitializerExpression(node, contextFlags) {
|
|
73041
73138
|
var declaration = node.parent;
|
|
73042
73139
|
if (ts.hasInitializer(declaration) && node === declaration.initializer) {
|
|
73043
|
-
var result = getContextualTypeForVariableLikeDeclaration(declaration);
|
|
73140
|
+
var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
|
|
73044
73141
|
if (result) {
|
|
73045
73142
|
return result;
|
|
73046
73143
|
}
|
|
@@ -73050,10 +73147,10 @@ var ts;
|
|
|
73050
73147
|
}
|
|
73051
73148
|
return undefined;
|
|
73052
73149
|
}
|
|
73053
|
-
function getContextualTypeForReturnExpression(node) {
|
|
73150
|
+
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
73054
73151
|
var func = ts.getContainingFunction(node);
|
|
73055
73152
|
if (func) {
|
|
73056
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73153
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73057
73154
|
if (contextualReturnType) {
|
|
73058
73155
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73059
73156
|
if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
|
|
@@ -73083,11 +73180,11 @@ var ts;
|
|
|
73083
73180
|
}
|
|
73084
73181
|
return undefined;
|
|
73085
73182
|
}
|
|
73086
|
-
function getContextualTypeForYieldOperand(node) {
|
|
73183
|
+
function getContextualTypeForYieldOperand(node, contextFlags) {
|
|
73087
73184
|
var func = ts.getContainingFunction(node);
|
|
73088
73185
|
if (func) {
|
|
73089
73186
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73090
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73187
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73091
73188
|
if (contextualReturnType) {
|
|
73092
73189
|
return node.asteriskToken
|
|
73093
73190
|
? contextualReturnType
|
|
@@ -73111,14 +73208,14 @@ var ts;
|
|
|
73111
73208
|
}
|
|
73112
73209
|
function getContextualIterationType(kind, functionDecl) {
|
|
73113
73210
|
var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
|
|
73114
|
-
var contextualReturnType = getContextualReturnType(functionDecl);
|
|
73211
|
+
var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
|
|
73115
73212
|
if (contextualReturnType) {
|
|
73116
73213
|
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
|
|
73117
73214
|
|| undefined;
|
|
73118
73215
|
}
|
|
73119
73216
|
return undefined;
|
|
73120
73217
|
}
|
|
73121
|
-
function getContextualReturnType(functionDecl) {
|
|
73218
|
+
function getContextualReturnType(functionDecl, contextFlags) {
|
|
73122
73219
|
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
|
73123
73220
|
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
|
73124
73221
|
var returnType = getReturnTypeFromAnnotation(functionDecl);
|
|
@@ -73133,7 +73230,7 @@ var ts;
|
|
|
73133
73230
|
}
|
|
73134
73231
|
var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
|
|
73135
73232
|
if (iife) {
|
|
73136
|
-
return getContextualType(iife);
|
|
73233
|
+
return getContextualType(iife, contextFlags);
|
|
73137
73234
|
}
|
|
73138
73235
|
return undefined;
|
|
73139
73236
|
}
|
|
@@ -73386,7 +73483,7 @@ var ts;
|
|
|
73386
73483
|
}
|
|
73387
73484
|
function getContextualTypeForObjectLiteralElement(element, contextFlags) {
|
|
73388
73485
|
var objectLiteral = element.parent;
|
|
73389
|
-
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
|
|
73486
|
+
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
|
|
73390
73487
|
if (propertyAssignmentType) {
|
|
73391
73488
|
return propertyAssignmentType;
|
|
73392
73489
|
}
|
|
@@ -73581,9 +73678,9 @@ var ts;
|
|
|
73581
73678
|
return getContextualTypeForInitializerExpression(node, contextFlags);
|
|
73582
73679
|
case 214 /* ArrowFunction */:
|
|
73583
73680
|
case 247 /* ReturnStatement */:
|
|
73584
|
-
return getContextualTypeForReturnExpression(node);
|
|
73681
|
+
return getContextualTypeForReturnExpression(node, contextFlags);
|
|
73585
73682
|
case 224 /* YieldExpression */:
|
|
73586
|
-
return getContextualTypeForYieldOperand(parent);
|
|
73683
|
+
return getContextualTypeForYieldOperand(parent, contextFlags);
|
|
73587
73684
|
case 218 /* AwaitExpression */:
|
|
73588
73685
|
return getContextualTypeForAwaitOperand(parent, contextFlags);
|
|
73589
73686
|
case 208 /* CallExpression */:
|
|
@@ -73631,7 +73728,7 @@ var ts;
|
|
|
73631
73728
|
}
|
|
73632
73729
|
return undefined;
|
|
73633
73730
|
function tryFindWhenConstTypeReference(node) {
|
|
73634
|
-
return getContextualType(node);
|
|
73731
|
+
return getContextualType(node, contextFlags);
|
|
73635
73732
|
}
|
|
73636
73733
|
}
|
|
73637
73734
|
function getInferenceContext(node) {
|
|
@@ -73933,7 +74030,7 @@ var ts;
|
|
|
73933
74030
|
var elementCount = elements.length;
|
|
73934
74031
|
var elementTypes = [];
|
|
73935
74032
|
var elementFlags = [];
|
|
73936
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74033
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
73937
74034
|
var inDestructuringPattern = ts.isAssignmentTarget(node);
|
|
73938
74035
|
var inConstContext = isConstContext(node);
|
|
73939
74036
|
var hasOmittedExpression = false;
|
|
@@ -74104,7 +74201,7 @@ var ts;
|
|
|
74104
74201
|
var propertiesTable = ts.createSymbolTable();
|
|
74105
74202
|
var propertiesArray = [];
|
|
74106
74203
|
var spread = emptyObjectType;
|
|
74107
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74204
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74108
74205
|
var contextualTypeHasPattern = contextualType && contextualType.pattern &&
|
|
74109
74206
|
(contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
|
|
74110
74207
|
var inConstContext = isConstContext(node);
|
|
@@ -74443,7 +74540,7 @@ var ts;
|
|
|
74443
74540
|
if (explicitlySpecifyChildrenAttribute) {
|
|
74444
74541
|
error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
|
|
74445
74542
|
}
|
|
74446
|
-
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
|
|
74543
|
+
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
|
|
74447
74544
|
var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
|
|
74448
74545
|
// If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process
|
|
74449
74546
|
var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
|
|
@@ -76906,7 +77003,7 @@ var ts;
|
|
|
76906
77003
|
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
76907
77004
|
if (inferenceContext) {
|
|
76908
77005
|
var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
76909
|
-
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext
|
|
77006
|
+
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
76910
77007
|
// If the original signature has a generic rest type, instantiation may produce a
|
|
76911
77008
|
// signature with different arity and we need to perform another arity check.
|
|
76912
77009
|
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
|
|
@@ -78283,17 +78380,6 @@ var ts;
|
|
|
78283
78380
|
}
|
|
78284
78381
|
}
|
|
78285
78382
|
}
|
|
78286
|
-
var restType = getEffectiveRestType(context);
|
|
78287
|
-
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78288
|
-
// The contextual signature has a generic rest parameter. We first instantiate the contextual
|
|
78289
|
-
// signature (without fixing type parameters) and assign types to contextually typed parameters.
|
|
78290
|
-
var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
|
|
78291
|
-
assignContextualParameterTypes(signature, instantiatedContext);
|
|
78292
|
-
// We then infer from a tuple type representing the parameters that correspond to the contextual
|
|
78293
|
-
// rest parameter.
|
|
78294
|
-
var restPos = getParameterCount(context) - 1;
|
|
78295
|
-
inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
|
|
78296
|
-
}
|
|
78297
78383
|
}
|
|
78298
78384
|
function assignContextualParameterTypes(signature, context) {
|
|
78299
78385
|
if (context.typeParameters) {
|
|
@@ -78486,7 +78572,7 @@ var ts;
|
|
|
78486
78572
|
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
|
78487
78573
|
var contextualType = !contextualSignature ? undefined :
|
|
78488
78574
|
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
|
|
78489
|
-
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
|
|
78575
|
+
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
|
|
78490
78576
|
if (isGenerator) {
|
|
78491
78577
|
yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
|
|
78492
78578
|
returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
|
|
@@ -78557,7 +78643,7 @@ var ts;
|
|
|
78557
78643
|
nextType = iterationTypes && iterationTypes.nextType;
|
|
78558
78644
|
}
|
|
78559
78645
|
else {
|
|
78560
|
-
nextType = getContextualType(yieldExpression);
|
|
78646
|
+
nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
|
|
78561
78647
|
}
|
|
78562
78648
|
if (nextType)
|
|
78563
78649
|
ts.pushIfUnique(nextTypes, nextType);
|
|
@@ -78766,11 +78852,16 @@ var ts;
|
|
|
78766
78852
|
if (isContextSensitive(node)) {
|
|
78767
78853
|
if (contextualSignature) {
|
|
78768
78854
|
var inferenceContext = getInferenceContext(node);
|
|
78855
|
+
var instantiatedContextualSignature = void 0;
|
|
78769
78856
|
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
78770
78857
|
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
78858
|
+
var restType = getEffectiveRestType(contextualSignature);
|
|
78859
|
+
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78860
|
+
instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
|
|
78861
|
+
}
|
|
78771
78862
|
}
|
|
78772
|
-
|
|
78773
|
-
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
|
|
78863
|
+
instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
|
|
78864
|
+
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
|
|
78774
78865
|
assignContextualParameterTypes(signature, instantiatedContextualSignature);
|
|
78775
78866
|
}
|
|
78776
78867
|
else {
|
|
@@ -80012,7 +80103,7 @@ var ts;
|
|
|
80012
80103
|
type = anyType;
|
|
80013
80104
|
addLazyDiagnostic(function () {
|
|
80014
80105
|
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
80015
|
-
var contextualType = getContextualType(node);
|
|
80106
|
+
var contextualType = getContextualType(node, /*contextFlags*/ undefined);
|
|
80016
80107
|
if (!contextualType || isTypeAny(contextualType)) {
|
|
80017
80108
|
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
80018
80109
|
}
|
|
@@ -80053,7 +80144,7 @@ var ts;
|
|
|
80053
80144
|
texts.push(span.literal.text);
|
|
80054
80145
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
80055
80146
|
}
|
|
80056
|
-
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80147
|
+
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80057
80148
|
}
|
|
80058
80149
|
function isTemplateLiteralContextualType(type) {
|
|
80059
80150
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
|
|
@@ -80081,7 +80172,7 @@ var ts;
|
|
|
80081
80172
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
80082
80173
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
80083
80174
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
80084
|
-
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
|
|
80175
|
+
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ?
|
|
80085
80176
|
getRegularTypeOfLiteralType(type) : type;
|
|
80086
80177
|
return result;
|
|
80087
80178
|
}
|
|
@@ -80196,7 +80287,7 @@ var ts;
|
|
|
80196
80287
|
var type = checkExpression(node, checkMode, forceTuple);
|
|
80197
80288
|
return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
|
|
80198
80289
|
isTypeAssertion(node) ? type :
|
|
80199
|
-
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
|
|
80290
|
+
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined));
|
|
80200
80291
|
}
|
|
80201
80292
|
function checkPropertyAssignment(node, checkMode) {
|
|
80202
80293
|
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
|
@@ -86178,7 +86269,9 @@ var ts;
|
|
|
86178
86269
|
error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
|
|
86179
86270
|
}
|
|
86180
86271
|
else {
|
|
86181
|
-
|
|
86272
|
+
if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
|
|
86273
|
+
markExportAsReferenced(node);
|
|
86274
|
+
}
|
|
86182
86275
|
var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
|
|
86183
86276
|
if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
|
|
86184
86277
|
checkExpressionCached(node.propertyName || node.name);
|
|
@@ -89539,9 +89632,6 @@ var ts;
|
|
|
89539
89632
|
else {
|
|
89540
89633
|
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89541
89634
|
}
|
|
89542
|
-
if (!isConstOrReadonly || isInvalidInitializer) {
|
|
89543
|
-
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89544
|
-
}
|
|
89545
89635
|
}
|
|
89546
89636
|
}
|
|
89547
89637
|
function checkGrammarVariableDeclaration(node) {
|
|
@@ -111326,7 +111416,7 @@ var ts;
|
|
|
111326
111416
|
return;
|
|
111327
111417
|
}
|
|
111328
111418
|
// Make sure not to write js file and source map file if any of them cannot be written
|
|
111329
|
-
if (
|
|
111419
|
+
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
|
|
111330
111420
|
emitSkipped = true;
|
|
111331
111421
|
return;
|
|
111332
111422
|
}
|
|
@@ -124588,7 +124678,6 @@ var ts;
|
|
|
124588
124678
|
var parsedConfigs; // Parsed commandline and watching cached for referenced projects
|
|
124589
124679
|
var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
|
|
124590
124680
|
var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
|
124591
|
-
var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
|
124592
124681
|
var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
|
124593
124682
|
var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
|
|
124594
124683
|
var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
|
|
@@ -124741,12 +124830,12 @@ var ts;
|
|
|
124741
124830
|
var program = getCurrentBuilderProgram();
|
|
124742
124831
|
if (hasChangedCompilerOptions) {
|
|
124743
124832
|
newLine = updateNewLine();
|
|
124744
|
-
if (program &&
|
|
124833
|
+
if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
124745
124834
|
resolutionCache.clear();
|
|
124746
124835
|
}
|
|
124747
124836
|
}
|
|
124748
124837
|
// All resolutions are invalid if user provided resolutions
|
|
124749
|
-
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution
|
|
124838
|
+
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
|
|
124750
124839
|
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
124751
124840
|
if (hasChangedConfigFileParsingErrors) {
|
|
124752
124841
|
if (reportFileChangeDetectedOnCreateProgram) {
|
|
@@ -124762,7 +124851,6 @@ var ts;
|
|
|
124762
124851
|
}
|
|
124763
124852
|
createNewProgram(hasInvalidatedResolution);
|
|
124764
124853
|
}
|
|
124765
|
-
changesAffectResolution = false; // reset for next sync
|
|
124766
124854
|
reportFileChangeDetectedOnCreateProgram = false;
|
|
124767
124855
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
124768
124856
|
host.afterProgramCreate(builderProgram);
|
|
@@ -126143,7 +126231,7 @@ var ts;
|
|
|
126143
126231
|
}
|
|
126144
126232
|
function afterProgramDone(state, program, config) {
|
|
126145
126233
|
if (program) {
|
|
126146
|
-
if (
|
|
126234
|
+
if (state.write)
|
|
126147
126235
|
ts.listFiles(program, state.write);
|
|
126148
126236
|
if (state.host.afterProgramEmitAndDiagnostics) {
|
|
126149
126237
|
state.host.afterProgramEmitAndDiagnostics(program);
|