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/tsserverlibrary.js
CHANGED
|
@@ -303,7 +303,7 @@ var ts;
|
|
|
303
303
|
// The following is baselined as a literal template type without intervention
|
|
304
304
|
/** The version of the TypeScript compiler release */
|
|
305
305
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
306
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220708";
|
|
307
307
|
/* @internal */
|
|
308
308
|
var Comparison;
|
|
309
309
|
(function (Comparison) {
|
|
@@ -2259,7 +2259,7 @@ var ts;
|
|
|
2259
2259
|
* and 1 insertion/deletion at 3 characters)
|
|
2260
2260
|
*/
|
|
2261
2261
|
function getSpellingSuggestion(name, candidates, getName) {
|
|
2262
|
-
var maximumLengthDifference = Math.
|
|
2262
|
+
var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
|
|
2263
2263
|
var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
|
|
2264
2264
|
var bestCandidate;
|
|
2265
2265
|
for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
|
|
@@ -2988,6 +2988,22 @@ var ts;
|
|
|
2988
2988
|
return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true);
|
|
2989
2989
|
}
|
|
2990
2990
|
Debug.formatFlowFlags = formatFlowFlags;
|
|
2991
|
+
function formatRelationComparisonResult(result) {
|
|
2992
|
+
return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true);
|
|
2993
|
+
}
|
|
2994
|
+
Debug.formatRelationComparisonResult = formatRelationComparisonResult;
|
|
2995
|
+
function formatCheckMode(mode) {
|
|
2996
|
+
return formatEnum(mode, ts.CheckMode, /*isFlags*/ true);
|
|
2997
|
+
}
|
|
2998
|
+
Debug.formatCheckMode = formatCheckMode;
|
|
2999
|
+
function formatSignatureCheckMode(mode) {
|
|
3000
|
+
return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true);
|
|
3001
|
+
}
|
|
3002
|
+
Debug.formatSignatureCheckMode = formatSignatureCheckMode;
|
|
3003
|
+
function formatTypeFacts(facts) {
|
|
3004
|
+
return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true);
|
|
3005
|
+
}
|
|
3006
|
+
Debug.formatTypeFacts = formatTypeFacts;
|
|
2991
3007
|
var isDebugInfoEnabled = false;
|
|
2992
3008
|
var extendedDebugModule;
|
|
2993
3009
|
function extendedDebug() {
|
|
@@ -4940,6 +4956,7 @@ var ts;
|
|
|
4940
4956
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4941
4957
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4942
4958
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4959
|
+
NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4943
4960
|
// Error handling
|
|
4944
4961
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4945
4962
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -4980,6 +4997,7 @@ var ts;
|
|
|
4980
4997
|
TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4981
4998
|
TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4982
4999
|
TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
5000
|
+
TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4983
5001
|
// Error Handling
|
|
4984
5002
|
TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
|
|
4985
5003
|
// TypeFormatFlags exclusive
|
|
@@ -4991,7 +5009,7 @@ var ts;
|
|
|
4991
5009
|
TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
|
|
4992
5010
|
TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
|
|
4993
5011
|
/** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
|
|
4994
|
-
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] =
|
|
5012
|
+
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
|
|
4995
5013
|
})(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
|
|
4996
5014
|
var SymbolFormatFlags;
|
|
4997
5015
|
(function (SymbolFormatFlags) {
|
|
@@ -9225,6 +9243,7 @@ var ts;
|
|
|
9225
9243
|
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'."),
|
|
9226
9244
|
_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?"),
|
|
9227
9245
|
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."),
|
|
9246
|
+
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."),
|
|
9228
9247
|
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}'."),
|
|
9229
9248
|
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}'."),
|
|
9230
9249
|
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}'."),
|
|
@@ -19723,7 +19742,8 @@ var ts;
|
|
|
19723
19742
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
|
|
19724
19743
|
if (isWrite === void 0) { isWrite = false; }
|
|
19725
19744
|
if (s.valueDeclaration) {
|
|
19726
|
-
var declaration = (isWrite && s.declarations && ts.find(s.declarations,
|
|
19745
|
+
var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
|
|
19746
|
+
|| (s.flags & 32768 /* GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
|
|
19727
19747
|
var flags = ts.getCombinedModifierFlags(declaration);
|
|
19728
19748
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
|
|
19729
19749
|
}
|
|
@@ -20398,7 +20418,7 @@ var ts;
|
|
|
20398
20418
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20399
20419
|
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20400
20420
|
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20401
|
-
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20421
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20402
20422
|
}
|
|
20403
20423
|
function getSetExternalModuleIndicator(options) {
|
|
20404
20424
|
// TODO: Should this callback be cached?
|
|
@@ -20421,10 +20441,7 @@ var ts;
|
|
|
20421
20441
|
if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
|
|
20422
20442
|
checks.push(isFileModuleFromUsingJSXTag);
|
|
20423
20443
|
}
|
|
20424
|
-
|
|
20425
|
-
if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
20426
|
-
checks.push(isFileForcedToBeModuleByFormat);
|
|
20427
|
-
}
|
|
20444
|
+
checks.push(isFileForcedToBeModuleByFormat);
|
|
20428
20445
|
var combined_1 = ts.or.apply(void 0, checks);
|
|
20429
20446
|
var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
|
|
20430
20447
|
return callback;
|
|
@@ -34144,10 +34161,10 @@ var ts;
|
|
|
34144
34161
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
34145
34162
|
var modifiers = parseModifiers();
|
|
34146
34163
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
34147
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
|
|
34164
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
|
|
34148
34165
|
}
|
|
34149
34166
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
34150
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
|
|
34167
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
|
|
34151
34168
|
}
|
|
34152
34169
|
if (isIndexSignature()) {
|
|
34153
34170
|
return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
|
|
@@ -36193,10 +36210,10 @@ var ts;
|
|
|
36193
36210
|
var decorators = parseDecorators();
|
|
36194
36211
|
var modifiers = parseModifiers();
|
|
36195
36212
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
36196
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
36213
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
36197
36214
|
}
|
|
36198
36215
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
36199
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
36216
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
36200
36217
|
}
|
|
36201
36218
|
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
|
36202
36219
|
var tokenIsIdentifier = isIdentifier();
|
|
@@ -36888,9 +36905,15 @@ var ts;
|
|
|
36888
36905
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
|
|
36889
36906
|
}
|
|
36890
36907
|
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
|
|
36891
|
-
if (token() !== 18 /* OpenBraceToken */
|
|
36892
|
-
|
|
36893
|
-
|
|
36908
|
+
if (token() !== 18 /* OpenBraceToken */) {
|
|
36909
|
+
if (flags & 4 /* Type */) {
|
|
36910
|
+
parseTypeMemberSemicolon();
|
|
36911
|
+
return;
|
|
36912
|
+
}
|
|
36913
|
+
if (canParseSemicolon()) {
|
|
36914
|
+
parseSemicolon();
|
|
36915
|
+
return;
|
|
36916
|
+
}
|
|
36894
36917
|
}
|
|
36895
36918
|
return parseFunctionBlock(flags, diagnosticMessage);
|
|
36896
36919
|
}
|
|
@@ -37094,12 +37117,12 @@ var ts;
|
|
|
37094
37117
|
}
|
|
37095
37118
|
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
|
|
37096
37119
|
}
|
|
37097
|
-
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
|
|
37120
|
+
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
|
|
37098
37121
|
var name = parsePropertyName();
|
|
37099
37122
|
var typeParameters = parseTypeParameters();
|
|
37100
37123
|
var parameters = parseParameters(0 /* None */);
|
|
37101
37124
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
37102
|
-
var body = parseFunctionBlockOrSemicolon(
|
|
37125
|
+
var body = parseFunctionBlockOrSemicolon(flags);
|
|
37103
37126
|
var node = kind === 172 /* GetAccessor */
|
|
37104
37127
|
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
|
|
37105
37128
|
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
|
|
@@ -37286,10 +37309,10 @@ var ts;
|
|
|
37286
37309
|
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
37287
37310
|
}
|
|
37288
37311
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
37289
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
37312
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
37290
37313
|
}
|
|
37291
37314
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
37292
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
37315
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
37293
37316
|
}
|
|
37294
37317
|
if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
|
|
37295
37318
|
var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -44600,6 +44623,7 @@ var ts;
|
|
|
44600
44623
|
return toSearchResult(/*value*/ undefined);
|
|
44601
44624
|
}
|
|
44602
44625
|
/**
|
|
44626
|
+
* @internal
|
|
44603
44627
|
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
|
44604
44628
|
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
|
44605
44629
|
*/
|
|
@@ -44622,6 +44646,7 @@ var ts;
|
|
|
44622
44646
|
return 1;
|
|
44623
44647
|
return 0;
|
|
44624
44648
|
}
|
|
44649
|
+
ts.comparePatternKeys = comparePatternKeys;
|
|
44625
44650
|
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
44626
44651
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44627
44652
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
@@ -48693,7 +48718,7 @@ var ts;
|
|
|
48693
48718
|
// Masks
|
|
48694
48719
|
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
48695
48720
|
TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
|
|
48696
|
-
})(TypeFacts || (TypeFacts = {}));
|
|
48721
|
+
})(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
|
|
48697
48722
|
var typeofNEFacts = new ts.Map(ts.getEntries({
|
|
48698
48723
|
string: 256 /* TypeofNEString */,
|
|
48699
48724
|
number: 512 /* TypeofNENumber */,
|
|
@@ -48728,7 +48753,7 @@ var ts;
|
|
|
48728
48753
|
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
48729
48754
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
48730
48755
|
// we need to preserve generic types instead of substituting them for constraints
|
|
48731
|
-
})(CheckMode || (CheckMode = {}));
|
|
48756
|
+
})(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
|
|
48732
48757
|
var SignatureCheckMode;
|
|
48733
48758
|
(function (SignatureCheckMode) {
|
|
48734
48759
|
SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
|
|
@@ -48736,7 +48761,7 @@ var ts;
|
|
|
48736
48761
|
SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
|
|
48737
48762
|
SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
|
|
48738
48763
|
SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
|
|
48739
|
-
})(SignatureCheckMode || (SignatureCheckMode = {}));
|
|
48764
|
+
})(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
|
|
48740
48765
|
var IntersectionState;
|
|
48741
48766
|
(function (IntersectionState) {
|
|
48742
48767
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
@@ -49088,7 +49113,7 @@ var ts;
|
|
|
49088
49113
|
},
|
|
49089
49114
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
49090
49115
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
49091
|
-
return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
|
|
49116
|
+
return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
|
|
49092
49117
|
},
|
|
49093
49118
|
getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
|
|
49094
49119
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -49096,7 +49121,7 @@ var ts;
|
|
|
49096
49121
|
},
|
|
49097
49122
|
getContextualTypeForJsxAttribute: function (nodeIn) {
|
|
49098
49123
|
var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
|
|
49099
|
-
return node && getContextualTypeForJsxAttribute(node);
|
|
49124
|
+
return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
|
|
49100
49125
|
},
|
|
49101
49126
|
isContextSensitive: isContextSensitive,
|
|
49102
49127
|
getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
|
|
@@ -49302,6 +49327,7 @@ var ts;
|
|
|
49302
49327
|
var stringMappingTypes = new ts.Map();
|
|
49303
49328
|
var substitutionTypes = new ts.Map();
|
|
49304
49329
|
var subtypeReductionCache = new ts.Map();
|
|
49330
|
+
var cachedTypes = new ts.Map();
|
|
49305
49331
|
var evolvingArrayTypes = [];
|
|
49306
49332
|
var undefinedProperties = new ts.Map();
|
|
49307
49333
|
var markerTypes = new ts.Set();
|
|
@@ -49555,6 +49581,14 @@ var ts;
|
|
|
49555
49581
|
];
|
|
49556
49582
|
initializeTypeChecker();
|
|
49557
49583
|
return checker;
|
|
49584
|
+
function getCachedType(key) {
|
|
49585
|
+
return key ? cachedTypes.get(key) : undefined;
|
|
49586
|
+
}
|
|
49587
|
+
function setCachedType(key, type) {
|
|
49588
|
+
if (key)
|
|
49589
|
+
cachedTypes.set(key, type);
|
|
49590
|
+
return type;
|
|
49591
|
+
}
|
|
49558
49592
|
function getJsxNamespace(location) {
|
|
49559
49593
|
if (location) {
|
|
49560
49594
|
var file = ts.getSourceFileOfNode(location);
|
|
@@ -50419,6 +50453,7 @@ var ts;
|
|
|
50419
50453
|
if (ctor && ctor.locals) {
|
|
50420
50454
|
if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
|
|
50421
50455
|
// Remember the property node, it will be used later to report appropriate error
|
|
50456
|
+
ts.Debug.assertNode(location, ts.isPropertyDeclaration);
|
|
50422
50457
|
propertyWithInvalidInitializer = location;
|
|
50423
50458
|
}
|
|
50424
50459
|
}
|
|
@@ -50608,11 +50643,27 @@ var ts;
|
|
|
50608
50643
|
}
|
|
50609
50644
|
}
|
|
50610
50645
|
}
|
|
50646
|
+
// The invalid initializer error is needed in two situation:
|
|
50647
|
+
// 1. When result is undefined, after checking for a missing "this."
|
|
50648
|
+
// 2. When result is defined
|
|
50649
|
+
function checkAndReportErrorForInvalidInitializer() {
|
|
50650
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
50651
|
+
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50652
|
+
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50653
|
+
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
50654
|
+
error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
|
|
50655
|
+
? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
|
|
50656
|
+
: ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
|
|
50657
|
+
return true;
|
|
50658
|
+
}
|
|
50659
|
+
return false;
|
|
50660
|
+
}
|
|
50611
50661
|
if (!result) {
|
|
50612
50662
|
if (nameNotFoundMessage) {
|
|
50613
50663
|
addLazyDiagnostic(function () {
|
|
50614
50664
|
if (!errorLocation ||
|
|
50615
50665
|
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
50666
|
+
!checkAndReportErrorForInvalidInitializer() &&
|
|
50616
50667
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50617
50668
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50618
50669
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
@@ -50620,7 +50671,16 @@ var ts;
|
|
|
50620
50671
|
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50621
50672
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50622
50673
|
var suggestion = void 0;
|
|
50623
|
-
|
|
50674
|
+
var suggestedLib = void 0;
|
|
50675
|
+
// Report missing lib first
|
|
50676
|
+
if (nameArg) {
|
|
50677
|
+
suggestedLib = getSuggestedLibForNonExistentName(nameArg);
|
|
50678
|
+
if (suggestedLib) {
|
|
50679
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
|
|
50680
|
+
}
|
|
50681
|
+
}
|
|
50682
|
+
// then spelling suggestions
|
|
50683
|
+
if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
50624
50684
|
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
50625
50685
|
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
50626
50686
|
if (isGlobalScopeAugmentationDeclaration) {
|
|
@@ -50639,16 +50699,9 @@ var ts;
|
|
|
50639
50699
|
}
|
|
50640
50700
|
}
|
|
50641
50701
|
}
|
|
50642
|
-
|
|
50643
|
-
|
|
50644
|
-
|
|
50645
|
-
if (lib) {
|
|
50646
|
-
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
|
|
50647
|
-
}
|
|
50648
|
-
else {
|
|
50649
|
-
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
50650
|
-
}
|
|
50651
|
-
}
|
|
50702
|
+
// And then fall back to unspecified "not found"
|
|
50703
|
+
if (!suggestion && !suggestedLib && nameArg) {
|
|
50704
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
50652
50705
|
}
|
|
50653
50706
|
suggestionCount++;
|
|
50654
50707
|
}
|
|
@@ -50656,12 +50709,7 @@ var ts;
|
|
|
50656
50709
|
}
|
|
50657
50710
|
return undefined;
|
|
50658
50711
|
}
|
|
50659
|
-
if (
|
|
50660
|
-
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50661
|
-
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50662
|
-
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
50663
|
-
var propertyName = propertyWithInvalidInitializer.name;
|
|
50664
|
-
error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
|
|
50712
|
+
else if (checkAndReportErrorForInvalidInitializer()) {
|
|
50665
50713
|
return undefined;
|
|
50666
50714
|
}
|
|
50667
50715
|
// Perform extra checks only if error reporting was requested
|
|
@@ -52810,13 +52858,25 @@ var ts;
|
|
|
52810
52858
|
&& isDeclarationVisible(declaration.parent)) {
|
|
52811
52859
|
return addVisibleAlias(declaration, declaration);
|
|
52812
52860
|
}
|
|
52813
|
-
else if (
|
|
52814
|
-
&& ts.
|
|
52815
|
-
|
|
52816
|
-
|
|
52817
|
-
|
|
52818
|
-
|
|
52819
|
-
|
|
52861
|
+
else if (ts.isBindingElement(declaration)) {
|
|
52862
|
+
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
|
|
52863
|
+
&& ts.isVariableDeclaration(declaration.parent.parent)
|
|
52864
|
+
&& ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
|
|
52865
|
+
&& !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
|
|
52866
|
+
&& declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
|
|
52867
|
+
&& isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
|
|
52868
|
+
return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
|
|
52869
|
+
}
|
|
52870
|
+
else if (symbol.flags & 2 /* BlockScopedVariable */) {
|
|
52871
|
+
var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
|
|
52872
|
+
if (ts.hasSyntacticModifier(variableStatement, 1 /* Export */)) {
|
|
52873
|
+
return true;
|
|
52874
|
+
}
|
|
52875
|
+
if (!isDeclarationVisible(variableStatement.parent)) {
|
|
52876
|
+
return false;
|
|
52877
|
+
}
|
|
52878
|
+
return addVisibleAlias(declaration, variableStatement);
|
|
52879
|
+
}
|
|
52820
52880
|
}
|
|
52821
52881
|
// Declaration is not visible
|
|
52822
52882
|
return false;
|
|
@@ -52949,7 +53009,7 @@ var ts;
|
|
|
52949
53009
|
}
|
|
52950
53010
|
function toNodeBuilderFlags(flags) {
|
|
52951
53011
|
if (flags === void 0) { flags = 0 /* None */; }
|
|
52952
|
-
return flags &
|
|
53012
|
+
return flags & 848330091 /* NodeBuilderFlagsMask */;
|
|
52953
53013
|
}
|
|
52954
53014
|
function isClassInstanceSide(type) {
|
|
52955
53015
|
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
|
|
@@ -53337,6 +53397,10 @@ var ts;
|
|
|
53337
53397
|
}
|
|
53338
53398
|
return typeToTypeNodeHelper(type, context);
|
|
53339
53399
|
}
|
|
53400
|
+
function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
|
|
53401
|
+
return isMappedTypeWithKeyofConstraintDeclaration(type)
|
|
53402
|
+
&& !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
|
|
53403
|
+
}
|
|
53340
53404
|
function createMappedTypeNodeFromType(type) {
|
|
53341
53405
|
ts.Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
53342
53406
|
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
|
|
@@ -53346,7 +53410,7 @@ var ts;
|
|
|
53346
53410
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
53347
53411
|
// We have a { [P in keyof T]: X }
|
|
53348
53412
|
// We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
|
|
53349
|
-
if (
|
|
53413
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53350
53414
|
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
53351
53415
|
var name = typeParameterToName(newParam, context);
|
|
53352
53416
|
newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
@@ -53362,11 +53426,12 @@ var ts;
|
|
|
53362
53426
|
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
53363
53427
|
context.approximateLength += 10;
|
|
53364
53428
|
var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
53365
|
-
if (
|
|
53429
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53366
53430
|
// homomorphic mapped type with a non-homomorphic naive inlining
|
|
53367
53431
|
// wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
|
|
53368
53432
|
// type stays homomorphic
|
|
53369
|
-
|
|
53433
|
+
var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
|
|
53434
|
+
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 */));
|
|
53370
53435
|
}
|
|
53371
53436
|
return result;
|
|
53372
53437
|
}
|
|
@@ -53928,7 +53993,7 @@ var ts;
|
|
|
53928
53993
|
var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
|
|
53929
53994
|
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
|
|
53930
53995
|
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); });
|
|
53931
|
-
var thisParameter = tryGetThisParameterDeclaration(signature, context);
|
|
53996
|
+
var thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context);
|
|
53932
53997
|
if (thisParameter) {
|
|
53933
53998
|
parameters.unshift(thisParameter);
|
|
53934
53999
|
}
|
|
@@ -54987,12 +55052,11 @@ var ts;
|
|
|
54987
55052
|
if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
|
|
54988
55053
|
var oldContext = context;
|
|
54989
55054
|
context = cloneNodeBuilderContext(context);
|
|
54990
|
-
|
|
55055
|
+
serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
|
|
54991
55056
|
if (context.reportedDiagnostic) {
|
|
54992
55057
|
oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
|
|
54993
55058
|
}
|
|
54994
55059
|
context = oldContext;
|
|
54995
|
-
return result;
|
|
54996
55060
|
}
|
|
54997
55061
|
}
|
|
54998
55062
|
// Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
|
|
@@ -58049,7 +58113,7 @@ var ts;
|
|
|
58049
58113
|
error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
58050
58114
|
}
|
|
58051
58115
|
else {
|
|
58052
|
-
error(ts.isNamedDeclaration(declaration) ? declaration.name
|
|
58116
|
+
error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
58053
58117
|
}
|
|
58054
58118
|
}
|
|
58055
58119
|
links.declaredType = type;
|
|
@@ -62512,19 +62576,22 @@ var ts;
|
|
|
62512
62576
|
* to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
|
|
62513
62577
|
*/
|
|
62514
62578
|
function isPossiblyReducibleByInstantiation(type) {
|
|
62515
|
-
|
|
62516
|
-
|
|
62517
|
-
|
|
62518
|
-
|
|
62579
|
+
var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
|
|
62580
|
+
return getReducedType(uniqueFilled) !== uniqueFilled;
|
|
62581
|
+
}
|
|
62582
|
+
function shouldDeferIndexType(type) {
|
|
62583
|
+
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
|
|
62584
|
+
isGenericTupleType(type) ||
|
|
62585
|
+
isGenericMappedType(type) && !hasDistributiveNameType(type) ||
|
|
62586
|
+
type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
|
|
62587
|
+
type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
|
|
62519
62588
|
}
|
|
62520
62589
|
function getIndexType(type, stringsOnly, noIndexSignatures) {
|
|
62521
62590
|
if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
|
|
62522
62591
|
type = getReducedType(type);
|
|
62523
|
-
return type
|
|
62524
|
-
?
|
|
62525
|
-
|
|
62526
|
-
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
62527
|
-
type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
62592
|
+
return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
62593
|
+
type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
62594
|
+
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
62528
62595
|
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
|
|
62529
62596
|
type === wildcardType ? wildcardType :
|
|
62530
62597
|
type.flags & 2 /* Unknown */ ? neverType :
|
|
@@ -66317,13 +66384,20 @@ var ts;
|
|
|
66317
66384
|
return result;
|
|
66318
66385
|
}
|
|
66319
66386
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66387
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
66388
|
+
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66389
|
+
if (result) {
|
|
66390
|
+
resetErrorInfo(saveErrorInfo);
|
|
66391
|
+
}
|
|
66392
|
+
return result;
|
|
66393
|
+
}
|
|
66394
|
+
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
66320
66395
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
66321
66396
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
66322
66397
|
}
|
|
66323
66398
|
var result;
|
|
66324
66399
|
var originalErrorInfo;
|
|
66325
66400
|
var varianceCheckFailed = false;
|
|
66326
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
66327
66401
|
var sourceFlags = source.flags;
|
|
66328
66402
|
var targetFlags = target.flags;
|
|
66329
66403
|
if (relation === identityRelation) {
|
|
@@ -66387,7 +66461,6 @@ var ts;
|
|
|
66387
66461
|
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66388
66462
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66389
66463
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66390
|
-
resetErrorInfo(saveErrorInfo);
|
|
66391
66464
|
return result;
|
|
66392
66465
|
}
|
|
66393
66466
|
}
|
|
@@ -66512,7 +66585,6 @@ var ts;
|
|
|
66512
66585
|
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
66513
66586
|
}
|
|
66514
66587
|
if (result) {
|
|
66515
|
-
resetErrorInfo(saveErrorInfo);
|
|
66516
66588
|
return result;
|
|
66517
66589
|
}
|
|
66518
66590
|
if (reportErrors) {
|
|
@@ -66615,7 +66687,6 @@ var ts;
|
|
|
66615
66687
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66616
66688
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66617
66689
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
66618
|
-
resetErrorInfo(saveErrorInfo);
|
|
66619
66690
|
return 3 /* Maybe */;
|
|
66620
66691
|
}
|
|
66621
66692
|
var c = target;
|
|
@@ -66630,7 +66701,6 @@ var ts;
|
|
|
66630
66701
|
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
66631
66702
|
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
66632
66703
|
if (result) {
|
|
66633
|
-
resetErrorInfo(saveErrorInfo);
|
|
66634
66704
|
return result;
|
|
66635
66705
|
}
|
|
66636
66706
|
}
|
|
@@ -66662,12 +66732,10 @@ var ts;
|
|
|
66662
66732
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
66663
66733
|
// 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
|
|
66664
66734
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66665
|
-
resetErrorInfo(saveErrorInfo);
|
|
66666
66735
|
return result;
|
|
66667
66736
|
}
|
|
66668
66737
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
66669
66738
|
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
66670
|
-
resetErrorInfo(saveErrorInfo);
|
|
66671
66739
|
return result;
|
|
66672
66740
|
}
|
|
66673
66741
|
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
@@ -66676,7 +66744,6 @@ var ts;
|
|
|
66676
66744
|
var indexConstraint = getConstraintOfType(source.indexType);
|
|
66677
66745
|
if (indexConstraint) {
|
|
66678
66746
|
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
66679
|
-
resetErrorInfo(saveErrorInfo);
|
|
66680
66747
|
return result;
|
|
66681
66748
|
}
|
|
66682
66749
|
}
|
|
@@ -66685,7 +66752,6 @@ var ts;
|
|
|
66685
66752
|
}
|
|
66686
66753
|
else if (sourceFlags & 4194304 /* Index */) {
|
|
66687
66754
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
66688
|
-
resetErrorInfo(saveErrorInfo);
|
|
66689
66755
|
return result;
|
|
66690
66756
|
}
|
|
66691
66757
|
}
|
|
@@ -66693,7 +66759,6 @@ var ts;
|
|
|
66693
66759
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66694
66760
|
var constraint = getBaseConstraintOfType(source);
|
|
66695
66761
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66696
|
-
resetErrorInfo(saveErrorInfo);
|
|
66697
66762
|
return result;
|
|
66698
66763
|
}
|
|
66699
66764
|
}
|
|
@@ -66704,14 +66769,12 @@ var ts;
|
|
|
66704
66769
|
return 0 /* False */;
|
|
66705
66770
|
}
|
|
66706
66771
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66707
|
-
resetErrorInfo(saveErrorInfo);
|
|
66708
66772
|
return result;
|
|
66709
66773
|
}
|
|
66710
66774
|
}
|
|
66711
66775
|
else {
|
|
66712
66776
|
var constraint = getBaseConstraintOfType(source);
|
|
66713
66777
|
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66714
|
-
resetErrorInfo(saveErrorInfo);
|
|
66715
66778
|
return result;
|
|
66716
66779
|
}
|
|
66717
66780
|
}
|
|
@@ -66720,7 +66783,6 @@ var ts;
|
|
|
66720
66783
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66721
66784
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66722
66785
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
66723
|
-
resetErrorInfo(saveErrorInfo);
|
|
66724
66786
|
return 3 /* Maybe */;
|
|
66725
66787
|
}
|
|
66726
66788
|
if (targetFlags & 16777216 /* Conditional */) {
|
|
@@ -66743,7 +66805,6 @@ var ts;
|
|
|
66743
66805
|
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
66744
66806
|
}
|
|
66745
66807
|
if (result) {
|
|
66746
|
-
resetErrorInfo(saveErrorInfo);
|
|
66747
66808
|
return result;
|
|
66748
66809
|
}
|
|
66749
66810
|
}
|
|
@@ -66754,7 +66815,6 @@ var ts;
|
|
|
66754
66815
|
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
66755
66816
|
if (distributiveConstraint) {
|
|
66756
66817
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66757
|
-
resetErrorInfo(saveErrorInfo);
|
|
66758
66818
|
return result;
|
|
66759
66819
|
}
|
|
66760
66820
|
}
|
|
@@ -66764,7 +66824,6 @@ var ts;
|
|
|
66764
66824
|
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
66765
66825
|
if (defaultConstraint) {
|
|
66766
66826
|
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66767
|
-
resetErrorInfo(saveErrorInfo);
|
|
66768
66827
|
return result;
|
|
66769
66828
|
}
|
|
66770
66829
|
}
|
|
@@ -66777,7 +66836,6 @@ var ts;
|
|
|
66777
66836
|
if (isGenericMappedType(target)) {
|
|
66778
66837
|
if (isGenericMappedType(source)) {
|
|
66779
66838
|
if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
|
|
66780
|
-
resetErrorInfo(saveErrorInfo);
|
|
66781
66839
|
return result;
|
|
66782
66840
|
}
|
|
66783
66841
|
}
|
|
@@ -68232,9 +68290,14 @@ var ts;
|
|
|
68232
68290
|
type.flags & 256 /* NumberLiteral */ ? numberType :
|
|
68233
68291
|
type.flags & 2048 /* BigIntLiteral */ ? bigintType :
|
|
68234
68292
|
type.flags & 512 /* BooleanLiteral */ ? booleanType :
|
|
68235
|
-
type.flags & 1048576 /* Union */ ?
|
|
68293
|
+
type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) :
|
|
68236
68294
|
type;
|
|
68237
68295
|
}
|
|
68296
|
+
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
68297
|
+
var _a;
|
|
68298
|
+
var key = "B" + getTypeId(type);
|
|
68299
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
68300
|
+
}
|
|
68238
68301
|
function getWidenedLiteralType(type) {
|
|
68239
68302
|
return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
|
|
68240
68303
|
type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
|
|
@@ -70118,6 +70181,15 @@ var ts;
|
|
|
70118
70181
|
var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
|
|
70119
70182
|
return key && key + "." + propName;
|
|
70120
70183
|
}
|
|
70184
|
+
break;
|
|
70185
|
+
case 201 /* ObjectBindingPattern */:
|
|
70186
|
+
case 202 /* ArrayBindingPattern */:
|
|
70187
|
+
case 256 /* FunctionDeclaration */:
|
|
70188
|
+
case 213 /* FunctionExpression */:
|
|
70189
|
+
case 214 /* ArrowFunction */:
|
|
70190
|
+
case 169 /* MethodDeclaration */:
|
|
70191
|
+
// Handle pseudo-references originating in getNarrowedTypeOfSymbol.
|
|
70192
|
+
return getNodeId(node) + "#" + getTypeId(declaredType);
|
|
70121
70193
|
}
|
|
70122
70194
|
return undefined;
|
|
70123
70195
|
}
|
|
@@ -70377,23 +70449,25 @@ var ts;
|
|
|
70377
70449
|
// For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
|
|
70378
70450
|
// we remove type string.
|
|
70379
70451
|
function getAssignmentReducedType(declaredType, assignedType) {
|
|
70380
|
-
|
|
70381
|
-
|
|
70382
|
-
|
|
70383
|
-
}
|
|
70384
|
-
var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70385
|
-
if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
|
|
70386
|
-
reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
|
|
70387
|
-
}
|
|
70388
|
-
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70389
|
-
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70390
|
-
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70391
|
-
// is not assignable to the declared type.)
|
|
70392
|
-
if (isTypeAssignableTo(assignedType, reducedType)) {
|
|
70393
|
-
return reducedType;
|
|
70394
|
-
}
|
|
70452
|
+
var _a;
|
|
70453
|
+
if (declaredType === assignedType) {
|
|
70454
|
+
return declaredType;
|
|
70395
70455
|
}
|
|
70396
|
-
|
|
70456
|
+
if (assignedType.flags & 131072 /* Never */) {
|
|
70457
|
+
return assignedType;
|
|
70458
|
+
}
|
|
70459
|
+
var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
|
|
70460
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
|
|
70461
|
+
}
|
|
70462
|
+
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
70463
|
+
var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70464
|
+
// Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type.
|
|
70465
|
+
var reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
70466
|
+
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70467
|
+
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70468
|
+
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70469
|
+
// is not assignable to the declared type.)
|
|
70470
|
+
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
70397
70471
|
}
|
|
70398
70472
|
function isFunctionObjectType(type) {
|
|
70399
70473
|
// We do a quick check for a "bind" property before performing the more expensive subtype
|
|
@@ -71799,7 +71873,7 @@ var ts;
|
|
|
71799
71873
|
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
71800
71874
|
? getTypeOfSymbol(classSymbol)
|
|
71801
71875
|
: getDeclaredTypeOfSymbol(classSymbol);
|
|
71802
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
71876
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
71803
71877
|
}
|
|
71804
71878
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
71805
71879
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
@@ -72050,9 +72124,15 @@ var ts;
|
|
|
72050
72124
|
if (!nonConstructorTypeInUnion)
|
|
72051
72125
|
return type;
|
|
72052
72126
|
}
|
|
72053
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
72127
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
72128
|
+
}
|
|
72129
|
+
function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
|
|
72130
|
+
var _a;
|
|
72131
|
+
var key = type.flags & 1048576 /* Union */ ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
|
|
72132
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
|
|
72054
72133
|
}
|
|
72055
|
-
function
|
|
72134
|
+
function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
|
|
72135
|
+
var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
|
|
72056
72136
|
if (!assumeTrue) {
|
|
72057
72137
|
return filterType(type, function (t) { return !isRelated(t, candidate); });
|
|
72058
72138
|
}
|
|
@@ -72100,7 +72180,7 @@ var ts;
|
|
|
72100
72180
|
var predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
72101
72181
|
if (predicateArgument) {
|
|
72102
72182
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
72103
|
-
return getNarrowedType(type, predicate.type, assumeTrue,
|
|
72183
|
+
return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false);
|
|
72104
72184
|
}
|
|
72105
72185
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
|
|
72106
72186
|
!(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
@@ -72108,7 +72188,7 @@ var ts;
|
|
|
72108
72188
|
}
|
|
72109
72189
|
var access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
72110
72190
|
if (access) {
|
|
72111
|
-
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue,
|
|
72191
|
+
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); });
|
|
72112
72192
|
}
|
|
72113
72193
|
}
|
|
72114
72194
|
}
|
|
@@ -72285,7 +72365,7 @@ var ts;
|
|
|
72285
72365
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
72286
72366
|
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
72287
72367
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
72288
|
-
: getContextualType(node));
|
|
72368
|
+
: getContextualType(node, /*contextFlags*/ undefined));
|
|
72289
72369
|
return contextualType && !isGenericType(contextualType);
|
|
72290
72370
|
}
|
|
72291
72371
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -72447,9 +72527,7 @@ var ts;
|
|
|
72447
72527
|
getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
|
|
72448
72528
|
return getTypeOfSymbol(symbol);
|
|
72449
72529
|
}
|
|
72450
|
-
|
|
72451
|
-
// for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that
|
|
72452
|
-
if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
|
|
72530
|
+
if (shouldMarkIdentifierAliasReferenced(node)) {
|
|
72453
72531
|
markAliasReferenced(symbol, node);
|
|
72454
72532
|
}
|
|
72455
72533
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
@@ -72583,6 +72661,25 @@ var ts;
|
|
|
72583
72661
|
}
|
|
72584
72662
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
72585
72663
|
}
|
|
72664
|
+
function shouldMarkIdentifierAliasReferenced(node) {
|
|
72665
|
+
var _a;
|
|
72666
|
+
var parent = node.parent;
|
|
72667
|
+
if (parent) {
|
|
72668
|
+
// A property access expression LHS? checkPropertyAccessExpression will handle that.
|
|
72669
|
+
if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
|
|
72670
|
+
return false;
|
|
72671
|
+
}
|
|
72672
|
+
// Next two check for an identifier inside a type only export.
|
|
72673
|
+
if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
|
|
72674
|
+
return false;
|
|
72675
|
+
}
|
|
72676
|
+
var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
72677
|
+
if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
|
|
72678
|
+
return false;
|
|
72679
|
+
}
|
|
72680
|
+
}
|
|
72681
|
+
return true;
|
|
72682
|
+
}
|
|
72586
72683
|
function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
|
|
72587
72684
|
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); });
|
|
72588
72685
|
}
|
|
@@ -73132,7 +73229,7 @@ var ts;
|
|
|
73132
73229
|
// We have an object literal method. Check if the containing object literal has a contextual type
|
|
73133
73230
|
// that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
|
|
73134
73231
|
// any directly enclosing object literals.
|
|
73135
|
-
var contextualType = getApparentTypeOfContextualType(containingLiteral);
|
|
73232
|
+
var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
|
|
73136
73233
|
var literal = containingLiteral;
|
|
73137
73234
|
var type = contextualType;
|
|
73138
73235
|
while (type) {
|
|
@@ -73144,7 +73241,7 @@ var ts;
|
|
|
73144
73241
|
break;
|
|
73145
73242
|
}
|
|
73146
73243
|
literal = literal.parent.parent;
|
|
73147
|
-
type = getApparentTypeOfContextualType(literal);
|
|
73244
|
+
type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
|
|
73148
73245
|
}
|
|
73149
73246
|
// There was no contextual ThisType<T> for the containing object literal, so the contextual type
|
|
73150
73247
|
// for 'this' is the non-null form of the contextual type for the containing object literal or
|
|
@@ -73201,7 +73298,7 @@ var ts;
|
|
|
73201
73298
|
tryGetTypeAtPosition(contextualSignature, index);
|
|
73202
73299
|
}
|
|
73203
73300
|
}
|
|
73204
|
-
function getContextualTypeForVariableLikeDeclaration(declaration) {
|
|
73301
|
+
function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
|
|
73205
73302
|
var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
|
|
73206
73303
|
if (typeNode) {
|
|
73207
73304
|
return getTypeFromTypeNode(typeNode);
|
|
@@ -73210,18 +73307,18 @@ var ts;
|
|
|
73210
73307
|
case 164 /* Parameter */:
|
|
73211
73308
|
return getContextuallyTypedParameterType(declaration);
|
|
73212
73309
|
case 203 /* BindingElement */:
|
|
73213
|
-
return getContextualTypeForBindingElement(declaration);
|
|
73310
|
+
return getContextualTypeForBindingElement(declaration, contextFlags);
|
|
73214
73311
|
case 167 /* PropertyDeclaration */:
|
|
73215
73312
|
if (ts.isStatic(declaration)) {
|
|
73216
|
-
return getContextualTypeForStaticPropertyDeclaration(declaration);
|
|
73313
|
+
return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
|
|
73217
73314
|
}
|
|
73218
73315
|
// By default, do nothing and return undefined - only the above cases have context implied by a parent
|
|
73219
73316
|
}
|
|
73220
73317
|
}
|
|
73221
|
-
function getContextualTypeForBindingElement(declaration) {
|
|
73318
|
+
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
73222
73319
|
var parent = declaration.parent.parent;
|
|
73223
73320
|
var name = declaration.propertyName || declaration.name;
|
|
73224
|
-
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
73321
|
+
var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
|
|
73225
73322
|
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
73226
73323
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
73227
73324
|
return undefined;
|
|
@@ -73237,8 +73334,8 @@ var ts;
|
|
|
73237
73334
|
return getTypeOfPropertyOfType(parentType, text);
|
|
73238
73335
|
}
|
|
73239
73336
|
}
|
|
73240
|
-
function getContextualTypeForStaticPropertyDeclaration(declaration) {
|
|
73241
|
-
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
|
|
73337
|
+
function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
|
|
73338
|
+
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
|
|
73242
73339
|
if (!parentType)
|
|
73243
73340
|
return undefined;
|
|
73244
73341
|
return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
|
|
@@ -73254,7 +73351,7 @@ var ts;
|
|
|
73254
73351
|
function getContextualTypeForInitializerExpression(node, contextFlags) {
|
|
73255
73352
|
var declaration = node.parent;
|
|
73256
73353
|
if (ts.hasInitializer(declaration) && node === declaration.initializer) {
|
|
73257
|
-
var result = getContextualTypeForVariableLikeDeclaration(declaration);
|
|
73354
|
+
var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
|
|
73258
73355
|
if (result) {
|
|
73259
73356
|
return result;
|
|
73260
73357
|
}
|
|
@@ -73264,10 +73361,10 @@ var ts;
|
|
|
73264
73361
|
}
|
|
73265
73362
|
return undefined;
|
|
73266
73363
|
}
|
|
73267
|
-
function getContextualTypeForReturnExpression(node) {
|
|
73364
|
+
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
73268
73365
|
var func = ts.getContainingFunction(node);
|
|
73269
73366
|
if (func) {
|
|
73270
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73367
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73271
73368
|
if (contextualReturnType) {
|
|
73272
73369
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73273
73370
|
if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
|
|
@@ -73297,11 +73394,11 @@ var ts;
|
|
|
73297
73394
|
}
|
|
73298
73395
|
return undefined;
|
|
73299
73396
|
}
|
|
73300
|
-
function getContextualTypeForYieldOperand(node) {
|
|
73397
|
+
function getContextualTypeForYieldOperand(node, contextFlags) {
|
|
73301
73398
|
var func = ts.getContainingFunction(node);
|
|
73302
73399
|
if (func) {
|
|
73303
73400
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73304
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73401
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73305
73402
|
if (contextualReturnType) {
|
|
73306
73403
|
return node.asteriskToken
|
|
73307
73404
|
? contextualReturnType
|
|
@@ -73325,14 +73422,14 @@ var ts;
|
|
|
73325
73422
|
}
|
|
73326
73423
|
function getContextualIterationType(kind, functionDecl) {
|
|
73327
73424
|
var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
|
|
73328
|
-
var contextualReturnType = getContextualReturnType(functionDecl);
|
|
73425
|
+
var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
|
|
73329
73426
|
if (contextualReturnType) {
|
|
73330
73427
|
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
|
|
73331
73428
|
|| undefined;
|
|
73332
73429
|
}
|
|
73333
73430
|
return undefined;
|
|
73334
73431
|
}
|
|
73335
|
-
function getContextualReturnType(functionDecl) {
|
|
73432
|
+
function getContextualReturnType(functionDecl, contextFlags) {
|
|
73336
73433
|
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
|
73337
73434
|
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
|
73338
73435
|
var returnType = getReturnTypeFromAnnotation(functionDecl);
|
|
@@ -73347,7 +73444,7 @@ var ts;
|
|
|
73347
73444
|
}
|
|
73348
73445
|
var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
|
|
73349
73446
|
if (iife) {
|
|
73350
|
-
return getContextualType(iife);
|
|
73447
|
+
return getContextualType(iife, contextFlags);
|
|
73351
73448
|
}
|
|
73352
73449
|
return undefined;
|
|
73353
73450
|
}
|
|
@@ -73600,7 +73697,7 @@ var ts;
|
|
|
73600
73697
|
}
|
|
73601
73698
|
function getContextualTypeForObjectLiteralElement(element, contextFlags) {
|
|
73602
73699
|
var objectLiteral = element.parent;
|
|
73603
|
-
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
|
|
73700
|
+
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
|
|
73604
73701
|
if (propertyAssignmentType) {
|
|
73605
73702
|
return propertyAssignmentType;
|
|
73606
73703
|
}
|
|
@@ -73795,9 +73892,9 @@ var ts;
|
|
|
73795
73892
|
return getContextualTypeForInitializerExpression(node, contextFlags);
|
|
73796
73893
|
case 214 /* ArrowFunction */:
|
|
73797
73894
|
case 247 /* ReturnStatement */:
|
|
73798
|
-
return getContextualTypeForReturnExpression(node);
|
|
73895
|
+
return getContextualTypeForReturnExpression(node, contextFlags);
|
|
73799
73896
|
case 224 /* YieldExpression */:
|
|
73800
|
-
return getContextualTypeForYieldOperand(parent);
|
|
73897
|
+
return getContextualTypeForYieldOperand(parent, contextFlags);
|
|
73801
73898
|
case 218 /* AwaitExpression */:
|
|
73802
73899
|
return getContextualTypeForAwaitOperand(parent, contextFlags);
|
|
73803
73900
|
case 208 /* CallExpression */:
|
|
@@ -73845,7 +73942,7 @@ var ts;
|
|
|
73845
73942
|
}
|
|
73846
73943
|
return undefined;
|
|
73847
73944
|
function tryFindWhenConstTypeReference(node) {
|
|
73848
|
-
return getContextualType(node);
|
|
73945
|
+
return getContextualType(node, contextFlags);
|
|
73849
73946
|
}
|
|
73850
73947
|
}
|
|
73851
73948
|
function getInferenceContext(node) {
|
|
@@ -74147,7 +74244,7 @@ var ts;
|
|
|
74147
74244
|
var elementCount = elements.length;
|
|
74148
74245
|
var elementTypes = [];
|
|
74149
74246
|
var elementFlags = [];
|
|
74150
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74247
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74151
74248
|
var inDestructuringPattern = ts.isAssignmentTarget(node);
|
|
74152
74249
|
var inConstContext = isConstContext(node);
|
|
74153
74250
|
var hasOmittedExpression = false;
|
|
@@ -74318,7 +74415,7 @@ var ts;
|
|
|
74318
74415
|
var propertiesTable = ts.createSymbolTable();
|
|
74319
74416
|
var propertiesArray = [];
|
|
74320
74417
|
var spread = emptyObjectType;
|
|
74321
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74418
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74322
74419
|
var contextualTypeHasPattern = contextualType && contextualType.pattern &&
|
|
74323
74420
|
(contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
|
|
74324
74421
|
var inConstContext = isConstContext(node);
|
|
@@ -74657,7 +74754,7 @@ var ts;
|
|
|
74657
74754
|
if (explicitlySpecifyChildrenAttribute) {
|
|
74658
74755
|
error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
|
|
74659
74756
|
}
|
|
74660
|
-
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
|
|
74757
|
+
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
|
|
74661
74758
|
var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
|
|
74662
74759
|
// 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
|
|
74663
74760
|
var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
|
|
@@ -77120,7 +77217,7 @@ var ts;
|
|
|
77120
77217
|
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
77121
77218
|
if (inferenceContext) {
|
|
77122
77219
|
var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
77123
|
-
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext
|
|
77220
|
+
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
77124
77221
|
// If the original signature has a generic rest type, instantiation may produce a
|
|
77125
77222
|
// signature with different arity and we need to perform another arity check.
|
|
77126
77223
|
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
|
|
@@ -78497,17 +78594,6 @@ var ts;
|
|
|
78497
78594
|
}
|
|
78498
78595
|
}
|
|
78499
78596
|
}
|
|
78500
|
-
var restType = getEffectiveRestType(context);
|
|
78501
|
-
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78502
|
-
// The contextual signature has a generic rest parameter. We first instantiate the contextual
|
|
78503
|
-
// signature (without fixing type parameters) and assign types to contextually typed parameters.
|
|
78504
|
-
var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
|
|
78505
|
-
assignContextualParameterTypes(signature, instantiatedContext);
|
|
78506
|
-
// We then infer from a tuple type representing the parameters that correspond to the contextual
|
|
78507
|
-
// rest parameter.
|
|
78508
|
-
var restPos = getParameterCount(context) - 1;
|
|
78509
|
-
inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
|
|
78510
|
-
}
|
|
78511
78597
|
}
|
|
78512
78598
|
function assignContextualParameterTypes(signature, context) {
|
|
78513
78599
|
if (context.typeParameters) {
|
|
@@ -78700,7 +78786,7 @@ var ts;
|
|
|
78700
78786
|
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
|
78701
78787
|
var contextualType = !contextualSignature ? undefined :
|
|
78702
78788
|
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
|
|
78703
|
-
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
|
|
78789
|
+
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
|
|
78704
78790
|
if (isGenerator) {
|
|
78705
78791
|
yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
|
|
78706
78792
|
returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
|
|
@@ -78771,7 +78857,7 @@ var ts;
|
|
|
78771
78857
|
nextType = iterationTypes && iterationTypes.nextType;
|
|
78772
78858
|
}
|
|
78773
78859
|
else {
|
|
78774
|
-
nextType = getContextualType(yieldExpression);
|
|
78860
|
+
nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
|
|
78775
78861
|
}
|
|
78776
78862
|
if (nextType)
|
|
78777
78863
|
ts.pushIfUnique(nextTypes, nextType);
|
|
@@ -78980,11 +79066,16 @@ var ts;
|
|
|
78980
79066
|
if (isContextSensitive(node)) {
|
|
78981
79067
|
if (contextualSignature) {
|
|
78982
79068
|
var inferenceContext = getInferenceContext(node);
|
|
79069
|
+
var instantiatedContextualSignature = void 0;
|
|
78983
79070
|
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
78984
79071
|
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
79072
|
+
var restType = getEffectiveRestType(contextualSignature);
|
|
79073
|
+
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
79074
|
+
instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
|
|
79075
|
+
}
|
|
78985
79076
|
}
|
|
78986
|
-
|
|
78987
|
-
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
|
|
79077
|
+
instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
|
|
79078
|
+
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
|
|
78988
79079
|
assignContextualParameterTypes(signature, instantiatedContextualSignature);
|
|
78989
79080
|
}
|
|
78990
79081
|
else {
|
|
@@ -80226,7 +80317,7 @@ var ts;
|
|
|
80226
80317
|
type = anyType;
|
|
80227
80318
|
addLazyDiagnostic(function () {
|
|
80228
80319
|
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
80229
|
-
var contextualType = getContextualType(node);
|
|
80320
|
+
var contextualType = getContextualType(node, /*contextFlags*/ undefined);
|
|
80230
80321
|
if (!contextualType || isTypeAny(contextualType)) {
|
|
80231
80322
|
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
80232
80323
|
}
|
|
@@ -80267,7 +80358,7 @@ var ts;
|
|
|
80267
80358
|
texts.push(span.literal.text);
|
|
80268
80359
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
80269
80360
|
}
|
|
80270
|
-
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80361
|
+
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80271
80362
|
}
|
|
80272
80363
|
function isTemplateLiteralContextualType(type) {
|
|
80273
80364
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
|
|
@@ -80295,7 +80386,7 @@ var ts;
|
|
|
80295
80386
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
80296
80387
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
80297
80388
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
80298
|
-
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
|
|
80389
|
+
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ?
|
|
80299
80390
|
getRegularTypeOfLiteralType(type) : type;
|
|
80300
80391
|
return result;
|
|
80301
80392
|
}
|
|
@@ -80410,7 +80501,7 @@ var ts;
|
|
|
80410
80501
|
var type = checkExpression(node, checkMode, forceTuple);
|
|
80411
80502
|
return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
|
|
80412
80503
|
isTypeAssertion(node) ? type :
|
|
80413
|
-
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
|
|
80504
|
+
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined));
|
|
80414
80505
|
}
|
|
80415
80506
|
function checkPropertyAssignment(node, checkMode) {
|
|
80416
80507
|
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
|
@@ -86392,7 +86483,9 @@ var ts;
|
|
|
86392
86483
|
error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
|
|
86393
86484
|
}
|
|
86394
86485
|
else {
|
|
86395
|
-
|
|
86486
|
+
if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
|
|
86487
|
+
markExportAsReferenced(node);
|
|
86488
|
+
}
|
|
86396
86489
|
var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
|
|
86397
86490
|
if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
|
|
86398
86491
|
checkExpressionCached(node.propertyName || node.name);
|
|
@@ -89753,9 +89846,6 @@ var ts;
|
|
|
89753
89846
|
else {
|
|
89754
89847
|
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89755
89848
|
}
|
|
89756
|
-
if (!isConstOrReadonly || isInvalidInitializer) {
|
|
89757
|
-
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89758
|
-
}
|
|
89759
89849
|
}
|
|
89760
89850
|
}
|
|
89761
89851
|
function checkGrammarVariableDeclaration(node) {
|
|
@@ -111540,7 +111630,7 @@ var ts;
|
|
|
111540
111630
|
return;
|
|
111541
111631
|
}
|
|
111542
111632
|
// Make sure not to write js file and source map file if any of them cannot be written
|
|
111543
|
-
if (
|
|
111633
|
+
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
|
|
111544
111634
|
emitSkipped = true;
|
|
111545
111635
|
return;
|
|
111546
111636
|
}
|
|
@@ -124802,7 +124892,6 @@ var ts;
|
|
|
124802
124892
|
var parsedConfigs; // Parsed commandline and watching cached for referenced projects
|
|
124803
124893
|
var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
|
|
124804
124894
|
var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
|
124805
|
-
var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
|
124806
124895
|
var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
|
124807
124896
|
var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
|
|
124808
124897
|
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
|
|
@@ -124955,12 +125044,12 @@ var ts;
|
|
|
124955
125044
|
var program = getCurrentBuilderProgram();
|
|
124956
125045
|
if (hasChangedCompilerOptions) {
|
|
124957
125046
|
newLine = updateNewLine();
|
|
124958
|
-
if (program &&
|
|
125047
|
+
if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
124959
125048
|
resolutionCache.clear();
|
|
124960
125049
|
}
|
|
124961
125050
|
}
|
|
124962
125051
|
// All resolutions are invalid if user provided resolutions
|
|
124963
|
-
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution
|
|
125052
|
+
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
|
|
124964
125053
|
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
124965
125054
|
if (hasChangedConfigFileParsingErrors) {
|
|
124966
125055
|
if (reportFileChangeDetectedOnCreateProgram) {
|
|
@@ -124976,7 +125065,6 @@ var ts;
|
|
|
124976
125065
|
}
|
|
124977
125066
|
createNewProgram(hasInvalidatedResolution);
|
|
124978
125067
|
}
|
|
124979
|
-
changesAffectResolution = false; // reset for next sync
|
|
124980
125068
|
reportFileChangeDetectedOnCreateProgram = false;
|
|
124981
125069
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
124982
125070
|
host.afterProgramCreate(builderProgram);
|
|
@@ -126357,7 +126445,7 @@ var ts;
|
|
|
126357
126445
|
}
|
|
126358
126446
|
function afterProgramDone(state, program, config) {
|
|
126359
126447
|
if (program) {
|
|
126360
|
-
if (
|
|
126448
|
+
if (state.write)
|
|
126361
126449
|
ts.listFiles(program, state.write);
|
|
126362
126450
|
if (state.host.afterProgramEmitAndDiagnostics) {
|
|
126363
126451
|
state.host.afterProgramEmitAndDiagnostics(program);
|
|
@@ -132934,6 +133022,26 @@ var ts;
|
|
|
132934
133022
|
(function (Completions) {
|
|
132935
133023
|
var StringCompletions;
|
|
132936
133024
|
(function (StringCompletions) {
|
|
133025
|
+
var _a;
|
|
133026
|
+
var kindPrecedence = (_a = {},
|
|
133027
|
+
_a["directory" /* directory */] = 0,
|
|
133028
|
+
_a["script" /* scriptElement */] = 1,
|
|
133029
|
+
_a["external module name" /* externalModuleName */] = 2,
|
|
133030
|
+
_a);
|
|
133031
|
+
function createNameAndKindSet() {
|
|
133032
|
+
var map = new ts.Map();
|
|
133033
|
+
function add(value) {
|
|
133034
|
+
var existing = map.get(value.name);
|
|
133035
|
+
if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) {
|
|
133036
|
+
map.set(value.name, value);
|
|
133037
|
+
}
|
|
133038
|
+
}
|
|
133039
|
+
return {
|
|
133040
|
+
add: add,
|
|
133041
|
+
has: map.has.bind(map),
|
|
133042
|
+
values: map.values.bind(map),
|
|
133043
|
+
};
|
|
133044
|
+
}
|
|
132937
133045
|
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
|
|
132938
133046
|
if (ts.isInReferenceComment(sourceFile, position)) {
|
|
132939
133047
|
var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
@@ -133215,11 +133323,12 @@ var ts;
|
|
|
133215
133323
|
}
|
|
133216
133324
|
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) {
|
|
133217
133325
|
var literalValue = ts.normalizeSlashes(node.text);
|
|
133326
|
+
var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
|
|
133218
133327
|
var scriptPath = sourceFile.path;
|
|
133219
133328
|
var scriptDirectory = ts.getDirectoryPath(scriptPath);
|
|
133220
133329
|
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
|
|
133221
133330
|
? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
|
|
133222
|
-
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
|
|
133331
|
+
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
|
|
133223
133332
|
function getIncludeExtensionOption() {
|
|
133224
133333
|
var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
|
|
133225
133334
|
return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
|
|
@@ -133235,7 +133344,7 @@ var ts;
|
|
|
133235
133344
|
return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
|
|
133236
133345
|
}
|
|
133237
133346
|
else {
|
|
133238
|
-
return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
|
|
133347
|
+
return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
|
|
133239
133348
|
}
|
|
133240
133349
|
}
|
|
133241
133350
|
function isEmitResolutionKindUsingNodeModules(compilerOptions) {
|
|
@@ -133271,7 +133380,7 @@ var ts;
|
|
|
133271
133380
|
var basePath = compilerOptions.project || host.getCurrentDirectory();
|
|
133272
133381
|
var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
|
133273
133382
|
var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
|
|
133274
|
-
return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); });
|
|
133383
|
+
return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); });
|
|
133275
133384
|
}
|
|
133276
133385
|
var IncludeExtensionsOption;
|
|
133277
133386
|
(function (IncludeExtensionsOption) {
|
|
@@ -133282,10 +133391,9 @@ var ts;
|
|
|
133282
133391
|
/**
|
|
133283
133392
|
* Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
|
|
133284
133393
|
*/
|
|
133285
|
-
function getCompletionEntriesForDirectoryFragment(fragment, scriptPath,
|
|
133286
|
-
var
|
|
133287
|
-
|
|
133288
|
-
if (result === void 0) { result = []; }
|
|
133394
|
+
function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) {
|
|
133395
|
+
var _a;
|
|
133396
|
+
if (result === void 0) { result = createNameAndKindSet(); }
|
|
133289
133397
|
if (fragment === undefined) {
|
|
133290
133398
|
fragment = "";
|
|
133291
133399
|
}
|
|
@@ -133309,11 +133417,11 @@ var ts;
|
|
|
133309
133417
|
var packageJson = ts.readJson(packageJsonPath, host);
|
|
133310
133418
|
var typesVersions = packageJson.typesVersions;
|
|
133311
133419
|
if (typeof typesVersions === "object") {
|
|
133312
|
-
var versionPaths = (
|
|
133420
|
+
var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
|
|
133313
133421
|
if (versionPaths) {
|
|
133314
133422
|
var packageDirectory = ts.getDirectoryPath(packageJsonPath);
|
|
133315
133423
|
var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
|
|
133316
|
-
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory,
|
|
133424
|
+
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
|
|
133317
133425
|
// A true result means one of the `versionPaths` was matched, which will block relative resolution
|
|
133318
133426
|
// to files and folders from here. All reachable paths given the pattern match are already added.
|
|
133319
133427
|
return result;
|
|
@@ -133325,39 +133433,17 @@ var ts;
|
|
|
133325
133433
|
if (!ts.tryDirectoryExists(host, baseDirectory))
|
|
133326
133434
|
return result;
|
|
133327
133435
|
// Enumerate the available files if possible
|
|
133328
|
-
var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
|
|
133436
|
+
var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
|
|
133329
133437
|
if (files) {
|
|
133330
|
-
/**
|
|
133331
|
-
* Multiple file entries might map to the same truncated name once we remove extensions
|
|
133332
|
-
* (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
|
|
133333
|
-
*
|
|
133334
|
-
* both foo.ts and foo.tsx become foo
|
|
133335
|
-
*/
|
|
133336
|
-
var foundFiles = new ts.Map(); // maps file to its extension
|
|
133337
133438
|
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
133338
133439
|
var filePath = files_1[_i];
|
|
133339
133440
|
filePath = ts.normalizePath(filePath);
|
|
133340
133441
|
if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
|
|
133341
133442
|
continue;
|
|
133342
133443
|
}
|
|
133343
|
-
var
|
|
133344
|
-
|
|
133345
|
-
if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
|
|
133346
|
-
foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
|
|
133347
|
-
foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
|
|
133348
|
-
}
|
|
133349
|
-
else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
|
|
133350
|
-
foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
|
|
133351
|
-
foundFiles.set(foundFileName, outputExtension);
|
|
133352
|
-
}
|
|
133353
|
-
else {
|
|
133354
|
-
foundFileName = ts.getBaseFileName(filePath);
|
|
133355
|
-
foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
|
|
133356
|
-
}
|
|
133444
|
+
var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension;
|
|
133445
|
+
result.add(nameAndKind(name, "script" /* scriptElement */, extension));
|
|
133357
133446
|
}
|
|
133358
|
-
foundFiles.forEach(function (ext, foundFile) {
|
|
133359
|
-
result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
|
|
133360
|
-
});
|
|
133361
133447
|
}
|
|
133362
133448
|
// If possible, get folder completion as well
|
|
133363
133449
|
var directories = ts.tryGetDirectories(host, baseDirectory);
|
|
@@ -133366,27 +133452,52 @@ var ts;
|
|
|
133366
133452
|
var directory = directories_1[_c];
|
|
133367
133453
|
var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
|
|
133368
133454
|
if (directoryName !== "@types") {
|
|
133369
|
-
result.
|
|
133455
|
+
result.add(directoryResult(directoryName));
|
|
133370
133456
|
}
|
|
133371
133457
|
}
|
|
133372
133458
|
}
|
|
133373
133459
|
return result;
|
|
133374
133460
|
}
|
|
133461
|
+
function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) {
|
|
133462
|
+
var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions);
|
|
133463
|
+
if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
|
|
133464
|
+
return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) };
|
|
133465
|
+
}
|
|
133466
|
+
else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
|
|
133467
|
+
return { name: ts.changeExtension(name, outputExtension), extension: outputExtension };
|
|
133468
|
+
}
|
|
133469
|
+
else {
|
|
133470
|
+
return { name: name, extension: ts.tryGetExtensionFromPath(name) };
|
|
133471
|
+
}
|
|
133472
|
+
}
|
|
133375
133473
|
/** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
|
|
133376
|
-
function addCompletionEntriesFromPaths(result, fragment, baseDirectory,
|
|
133377
|
-
var
|
|
133474
|
+
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
|
|
133475
|
+
var getPatternsForKey = function (key) { return paths[key]; };
|
|
133476
|
+
var comparePaths = function (a, b) {
|
|
133477
|
+
var patternA = ts.tryParsePattern(a);
|
|
133478
|
+
var patternB = ts.tryParsePattern(b);
|
|
133479
|
+
var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length;
|
|
133480
|
+
var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
|
|
133481
|
+
return ts.compareValues(lengthB, lengthA);
|
|
133482
|
+
};
|
|
133483
|
+
return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths);
|
|
133484
|
+
}
|
|
133485
|
+
/** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
|
|
133486
|
+
function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) {
|
|
133378
133487
|
var pathResults = [];
|
|
133379
|
-
var
|
|
133380
|
-
for (var
|
|
133381
|
-
|
|
133488
|
+
var matchedPath;
|
|
133489
|
+
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
133490
|
+
var key = keys_1[_i];
|
|
133491
|
+
if (key === ".")
|
|
133382
133492
|
continue;
|
|
133383
|
-
var
|
|
133493
|
+
var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
|
|
133494
|
+
var patterns = getPatternsForKey(key);
|
|
133384
133495
|
if (patterns) {
|
|
133385
|
-
var pathPattern = ts.tryParsePattern(
|
|
133496
|
+
var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash);
|
|
133386
133497
|
if (!pathPattern)
|
|
133387
133498
|
continue;
|
|
133388
133499
|
var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
|
|
133389
|
-
var isLongestMatch = isMatch && (
|
|
133500
|
+
var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* LessThan */);
|
|
133390
133501
|
if (isLongestMatch) {
|
|
133391
133502
|
// If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
|
|
133392
133503
|
// for `import {} from "some-package/|"` with a typesVersions:
|
|
@@ -133399,13 +133510,13 @@ var ts;
|
|
|
133399
133510
|
// added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
|
|
133400
133511
|
// ./dist/foo and ./foo, when only the latter will actually be resolvable.
|
|
133401
133512
|
// See pathCompletionsTypesVersionsWildcard6.ts.
|
|
133402
|
-
|
|
133513
|
+
matchedPath = key;
|
|
133403
133514
|
pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
|
|
133404
133515
|
}
|
|
133405
|
-
if (typeof pathPattern === "string" ||
|
|
133516
|
+
if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* GreaterThan */) {
|
|
133406
133517
|
pathResults.push({
|
|
133407
133518
|
matchedPattern: isMatch,
|
|
133408
|
-
results: getCompletionsForPathMapping(
|
|
133519
|
+
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
|
|
133409
133520
|
.map(function (_a) {
|
|
133410
133521
|
var name = _a.name, kind = _a.kind, extension = _a.extension;
|
|
133411
133522
|
return nameAndKind(name, kind, extension);
|
|
@@ -133414,10 +133525,8 @@ var ts;
|
|
|
133414
133525
|
}
|
|
133415
133526
|
}
|
|
133416
133527
|
}
|
|
133417
|
-
|
|
133418
|
-
|
|
133419
|
-
pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
|
|
133420
|
-
return matchedPathPrefixLength > -1;
|
|
133528
|
+
pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); });
|
|
133529
|
+
return matchedPath !== undefined;
|
|
133421
133530
|
}
|
|
133422
133531
|
/**
|
|
133423
133532
|
* Check all of the declared modules and those in node modules. Possible sources of modules:
|
|
@@ -133426,22 +133535,22 @@ var ts;
|
|
|
133426
133535
|
* Modules from node_modules (i.e. those listed in package.json)
|
|
133427
133536
|
* This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
|
|
133428
133537
|
*/
|
|
133429
|
-
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) {
|
|
133538
|
+
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) {
|
|
133430
133539
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths;
|
|
133431
|
-
var result =
|
|
133432
|
-
var extensionOptions = getExtensionOptions(compilerOptions);
|
|
133540
|
+
var result = createNameAndKindSet();
|
|
133541
|
+
var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
|
|
133433
133542
|
if (baseUrl) {
|
|
133434
133543
|
var projectDir = compilerOptions.project || host.getCurrentDirectory();
|
|
133435
133544
|
var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl));
|
|
133436
133545
|
getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
|
|
133437
133546
|
if (paths) {
|
|
133438
|
-
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions
|
|
133547
|
+
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
|
|
133439
133548
|
}
|
|
133440
133549
|
}
|
|
133441
133550
|
var fragmentDirectory = getFragmentDirectory(fragment);
|
|
133442
133551
|
for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
|
|
133443
133552
|
var ambientName = _a[_i];
|
|
133444
|
-
result.
|
|
133553
|
+
result.add(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133445
133554
|
}
|
|
133446
133555
|
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
133447
133556
|
if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
|
|
@@ -133449,15 +133558,13 @@ var ts;
|
|
|
133449
133558
|
// (But do if we didn't find anything, e.g. 'package.json' missing.)
|
|
133450
133559
|
var foundGlobal = false;
|
|
133451
133560
|
if (fragmentDirectory === undefined) {
|
|
133452
|
-
var _loop_3 = function (moduleName) {
|
|
133453
|
-
if (!result.some(function (entry) { return entry.name === moduleName; })) {
|
|
133454
|
-
foundGlobal = true;
|
|
133455
|
-
result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133456
|
-
}
|
|
133457
|
-
};
|
|
133458
133561
|
for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
|
|
133459
133562
|
var moduleName = _c[_b];
|
|
133460
|
-
|
|
133563
|
+
var moduleResult = nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined);
|
|
133564
|
+
if (!result.has(moduleResult.name)) {
|
|
133565
|
+
foundGlobal = true;
|
|
133566
|
+
result.add(moduleResult);
|
|
133567
|
+
}
|
|
133461
133568
|
}
|
|
133462
133569
|
}
|
|
133463
133570
|
if (!foundGlobal) {
|
|
@@ -133483,39 +133590,19 @@ var ts;
|
|
|
133483
133590
|
}
|
|
133484
133591
|
packagePath = ts.combinePaths(packagePath, subName);
|
|
133485
133592
|
}
|
|
133486
|
-
var
|
|
133593
|
+
var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
|
|
133594
|
+
var packageFile = ts.combinePaths(packageDirectory, "package.json");
|
|
133487
133595
|
if (ts.tryFileExists(host, packageFile)) {
|
|
133488
133596
|
var packageJson = ts.readJson(packageFile, host);
|
|
133489
|
-
var
|
|
133490
|
-
if (
|
|
133491
|
-
if (typeof
|
|
133597
|
+
var exports_1 = packageJson.exports;
|
|
133598
|
+
if (exports_1) {
|
|
133599
|
+
if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null
|
|
133492
133600
|
return; // null exports or entrypoint only, no sub-modules available
|
|
133493
133601
|
}
|
|
133494
|
-
var keys = ts.getOwnKeys(
|
|
133495
|
-
var
|
|
133496
|
-
var
|
|
133497
|
-
|
|
133498
|
-
return undefined;
|
|
133499
|
-
if (!ts.startsWith(k, "./"))
|
|
133500
|
-
return undefined;
|
|
133501
|
-
var subpath = k.substring(2);
|
|
133502
|
-
if (!ts.startsWith(subpath, fragmentSubpath_1))
|
|
133503
|
-
return undefined;
|
|
133504
|
-
// subpath is a valid export (barring conditions, which we don't currently check here)
|
|
133505
|
-
if (!ts.stringContains(subpath, "*")) {
|
|
133506
|
-
return subpath;
|
|
133507
|
-
}
|
|
133508
|
-
// pattern export - only return everything up to the `*`, so the user can autocomplete, then
|
|
133509
|
-
// keep filling in the pattern (we could speculatively return a list of options by hitting disk,
|
|
133510
|
-
// but conditions will make that somewhat awkward, as each condition may have a different set of possible
|
|
133511
|
-
// options for the `*`.
|
|
133512
|
-
return subpath.slice(0, subpath.indexOf("*"));
|
|
133513
|
-
});
|
|
133514
|
-
ts.forEach(processedKeys, function (k) {
|
|
133515
|
-
if (k) {
|
|
133516
|
-
result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133517
|
-
}
|
|
133518
|
-
});
|
|
133602
|
+
var keys = ts.getOwnKeys(exports_1);
|
|
133603
|
+
var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
|
133604
|
+
var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
133605
|
+
addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys);
|
|
133519
133606
|
return;
|
|
133520
133607
|
}
|
|
133521
133608
|
}
|
|
@@ -133525,31 +133612,44 @@ var ts;
|
|
|
133525
133612
|
ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
|
|
133526
133613
|
}
|
|
133527
133614
|
}
|
|
133528
|
-
return result;
|
|
133615
|
+
return ts.arrayFrom(result.values());
|
|
133616
|
+
}
|
|
133617
|
+
function getPatternFromFirstMatchingCondition(target, conditions) {
|
|
133618
|
+
if (typeof target === "string") {
|
|
133619
|
+
return target;
|
|
133620
|
+
}
|
|
133621
|
+
if (target && typeof target === "object" && !ts.isArray(target)) {
|
|
133622
|
+
for (var condition in target) {
|
|
133623
|
+
if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) {
|
|
133624
|
+
var pattern = target[condition];
|
|
133625
|
+
return getPatternFromFirstMatchingCondition(pattern, conditions);
|
|
133626
|
+
}
|
|
133627
|
+
}
|
|
133628
|
+
}
|
|
133529
133629
|
}
|
|
133530
133630
|
function getFragmentDirectory(fragment) {
|
|
133531
133631
|
return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined;
|
|
133532
133632
|
}
|
|
133533
|
-
function getCompletionsForPathMapping(path, patterns, fragment,
|
|
133633
|
+
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) {
|
|
133534
133634
|
if (!ts.endsWith(path, "*")) {
|
|
133535
133635
|
// For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
|
|
133536
|
-
return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray;
|
|
133636
|
+
return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* scriptElement */) : ts.emptyArray;
|
|
133537
133637
|
}
|
|
133538
133638
|
var pathPrefix = path.slice(0, path.length - 1);
|
|
133539
133639
|
var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
|
|
133540
133640
|
if (remainingFragment === undefined) {
|
|
133541
133641
|
var starIsFullPathComponent = path[path.length - 2] === "/";
|
|
133542
|
-
return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("",
|
|
133642
|
+
return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* directory */) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
|
|
133543
133643
|
var name = _a.name, rest = __rest(_a, ["name"]);
|
|
133544
133644
|
return (__assign({ name: pathPrefix + name }, rest));
|
|
133545
133645
|
}); });
|
|
133546
133646
|
}
|
|
133547
|
-
return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment,
|
|
133548
|
-
function justPathMappingName(name) {
|
|
133549
|
-
return ts.startsWith(name, fragment) ? [
|
|
133647
|
+
return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); });
|
|
133648
|
+
function justPathMappingName(name, kind) {
|
|
133649
|
+
return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray;
|
|
133550
133650
|
}
|
|
133551
133651
|
}
|
|
133552
|
-
function getModulesForPathsPattern(fragment,
|
|
133652
|
+
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) {
|
|
133553
133653
|
if (!host.readDirectory) {
|
|
133554
133654
|
return undefined;
|
|
133555
133655
|
}
|
|
@@ -133568,21 +133668,33 @@ var ts;
|
|
|
133568
133668
|
var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
|
|
133569
133669
|
var normalizedSuffix = ts.normalizePath(parsed.suffix);
|
|
133570
133670
|
// Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
|
|
133571
|
-
var baseDirectory = ts.normalizePath(ts.combinePaths(
|
|
133671
|
+
var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory));
|
|
133572
133672
|
var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
|
|
133573
|
-
// If we have a suffix, then we
|
|
133574
|
-
// that
|
|
133575
|
-
//
|
|
133576
|
-
|
|
133577
|
-
|
|
133578
|
-
|
|
133579
|
-
|
|
133580
|
-
|
|
133581
|
-
|
|
133582
|
-
var
|
|
133583
|
-
var
|
|
133584
|
-
|
|
133673
|
+
// If we have a suffix, then we read the directory all the way down to avoid returning completions for
|
|
133674
|
+
// directories that don't contain files that would match the suffix. A previous comment here was concerned
|
|
133675
|
+
// about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally,
|
|
133676
|
+
// but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not
|
|
133677
|
+
// a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?`
|
|
133678
|
+
// interpreted as "any character" can only return *too many* results as compared to the literal
|
|
133679
|
+
// interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always
|
|
133680
|
+
// done.
|
|
133681
|
+
var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*";
|
|
133682
|
+
var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) {
|
|
133683
|
+
var trimmedWithPattern = trimPrefixAndSuffix(match);
|
|
133684
|
+
if (trimmedWithPattern) {
|
|
133685
|
+
if (containsSlash(trimmedWithPattern)) {
|
|
133686
|
+
return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
|
|
133687
|
+
}
|
|
133688
|
+
var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension;
|
|
133689
|
+
return nameAndKind(name, "script" /* scriptElement */, extension);
|
|
133690
|
+
}
|
|
133585
133691
|
});
|
|
133692
|
+
// If we had a suffix, we already recursively searched for all possible files that could match
|
|
133693
|
+
// it and returned the directories leading to those files. Otherwise, assume any directory could
|
|
133694
|
+
// have something valid to import.
|
|
133695
|
+
var directories = normalizedSuffix
|
|
133696
|
+
? ts.emptyArray
|
|
133697
|
+
: ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); });
|
|
133586
133698
|
return __spreadArray(__spreadArray([], matches, true), directories, true);
|
|
133587
133699
|
function trimPrefixAndSuffix(path) {
|
|
133588
133700
|
var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix);
|
|
@@ -133625,10 +133737,10 @@ var ts;
|
|
|
133625
133737
|
var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
|
|
133626
133738
|
: kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
|
|
133627
133739
|
: ts.Debug.fail();
|
|
133628
|
-
return addReplacementSpans(toComplete, range.pos + prefix.length, names);
|
|
133740
|
+
return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values()));
|
|
133629
133741
|
}
|
|
133630
133742
|
function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) {
|
|
133631
|
-
if (result === void 0) { result =
|
|
133743
|
+
if (result === void 0) { result = createNameAndKindSet(); }
|
|
133632
133744
|
// Check for typings specified in compiler options
|
|
133633
133745
|
var seen = new ts.Map();
|
|
133634
133746
|
var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray;
|
|
@@ -133653,7 +133765,7 @@ var ts;
|
|
|
133653
133765
|
continue;
|
|
133654
133766
|
if (fragmentDirectory === undefined) {
|
|
133655
133767
|
if (!seen.has(packageName)) {
|
|
133656
|
-
result.
|
|
133768
|
+
result.add(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133657
133769
|
seen.set(packageName, true);
|
|
133658
133770
|
}
|
|
133659
133771
|
}
|
|
@@ -134545,7 +134657,7 @@ var ts;
|
|
|
134545
134657
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
134546
134658
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
134547
134659
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
134548
|
-
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ :
|
|
134660
|
+
var builderFlags = 33554432 /* OmitThisParameter */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
134549
134661
|
switch (declaration.kind) {
|
|
134550
134662
|
case 166 /* PropertySignature */:
|
|
134551
134663
|
case 167 /* PropertyDeclaration */:
|
|
@@ -139254,7 +139366,7 @@ var ts;
|
|
|
139254
139366
|
result = references;
|
|
139255
139367
|
continue;
|
|
139256
139368
|
}
|
|
139257
|
-
var
|
|
139369
|
+
var _loop_3 = function (entry) {
|
|
139258
139370
|
if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
|
|
139259
139371
|
result.push(entry);
|
|
139260
139372
|
return "continue";
|
|
@@ -139286,7 +139398,7 @@ var ts;
|
|
|
139286
139398
|
};
|
|
139287
139399
|
for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
|
|
139288
139400
|
var entry = references_2[_b];
|
|
139289
|
-
|
|
139401
|
+
_loop_3(entry);
|
|
139290
139402
|
}
|
|
139291
139403
|
}
|
|
139292
139404
|
return result;
|
|
@@ -140867,8 +140979,8 @@ var ts;
|
|
|
140867
140979
|
var declarations;
|
|
140868
140980
|
if (symbol && symbol.declarations) {
|
|
140869
140981
|
var indices = ts.indicesOf(symbol.declarations);
|
|
140870
|
-
var
|
|
140871
|
-
indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(
|
|
140982
|
+
var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
|
|
140983
|
+
indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; });
|
|
140872
140984
|
var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; });
|
|
140873
140985
|
var lastDecl = void 0;
|
|
140874
140986
|
for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) {
|
|
@@ -141316,7 +141428,7 @@ var ts;
|
|
|
141316
141428
|
}
|
|
141317
141429
|
function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
|
|
141318
141430
|
var allFiles = program.getSourceFiles();
|
|
141319
|
-
var
|
|
141431
|
+
var _loop_4 = function (sourceFile) {
|
|
141320
141432
|
var newFromOld = oldToNew(sourceFile.fileName);
|
|
141321
141433
|
var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
|
|
141322
141434
|
var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
|
|
@@ -141348,7 +141460,7 @@ var ts;
|
|
|
141348
141460
|
};
|
|
141349
141461
|
for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
|
|
141350
141462
|
var sourceFile = allFiles_1[_i];
|
|
141351
|
-
|
|
141463
|
+
_loop_4(sourceFile);
|
|
141352
141464
|
}
|
|
141353
141465
|
}
|
|
141354
141466
|
function combineNormal(pathA, pathB) {
|
|
@@ -142372,7 +142484,7 @@ var ts;
|
|
|
142372
142484
|
if (!patternMatcher)
|
|
142373
142485
|
return ts.emptyArray;
|
|
142374
142486
|
var rawItems = [];
|
|
142375
|
-
var
|
|
142487
|
+
var _loop_5 = function (sourceFile) {
|
|
142376
142488
|
cancellationToken.throwIfCancellationRequested();
|
|
142377
142489
|
if (excludeDtsFiles && sourceFile.isDeclarationFile) {
|
|
142378
142490
|
return "continue";
|
|
@@ -142384,7 +142496,7 @@ var ts;
|
|
|
142384
142496
|
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
|
|
142385
142497
|
for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
|
|
142386
142498
|
var sourceFile = sourceFiles_4[_i];
|
|
142387
|
-
|
|
142499
|
+
_loop_5(sourceFile);
|
|
142388
142500
|
}
|
|
142389
142501
|
rawItems.sort(compareNavigateToItems);
|
|
142390
142502
|
return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
|
|
@@ -144447,13 +144559,13 @@ var ts;
|
|
|
144447
144559
|
// Assumes 'value' is already lowercase.
|
|
144448
144560
|
function indexOfIgnoringCase(str, value) {
|
|
144449
144561
|
var n = str.length - value.length;
|
|
144450
|
-
var
|
|
144562
|
+
var _loop_6 = function (start) {
|
|
144451
144563
|
if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
|
|
144452
144564
|
return { value: start };
|
|
144453
144565
|
}
|
|
144454
144566
|
};
|
|
144455
144567
|
for (var start = 0; start <= n; start++) {
|
|
144456
|
-
var state_3 =
|
|
144568
|
+
var state_3 = _loop_6(start);
|
|
144457
144569
|
if (typeof state_3 === "object")
|
|
144458
144570
|
return state_3.value;
|
|
144459
144571
|
}
|
|
@@ -145920,7 +146032,7 @@ var ts;
|
|
|
145920
146032
|
return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
|
|
145921
146033
|
}
|
|
145922
146034
|
function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
|
|
145923
|
-
var
|
|
146035
|
+
var _loop_7 = function (n) {
|
|
145924
146036
|
// If the node is not a subspan of its parent, this is a big problem.
|
|
145925
146037
|
// There have been crashes that might be caused by this violation.
|
|
145926
146038
|
ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
|
|
@@ -145930,7 +146042,7 @@ var ts;
|
|
|
145930
146042
|
}
|
|
145931
146043
|
};
|
|
145932
146044
|
for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
|
|
145933
|
-
var state_4 =
|
|
146045
|
+
var state_4 = _loop_7(n);
|
|
145934
146046
|
if (typeof state_4 === "object")
|
|
145935
146047
|
return state_4.value;
|
|
145936
146048
|
}
|
|
@@ -147543,7 +147655,7 @@ var ts;
|
|
|
147543
147655
|
commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
|
|
147544
147656
|
ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
|
|
147545
147657
|
options = ts.cloneCompilerOptions(options);
|
|
147546
|
-
var
|
|
147658
|
+
var _loop_8 = function (opt) {
|
|
147547
147659
|
if (!ts.hasProperty(options, opt.name)) {
|
|
147548
147660
|
return "continue";
|
|
147549
147661
|
}
|
|
@@ -147562,7 +147674,7 @@ var ts;
|
|
|
147562
147674
|
};
|
|
147563
147675
|
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
|
|
147564
147676
|
var opt = commandLineOptionsStringToEnum_1[_i];
|
|
147565
|
-
|
|
147677
|
+
_loop_8(opt);
|
|
147566
147678
|
}
|
|
147567
147679
|
return options;
|
|
147568
147680
|
}
|
|
@@ -151327,7 +151439,7 @@ var ts;
|
|
|
151327
151439
|
ChangeTracker.prototype.finishDeleteDeclarations = function () {
|
|
151328
151440
|
var _this = this;
|
|
151329
151441
|
var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
|
|
151330
|
-
var
|
|
151442
|
+
var _loop_9 = function (sourceFile, node) {
|
|
151331
151443
|
if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
|
|
151332
151444
|
if (ts.isArray(node)) {
|
|
151333
151445
|
this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
|
|
@@ -151340,7 +151452,7 @@ var ts;
|
|
|
151340
151452
|
var this_1 = this;
|
|
151341
151453
|
for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
|
|
151342
151454
|
var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
|
|
151343
|
-
|
|
151455
|
+
_loop_9(sourceFile, node);
|
|
151344
151456
|
}
|
|
151345
151457
|
deletedNodesInLists.forEach(function (node) {
|
|
151346
151458
|
var sourceFile = node.getSourceFile();
|
|
@@ -151428,14 +151540,14 @@ var ts;
|
|
|
151428
151540
|
// order changes by start position
|
|
151429
151541
|
// If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa.
|
|
151430
151542
|
var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
|
|
151431
|
-
var
|
|
151543
|
+
var _loop_10 = function (i) {
|
|
151432
151544
|
ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
|
|
151433
151545
|
return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
|
|
151434
151546
|
});
|
|
151435
151547
|
};
|
|
151436
151548
|
// verify that change intervals do not overlap, except possibly at end points.
|
|
151437
151549
|
for (var i = 0; i < normalized.length - 1; i++) {
|
|
151438
|
-
|
|
151550
|
+
_loop_10(i);
|
|
151439
151551
|
}
|
|
151440
151552
|
var textChanges = ts.mapDefined(normalized, function (c) {
|
|
151441
151553
|
var span = ts.createTextSpanFromRange(c.range);
|
|
@@ -152343,7 +152455,7 @@ var ts;
|
|
|
152343
152455
|
}
|
|
152344
152456
|
var isCompleteFix = identifiers.isCompleteFix;
|
|
152345
152457
|
var initializers;
|
|
152346
|
-
var
|
|
152458
|
+
var _loop_11 = function (identifier) {
|
|
152347
152459
|
var symbol = checker.getSymbolAtLocation(identifier);
|
|
152348
152460
|
if (!symbol) {
|
|
152349
152461
|
return "continue";
|
|
@@ -152376,7 +152488,7 @@ var ts;
|
|
|
152376
152488
|
};
|
|
152377
152489
|
for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
|
|
152378
152490
|
var identifier = _a[_i];
|
|
152379
|
-
|
|
152491
|
+
_loop_11(identifier);
|
|
152380
152492
|
}
|
|
152381
152493
|
return initializers && {
|
|
152382
152494
|
initializers: initializers,
|
|
@@ -153261,7 +153373,7 @@ var ts;
|
|
|
153261
153373
|
}
|
|
153262
153374
|
var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
|
|
153263
153375
|
changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " });
|
|
153264
|
-
var
|
|
153376
|
+
var _loop_12 = function (returnStatement) {
|
|
153265
153377
|
ts.forEachChild(returnStatement, function visit(node) {
|
|
153266
153378
|
if (ts.isCallExpression(node)) {
|
|
153267
153379
|
var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
|
|
@@ -153283,7 +153395,7 @@ var ts;
|
|
|
153283
153395
|
};
|
|
153284
153396
|
for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
|
|
153285
153397
|
var returnStatement = returnStatements_1[_i];
|
|
153286
|
-
var state_5 =
|
|
153398
|
+
var state_5 = _loop_12(returnStatement);
|
|
153287
153399
|
if (typeof state_5 === "object")
|
|
153288
153400
|
return state_5.value;
|
|
153289
153401
|
}
|
|
@@ -156618,7 +156730,7 @@ var ts;
|
|
|
156618
156730
|
});
|
|
156619
156731
|
typeDeclToMembers.forEach(function (infos, declaration) {
|
|
156620
156732
|
var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
|
|
156621
|
-
var
|
|
156733
|
+
var _loop_13 = function (info) {
|
|
156622
156734
|
// If some superclass added this property, don't add it again.
|
|
156623
156735
|
if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
|
|
156624
156736
|
var superInfos = typeDeclToMembers.get(superClassOrInterface);
|
|
@@ -156645,7 +156757,7 @@ var ts;
|
|
|
156645
156757
|
};
|
|
156646
156758
|
for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
|
|
156647
156759
|
var info = infos_1[_i];
|
|
156648
|
-
|
|
156760
|
+
_loop_13(info);
|
|
156649
156761
|
}
|
|
156650
156762
|
});
|
|
156651
156763
|
}));
|
|
@@ -159419,7 +159531,7 @@ var ts;
|
|
|
159419
159531
|
function getSignatureFromCalls(calls) {
|
|
159420
159532
|
var parameters = [];
|
|
159421
159533
|
var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
|
|
159422
|
-
var
|
|
159534
|
+
var _loop_14 = function (i) {
|
|
159423
159535
|
var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
|
|
159424
159536
|
symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
|
|
159425
159537
|
if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
|
|
@@ -159428,7 +159540,7 @@ var ts;
|
|
|
159428
159540
|
parameters.push(symbol);
|
|
159429
159541
|
};
|
|
159430
159542
|
for (var i = 0; i < length; i++) {
|
|
159431
|
-
|
|
159543
|
+
_loop_14(i);
|
|
159432
159544
|
}
|
|
159433
159545
|
var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
|
|
159434
159546
|
return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
|
|
@@ -161404,7 +161516,7 @@ var ts;
|
|
|
161404
161516
|
// Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
|
|
161405
161517
|
// More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`.
|
|
161406
161518
|
var neededNamedImports = new ts.Set();
|
|
161407
|
-
var
|
|
161519
|
+
var _loop_15 = function (element) {
|
|
161408
161520
|
var propertyName = (element.propertyName || element.name).text;
|
|
161409
161521
|
ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
|
|
161410
161522
|
var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
|
|
@@ -161421,7 +161533,7 @@ var ts;
|
|
|
161421
161533
|
};
|
|
161422
161534
|
for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
|
|
161423
161535
|
var element = _a[_i];
|
|
161424
|
-
|
|
161536
|
+
_loop_15(element);
|
|
161425
161537
|
}
|
|
161426
161538
|
changes.replaceNode(sourceFile, toConvert, shouldUseDefault
|
|
161427
161539
|
? ts.factory.createIdentifier(namespaceImportName)
|
|
@@ -163312,7 +163424,7 @@ var ts;
|
|
|
163312
163424
|
: ts.getEnclosingBlockScopeContainer(scopes[0]);
|
|
163313
163425
|
ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
|
|
163314
163426
|
}
|
|
163315
|
-
var
|
|
163427
|
+
var _loop_16 = function (i) {
|
|
163316
163428
|
var scopeUsages = usagesPerScope[i];
|
|
163317
163429
|
// Special case: in the innermost scope, all usages are available.
|
|
163318
163430
|
// (The computed value reflects the value at the top-level of the scope, but the
|
|
@@ -163355,7 +163467,7 @@ var ts;
|
|
|
163355
163467
|
}
|
|
163356
163468
|
};
|
|
163357
163469
|
for (var i = 0; i < scopes.length; i++) {
|
|
163358
|
-
|
|
163470
|
+
_loop_16(i);
|
|
163359
163471
|
}
|
|
163360
163472
|
return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
|
|
163361
163473
|
function isInGenericContext(node) {
|
|
@@ -164056,10 +164168,10 @@ var ts;
|
|
|
164056
164168
|
}
|
|
164057
164169
|
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
|
|
164058
164170
|
var checker = program.getTypeChecker();
|
|
164059
|
-
var
|
|
164171
|
+
var _loop_17 = function (sourceFile) {
|
|
164060
164172
|
if (sourceFile === oldFile)
|
|
164061
164173
|
return "continue";
|
|
164062
|
-
var
|
|
164174
|
+
var _loop_18 = function (statement) {
|
|
164063
164175
|
forEachImportInStatement(statement, function (importNode) {
|
|
164064
164176
|
if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
|
|
164065
164177
|
return;
|
|
@@ -164081,12 +164193,12 @@ var ts;
|
|
|
164081
164193
|
};
|
|
164082
164194
|
for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
|
|
164083
164195
|
var statement = _c[_b];
|
|
164084
|
-
|
|
164196
|
+
_loop_18(statement);
|
|
164085
164197
|
}
|
|
164086
164198
|
};
|
|
164087
164199
|
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
|
|
164088
164200
|
var sourceFile = _a[_i];
|
|
164089
|
-
|
|
164201
|
+
_loop_17(sourceFile);
|
|
164090
164202
|
}
|
|
164091
164203
|
}
|
|
164092
164204
|
function getNamespaceLikeImport(node) {
|
|
@@ -165449,7 +165561,7 @@ var ts;
|
|
|
165449
165561
|
var templateSpans = [];
|
|
165450
165562
|
var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
|
|
165451
165563
|
copyCommentFromStringLiterals(headIndexes, templateHead);
|
|
165452
|
-
var
|
|
165564
|
+
var _loop_19 = function (i) {
|
|
165453
165565
|
var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
|
|
165454
165566
|
copyOperatorComments(i, currentNode);
|
|
165455
165567
|
var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
|
|
@@ -165478,7 +165590,7 @@ var ts;
|
|
|
165478
165590
|
};
|
|
165479
165591
|
var out_i_1;
|
|
165480
165592
|
for (var i = begin; i < nodes.length; i++) {
|
|
165481
|
-
|
|
165593
|
+
_loop_19(i);
|
|
165482
165594
|
i = out_i_1;
|
|
165483
165595
|
}
|
|
165484
165596
|
return ts.factory.createTemplateExpression(templateHead, templateSpans);
|
|
@@ -166090,20 +166202,25 @@ var ts;
|
|
|
166090
166202
|
return this.documentationComment;
|
|
166091
166203
|
};
|
|
166092
166204
|
SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) {
|
|
166093
|
-
|
|
166094
|
-
|
|
166205
|
+
if (context) {
|
|
166206
|
+
if (ts.isGetAccessor(context)) {
|
|
166095
166207
|
if (!this.contextualGetAccessorDocumentationComment) {
|
|
166096
166208
|
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166097
166209
|
}
|
|
166098
|
-
|
|
166099
|
-
|
|
166210
|
+
if (ts.length(this.contextualGetAccessorDocumentationComment)) {
|
|
166211
|
+
return this.contextualGetAccessorDocumentationComment;
|
|
166212
|
+
}
|
|
166213
|
+
}
|
|
166214
|
+
if (ts.isSetAccessor(context)) {
|
|
166100
166215
|
if (!this.contextualSetAccessorDocumentationComment) {
|
|
166101
166216
|
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166102
166217
|
}
|
|
166103
|
-
|
|
166104
|
-
|
|
166105
|
-
|
|
166218
|
+
if (ts.length(this.contextualSetAccessorDocumentationComment)) {
|
|
166219
|
+
return this.contextualSetAccessorDocumentationComment;
|
|
166220
|
+
}
|
|
166221
|
+
}
|
|
166106
166222
|
}
|
|
166223
|
+
return this.getDocumentationComment(checker);
|
|
166107
166224
|
};
|
|
166108
166225
|
SymbolObject.prototype.getJsDocTags = function (checker) {
|
|
166109
166226
|
if (this.tags === undefined) {
|
|
@@ -166112,20 +166229,25 @@ var ts;
|
|
|
166112
166229
|
return this.tags;
|
|
166113
166230
|
};
|
|
166114
166231
|
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
|
|
166115
|
-
|
|
166116
|
-
|
|
166232
|
+
if (context) {
|
|
166233
|
+
if (ts.isGetAccessor(context)) {
|
|
166117
166234
|
if (!this.contextualGetAccessorTags) {
|
|
166118
166235
|
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166119
166236
|
}
|
|
166120
|
-
|
|
166121
|
-
|
|
166237
|
+
if (ts.length(this.contextualGetAccessorTags)) {
|
|
166238
|
+
return this.contextualGetAccessorTags;
|
|
166239
|
+
}
|
|
166240
|
+
}
|
|
166241
|
+
if (ts.isSetAccessor(context)) {
|
|
166122
166242
|
if (!this.contextualSetAccessorTags) {
|
|
166123
166243
|
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166124
166244
|
}
|
|
166125
|
-
|
|
166126
|
-
|
|
166127
|
-
|
|
166245
|
+
if (ts.length(this.contextualSetAccessorTags)) {
|
|
166246
|
+
return this.contextualSetAccessorTags;
|
|
166247
|
+
}
|
|
166248
|
+
}
|
|
166128
166249
|
}
|
|
166250
|
+
return this.getJsDocTags(checker);
|
|
166129
166251
|
};
|
|
166130
166252
|
return SymbolObject;
|
|
166131
166253
|
}());
|
|
@@ -166314,7 +166436,7 @@ var ts;
|
|
|
166314
166436
|
var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
|
|
166315
166437
|
if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
166316
166438
|
var seenSymbols_1 = new ts.Set();
|
|
166317
|
-
var
|
|
166439
|
+
var _loop_20 = function (declaration) {
|
|
166318
166440
|
var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
166319
166441
|
var _a;
|
|
166320
166442
|
if (!seenSymbols_1.has(symbol)) {
|
|
@@ -166331,7 +166453,7 @@ var ts;
|
|
|
166331
166453
|
};
|
|
166332
166454
|
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
166333
166455
|
var declaration = declarations_7[_i];
|
|
166334
|
-
|
|
166456
|
+
_loop_20(declaration);
|
|
166335
166457
|
}
|
|
166336
166458
|
}
|
|
166337
166459
|
return tags;
|
|
@@ -166342,7 +166464,7 @@ var ts;
|
|
|
166342
166464
|
var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
|
|
166343
166465
|
if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
166344
166466
|
var seenSymbols_2 = new ts.Set();
|
|
166345
|
-
var
|
|
166467
|
+
var _loop_21 = function (declaration) {
|
|
166346
166468
|
var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
166347
166469
|
if (!seenSymbols_2.has(symbol)) {
|
|
166348
166470
|
seenSymbols_2.add(symbol);
|
|
@@ -166358,7 +166480,7 @@ var ts;
|
|
|
166358
166480
|
};
|
|
166359
166481
|
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
166360
166482
|
var declaration = declarations_8[_i];
|
|
166361
|
-
|
|
166483
|
+
_loop_21(declaration);
|
|
166362
166484
|
}
|
|
166363
166485
|
}
|
|
166364
166486
|
return doc;
|
|
@@ -166876,7 +166998,10 @@ var ts;
|
|
|
166876
166998
|
program = undefined; // TODO: GH#18217
|
|
166877
166999
|
lastTypesRootVersion = typeRootsVersion;
|
|
166878
167000
|
}
|
|
166879
|
-
|
|
167001
|
+
// This array is retained by the program and will be used to determine if the program is up to date,
|
|
167002
|
+
// so we need to make a copy in case the host mutates the underlying array - otherwise it would look
|
|
167003
|
+
// like every program always has the host's current list of root files.
|
|
167004
|
+
var rootFileNames = host.getScriptFileNames().slice();
|
|
166880
167005
|
// Get a fresh cache of the host information
|
|
166881
167006
|
var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
|
|
166882
167007
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|