typescript 4.8.0-dev.20220706 → 4.8.0-dev.20220709
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +158 -111
- package/lib/tsserver.js +379 -291
- package/lib/tsserverlibrary.d.ts +6 -0
- package/lib/tsserverlibrary.js +379 -291
- package/lib/typescript.d.ts +6 -0
- package/lib/typescript.js +379 -291
- package/lib/typescriptServices.d.ts +6 -0
- package/lib/typescriptServices.js +379 -291
- package/lib/typingsInstaller.js +172 -121
- 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.20220709";
|
|
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() {
|
|
@@ -9227,6 +9243,7 @@ var ts;
|
|
|
9227
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'."),
|
|
9228
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?"),
|
|
9229
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."),
|
|
9230
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}'."),
|
|
9231
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}'."),
|
|
9232
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}'."),
|
|
@@ -19725,7 +19742,8 @@ var ts;
|
|
|
19725
19742
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
|
|
19726
19743
|
if (isWrite === void 0) { isWrite = false; }
|
|
19727
19744
|
if (s.valueDeclaration) {
|
|
19728
|
-
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;
|
|
19729
19747
|
var flags = ts.getCombinedModifierFlags(declaration);
|
|
19730
19748
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
|
|
19731
19749
|
}
|
|
@@ -20400,7 +20418,7 @@ var ts;
|
|
|
20400
20418
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20401
20419
|
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20402
20420
|
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20403
|
-
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;
|
|
20404
20422
|
}
|
|
20405
20423
|
function getSetExternalModuleIndicator(options) {
|
|
20406
20424
|
// TODO: Should this callback be cached?
|
|
@@ -20423,10 +20441,7 @@ var ts;
|
|
|
20423
20441
|
if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
|
|
20424
20442
|
checks.push(isFileModuleFromUsingJSXTag);
|
|
20425
20443
|
}
|
|
20426
|
-
|
|
20427
|
-
if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
20428
|
-
checks.push(isFileForcedToBeModuleByFormat);
|
|
20429
|
-
}
|
|
20444
|
+
checks.push(isFileForcedToBeModuleByFormat);
|
|
20430
20445
|
var combined_1 = ts.or.apply(void 0, checks);
|
|
20431
20446
|
var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
|
|
20432
20447
|
return callback;
|
|
@@ -34146,10 +34161,10 @@ var ts;
|
|
|
34146
34161
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
34147
34162
|
var modifiers = parseModifiers();
|
|
34148
34163
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
34149
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
|
|
34164
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
|
|
34150
34165
|
}
|
|
34151
34166
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
34152
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
|
|
34167
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
|
|
34153
34168
|
}
|
|
34154
34169
|
if (isIndexSignature()) {
|
|
34155
34170
|
return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
|
|
@@ -36195,10 +36210,10 @@ var ts;
|
|
|
36195
36210
|
var decorators = parseDecorators();
|
|
36196
36211
|
var modifiers = parseModifiers();
|
|
36197
36212
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
36198
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
36213
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
36199
36214
|
}
|
|
36200
36215
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
36201
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
36216
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
36202
36217
|
}
|
|
36203
36218
|
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
|
36204
36219
|
var tokenIsIdentifier = isIdentifier();
|
|
@@ -36890,9 +36905,15 @@ var ts;
|
|
|
36890
36905
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
|
|
36891
36906
|
}
|
|
36892
36907
|
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
|
|
36893
|
-
if (token() !== 18 /* OpenBraceToken */
|
|
36894
|
-
|
|
36895
|
-
|
|
36908
|
+
if (token() !== 18 /* OpenBraceToken */) {
|
|
36909
|
+
if (flags & 4 /* Type */) {
|
|
36910
|
+
parseTypeMemberSemicolon();
|
|
36911
|
+
return;
|
|
36912
|
+
}
|
|
36913
|
+
if (canParseSemicolon()) {
|
|
36914
|
+
parseSemicolon();
|
|
36915
|
+
return;
|
|
36916
|
+
}
|
|
36896
36917
|
}
|
|
36897
36918
|
return parseFunctionBlock(flags, diagnosticMessage);
|
|
36898
36919
|
}
|
|
@@ -37096,12 +37117,12 @@ var ts;
|
|
|
37096
37117
|
}
|
|
37097
37118
|
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
|
|
37098
37119
|
}
|
|
37099
|
-
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
|
|
37120
|
+
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
|
|
37100
37121
|
var name = parsePropertyName();
|
|
37101
37122
|
var typeParameters = parseTypeParameters();
|
|
37102
37123
|
var parameters = parseParameters(0 /* None */);
|
|
37103
37124
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
37104
|
-
var body = parseFunctionBlockOrSemicolon(
|
|
37125
|
+
var body = parseFunctionBlockOrSemicolon(flags);
|
|
37105
37126
|
var node = kind === 172 /* GetAccessor */
|
|
37106
37127
|
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
|
|
37107
37128
|
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
|
|
@@ -37288,10 +37309,10 @@ var ts;
|
|
|
37288
37309
|
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
37289
37310
|
}
|
|
37290
37311
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
37291
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
37312
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
37292
37313
|
}
|
|
37293
37314
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
37294
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
37315
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
37295
37316
|
}
|
|
37296
37317
|
if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
|
|
37297
37318
|
var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -44602,6 +44623,7 @@ var ts;
|
|
|
44602
44623
|
return toSearchResult(/*value*/ undefined);
|
|
44603
44624
|
}
|
|
44604
44625
|
/**
|
|
44626
|
+
* @internal
|
|
44605
44627
|
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
|
44606
44628
|
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
|
44607
44629
|
*/
|
|
@@ -44624,6 +44646,7 @@ var ts;
|
|
|
44624
44646
|
return 1;
|
|
44625
44647
|
return 0;
|
|
44626
44648
|
}
|
|
44649
|
+
ts.comparePatternKeys = comparePatternKeys;
|
|
44627
44650
|
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
44628
44651
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44629
44652
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
@@ -48695,7 +48718,7 @@ var ts;
|
|
|
48695
48718
|
// Masks
|
|
48696
48719
|
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
48697
48720
|
TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
|
|
48698
|
-
})(TypeFacts || (TypeFacts = {}));
|
|
48721
|
+
})(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
|
|
48699
48722
|
var typeofNEFacts = new ts.Map(ts.getEntries({
|
|
48700
48723
|
string: 256 /* TypeofNEString */,
|
|
48701
48724
|
number: 512 /* TypeofNENumber */,
|
|
@@ -48730,7 +48753,7 @@ var ts;
|
|
|
48730
48753
|
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
48731
48754
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
48732
48755
|
// we need to preserve generic types instead of substituting them for constraints
|
|
48733
|
-
})(CheckMode || (CheckMode = {}));
|
|
48756
|
+
})(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
|
|
48734
48757
|
var SignatureCheckMode;
|
|
48735
48758
|
(function (SignatureCheckMode) {
|
|
48736
48759
|
SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
|
|
@@ -48738,7 +48761,7 @@ var ts;
|
|
|
48738
48761
|
SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
|
|
48739
48762
|
SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
|
|
48740
48763
|
SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
|
|
48741
|
-
})(SignatureCheckMode || (SignatureCheckMode = {}));
|
|
48764
|
+
})(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
|
|
48742
48765
|
var IntersectionState;
|
|
48743
48766
|
(function (IntersectionState) {
|
|
48744
48767
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
@@ -49090,7 +49113,7 @@ var ts;
|
|
|
49090
49113
|
},
|
|
49091
49114
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
49092
49115
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
49093
|
-
return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
|
|
49116
|
+
return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
|
|
49094
49117
|
},
|
|
49095
49118
|
getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
|
|
49096
49119
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -49098,7 +49121,7 @@ var ts;
|
|
|
49098
49121
|
},
|
|
49099
49122
|
getContextualTypeForJsxAttribute: function (nodeIn) {
|
|
49100
49123
|
var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
|
|
49101
|
-
return node && getContextualTypeForJsxAttribute(node);
|
|
49124
|
+
return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
|
|
49102
49125
|
},
|
|
49103
49126
|
isContextSensitive: isContextSensitive,
|
|
49104
49127
|
getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
|
|
@@ -50430,6 +50453,7 @@ var ts;
|
|
|
50430
50453
|
if (ctor && ctor.locals) {
|
|
50431
50454
|
if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
|
|
50432
50455
|
// Remember the property node, it will be used later to report appropriate error
|
|
50456
|
+
ts.Debug.assertNode(location, ts.isPropertyDeclaration);
|
|
50433
50457
|
propertyWithInvalidInitializer = location;
|
|
50434
50458
|
}
|
|
50435
50459
|
}
|
|
@@ -50619,11 +50643,27 @@ var ts;
|
|
|
50619
50643
|
}
|
|
50620
50644
|
}
|
|
50621
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
|
+
}
|
|
50622
50661
|
if (!result) {
|
|
50623
50662
|
if (nameNotFoundMessage) {
|
|
50624
50663
|
addLazyDiagnostic(function () {
|
|
50625
50664
|
if (!errorLocation ||
|
|
50626
50665
|
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
50666
|
+
!checkAndReportErrorForInvalidInitializer() &&
|
|
50627
50667
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50628
50668
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50629
50669
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
@@ -50631,7 +50671,16 @@ var ts;
|
|
|
50631
50671
|
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50632
50672
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50633
50673
|
var suggestion = void 0;
|
|
50634
|
-
|
|
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) {
|
|
50635
50684
|
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
50636
50685
|
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
50637
50686
|
if (isGlobalScopeAugmentationDeclaration) {
|
|
@@ -50650,16 +50699,9 @@ var ts;
|
|
|
50650
50699
|
}
|
|
50651
50700
|
}
|
|
50652
50701
|
}
|
|
50653
|
-
|
|
50654
|
-
|
|
50655
|
-
|
|
50656
|
-
if (lib) {
|
|
50657
|
-
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
|
|
50658
|
-
}
|
|
50659
|
-
else {
|
|
50660
|
-
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
50661
|
-
}
|
|
50662
|
-
}
|
|
50702
|
+
// And then fall back to unspecified "not found"
|
|
50703
|
+
if (!suggestion && !suggestedLib && nameArg) {
|
|
50704
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
50663
50705
|
}
|
|
50664
50706
|
suggestionCount++;
|
|
50665
50707
|
}
|
|
@@ -50667,12 +50709,7 @@ var ts;
|
|
|
50667
50709
|
}
|
|
50668
50710
|
return undefined;
|
|
50669
50711
|
}
|
|
50670
|
-
if (
|
|
50671
|
-
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50672
|
-
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50673
|
-
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
50674
|
-
var propertyName = propertyWithInvalidInitializer.name;
|
|
50675
|
-
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()) {
|
|
50676
50713
|
return undefined;
|
|
50677
50714
|
}
|
|
50678
50715
|
// Perform extra checks only if error reporting was requested
|
|
@@ -52821,13 +52858,25 @@ var ts;
|
|
|
52821
52858
|
&& isDeclarationVisible(declaration.parent)) {
|
|
52822
52859
|
return addVisibleAlias(declaration, declaration);
|
|
52823
52860
|
}
|
|
52824
|
-
else if (
|
|
52825
|
-
&& ts.
|
|
52826
|
-
|
|
52827
|
-
|
|
52828
|
-
|
|
52829
|
-
|
|
52830
|
-
|
|
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
|
+
}
|
|
52831
52880
|
}
|
|
52832
52881
|
// Declaration is not visible
|
|
52833
52882
|
return false;
|
|
@@ -53348,6 +53397,10 @@ var ts;
|
|
|
53348
53397
|
}
|
|
53349
53398
|
return typeToTypeNodeHelper(type, context);
|
|
53350
53399
|
}
|
|
53400
|
+
function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
|
|
53401
|
+
return isMappedTypeWithKeyofConstraintDeclaration(type)
|
|
53402
|
+
&& !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
|
|
53403
|
+
}
|
|
53351
53404
|
function createMappedTypeNodeFromType(type) {
|
|
53352
53405
|
ts.Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
53353
53406
|
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
|
|
@@ -53357,7 +53410,7 @@ var ts;
|
|
|
53357
53410
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
53358
53411
|
// We have a { [P in keyof T]: X }
|
|
53359
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`
|
|
53360
|
-
if (
|
|
53413
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53361
53414
|
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
53362
53415
|
var name = typeParameterToName(newParam, context);
|
|
53363
53416
|
newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
@@ -53373,11 +53426,12 @@ var ts;
|
|
|
53373
53426
|
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
53374
53427
|
context.approximateLength += 10;
|
|
53375
53428
|
var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
53376
|
-
if (
|
|
53429
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53377
53430
|
// homomorphic mapped type with a non-homomorphic naive inlining
|
|
53378
53431
|
// wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
|
|
53379
53432
|
// type stays homomorphic
|
|
53380
|
-
|
|
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 */));
|
|
53381
53435
|
}
|
|
53382
53436
|
return result;
|
|
53383
53437
|
}
|
|
@@ -62522,19 +62576,22 @@ var ts;
|
|
|
62522
62576
|
* to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
|
|
62523
62577
|
*/
|
|
62524
62578
|
function isPossiblyReducibleByInstantiation(type) {
|
|
62525
|
-
|
|
62526
|
-
|
|
62527
|
-
|
|
62528
|
-
|
|
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));
|
|
62529
62588
|
}
|
|
62530
62589
|
function getIndexType(type, stringsOnly, noIndexSignatures) {
|
|
62531
62590
|
if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
|
|
62532
62591
|
type = getReducedType(type);
|
|
62533
|
-
return type
|
|
62534
|
-
?
|
|
62535
|
-
|
|
62536
|
-
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
62537
|
-
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); })) :
|
|
62538
62595
|
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
|
|
62539
62596
|
type === wildcardType ? wildcardType :
|
|
62540
62597
|
type.flags & 2 /* Unknown */ ? neverType :
|
|
@@ -66327,13 +66384,20 @@ var ts;
|
|
|
66327
66384
|
return result;
|
|
66328
66385
|
}
|
|
66329
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) {
|
|
66330
66395
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
66331
66396
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
66332
66397
|
}
|
|
66333
66398
|
var result;
|
|
66334
66399
|
var originalErrorInfo;
|
|
66335
66400
|
var varianceCheckFailed = false;
|
|
66336
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
66337
66401
|
var sourceFlags = source.flags;
|
|
66338
66402
|
var targetFlags = target.flags;
|
|
66339
66403
|
if (relation === identityRelation) {
|
|
@@ -66397,7 +66461,6 @@ var ts;
|
|
|
66397
66461
|
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66398
66462
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66399
66463
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66400
|
-
resetErrorInfo(saveErrorInfo);
|
|
66401
66464
|
return result;
|
|
66402
66465
|
}
|
|
66403
66466
|
}
|
|
@@ -66522,7 +66585,6 @@ var ts;
|
|
|
66522
66585
|
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
66523
66586
|
}
|
|
66524
66587
|
if (result) {
|
|
66525
|
-
resetErrorInfo(saveErrorInfo);
|
|
66526
66588
|
return result;
|
|
66527
66589
|
}
|
|
66528
66590
|
if (reportErrors) {
|
|
@@ -66625,7 +66687,6 @@ var ts;
|
|
|
66625
66687
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66626
66688
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66627
66689
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
66628
|
-
resetErrorInfo(saveErrorInfo);
|
|
66629
66690
|
return 3 /* Maybe */;
|
|
66630
66691
|
}
|
|
66631
66692
|
var c = target;
|
|
@@ -66640,7 +66701,6 @@ var ts;
|
|
|
66640
66701
|
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
66641
66702
|
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
66642
66703
|
if (result) {
|
|
66643
|
-
resetErrorInfo(saveErrorInfo);
|
|
66644
66704
|
return result;
|
|
66645
66705
|
}
|
|
66646
66706
|
}
|
|
@@ -66672,12 +66732,10 @@ var ts;
|
|
|
66672
66732
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
66673
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
|
|
66674
66734
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66675
|
-
resetErrorInfo(saveErrorInfo);
|
|
66676
66735
|
return result;
|
|
66677
66736
|
}
|
|
66678
66737
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
66679
66738
|
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
66680
|
-
resetErrorInfo(saveErrorInfo);
|
|
66681
66739
|
return result;
|
|
66682
66740
|
}
|
|
66683
66741
|
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
@@ -66686,7 +66744,6 @@ var ts;
|
|
|
66686
66744
|
var indexConstraint = getConstraintOfType(source.indexType);
|
|
66687
66745
|
if (indexConstraint) {
|
|
66688
66746
|
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
66689
|
-
resetErrorInfo(saveErrorInfo);
|
|
66690
66747
|
return result;
|
|
66691
66748
|
}
|
|
66692
66749
|
}
|
|
@@ -66695,7 +66752,6 @@ var ts;
|
|
|
66695
66752
|
}
|
|
66696
66753
|
else if (sourceFlags & 4194304 /* Index */) {
|
|
66697
66754
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
66698
|
-
resetErrorInfo(saveErrorInfo);
|
|
66699
66755
|
return result;
|
|
66700
66756
|
}
|
|
66701
66757
|
}
|
|
@@ -66703,7 +66759,6 @@ var ts;
|
|
|
66703
66759
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66704
66760
|
var constraint = getBaseConstraintOfType(source);
|
|
66705
66761
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66706
|
-
resetErrorInfo(saveErrorInfo);
|
|
66707
66762
|
return result;
|
|
66708
66763
|
}
|
|
66709
66764
|
}
|
|
@@ -66714,14 +66769,12 @@ var ts;
|
|
|
66714
66769
|
return 0 /* False */;
|
|
66715
66770
|
}
|
|
66716
66771
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66717
|
-
resetErrorInfo(saveErrorInfo);
|
|
66718
66772
|
return result;
|
|
66719
66773
|
}
|
|
66720
66774
|
}
|
|
66721
66775
|
else {
|
|
66722
66776
|
var constraint = getBaseConstraintOfType(source);
|
|
66723
66777
|
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66724
|
-
resetErrorInfo(saveErrorInfo);
|
|
66725
66778
|
return result;
|
|
66726
66779
|
}
|
|
66727
66780
|
}
|
|
@@ -66730,7 +66783,6 @@ var ts;
|
|
|
66730
66783
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66731
66784
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66732
66785
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
66733
|
-
resetErrorInfo(saveErrorInfo);
|
|
66734
66786
|
return 3 /* Maybe */;
|
|
66735
66787
|
}
|
|
66736
66788
|
if (targetFlags & 16777216 /* Conditional */) {
|
|
@@ -66753,7 +66805,6 @@ var ts;
|
|
|
66753
66805
|
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
66754
66806
|
}
|
|
66755
66807
|
if (result) {
|
|
66756
|
-
resetErrorInfo(saveErrorInfo);
|
|
66757
66808
|
return result;
|
|
66758
66809
|
}
|
|
66759
66810
|
}
|
|
@@ -66764,7 +66815,6 @@ var ts;
|
|
|
66764
66815
|
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
66765
66816
|
if (distributiveConstraint) {
|
|
66766
66817
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66767
|
-
resetErrorInfo(saveErrorInfo);
|
|
66768
66818
|
return result;
|
|
66769
66819
|
}
|
|
66770
66820
|
}
|
|
@@ -66774,7 +66824,6 @@ var ts;
|
|
|
66774
66824
|
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
66775
66825
|
if (defaultConstraint) {
|
|
66776
66826
|
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66777
|
-
resetErrorInfo(saveErrorInfo);
|
|
66778
66827
|
return result;
|
|
66779
66828
|
}
|
|
66780
66829
|
}
|
|
@@ -66787,7 +66836,6 @@ var ts;
|
|
|
66787
66836
|
if (isGenericMappedType(target)) {
|
|
66788
66837
|
if (isGenericMappedType(source)) {
|
|
66789
66838
|
if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
|
|
66790
|
-
resetErrorInfo(saveErrorInfo);
|
|
66791
66839
|
return result;
|
|
66792
66840
|
}
|
|
66793
66841
|
}
|
|
@@ -70133,6 +70181,15 @@ var ts;
|
|
|
70133
70181
|
var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
|
|
70134
70182
|
return key && key + "." + propName;
|
|
70135
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);
|
|
70136
70193
|
}
|
|
70137
70194
|
return undefined;
|
|
70138
70195
|
}
|
|
@@ -72308,7 +72365,7 @@ var ts;
|
|
|
72308
72365
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
72309
72366
|
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
72310
72367
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
72311
|
-
: getContextualType(node));
|
|
72368
|
+
: getContextualType(node, /*contextFlags*/ undefined));
|
|
72312
72369
|
return contextualType && !isGenericType(contextualType);
|
|
72313
72370
|
}
|
|
72314
72371
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -73172,7 +73229,7 @@ var ts;
|
|
|
73172
73229
|
// We have an object literal method. Check if the containing object literal has a contextual type
|
|
73173
73230
|
// that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
|
|
73174
73231
|
// any directly enclosing object literals.
|
|
73175
|
-
var contextualType = getApparentTypeOfContextualType(containingLiteral);
|
|
73232
|
+
var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
|
|
73176
73233
|
var literal = containingLiteral;
|
|
73177
73234
|
var type = contextualType;
|
|
73178
73235
|
while (type) {
|
|
@@ -73184,7 +73241,7 @@ var ts;
|
|
|
73184
73241
|
break;
|
|
73185
73242
|
}
|
|
73186
73243
|
literal = literal.parent.parent;
|
|
73187
|
-
type = getApparentTypeOfContextualType(literal);
|
|
73244
|
+
type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
|
|
73188
73245
|
}
|
|
73189
73246
|
// There was no contextual ThisType<T> for the containing object literal, so the contextual type
|
|
73190
73247
|
// for 'this' is the non-null form of the contextual type for the containing object literal or
|
|
@@ -73241,7 +73298,7 @@ var ts;
|
|
|
73241
73298
|
tryGetTypeAtPosition(contextualSignature, index);
|
|
73242
73299
|
}
|
|
73243
73300
|
}
|
|
73244
|
-
function getContextualTypeForVariableLikeDeclaration(declaration) {
|
|
73301
|
+
function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
|
|
73245
73302
|
var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
|
|
73246
73303
|
if (typeNode) {
|
|
73247
73304
|
return getTypeFromTypeNode(typeNode);
|
|
@@ -73250,18 +73307,18 @@ var ts;
|
|
|
73250
73307
|
case 164 /* Parameter */:
|
|
73251
73308
|
return getContextuallyTypedParameterType(declaration);
|
|
73252
73309
|
case 203 /* BindingElement */:
|
|
73253
|
-
return getContextualTypeForBindingElement(declaration);
|
|
73310
|
+
return getContextualTypeForBindingElement(declaration, contextFlags);
|
|
73254
73311
|
case 167 /* PropertyDeclaration */:
|
|
73255
73312
|
if (ts.isStatic(declaration)) {
|
|
73256
|
-
return getContextualTypeForStaticPropertyDeclaration(declaration);
|
|
73313
|
+
return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
|
|
73257
73314
|
}
|
|
73258
73315
|
// By default, do nothing and return undefined - only the above cases have context implied by a parent
|
|
73259
73316
|
}
|
|
73260
73317
|
}
|
|
73261
|
-
function getContextualTypeForBindingElement(declaration) {
|
|
73318
|
+
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
73262
73319
|
var parent = declaration.parent.parent;
|
|
73263
73320
|
var name = declaration.propertyName || declaration.name;
|
|
73264
|
-
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
73321
|
+
var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
|
|
73265
73322
|
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
73266
73323
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
73267
73324
|
return undefined;
|
|
@@ -73277,8 +73334,8 @@ var ts;
|
|
|
73277
73334
|
return getTypeOfPropertyOfType(parentType, text);
|
|
73278
73335
|
}
|
|
73279
73336
|
}
|
|
73280
|
-
function getContextualTypeForStaticPropertyDeclaration(declaration) {
|
|
73281
|
-
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);
|
|
73282
73339
|
if (!parentType)
|
|
73283
73340
|
return undefined;
|
|
73284
73341
|
return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
|
|
@@ -73294,7 +73351,7 @@ var ts;
|
|
|
73294
73351
|
function getContextualTypeForInitializerExpression(node, contextFlags) {
|
|
73295
73352
|
var declaration = node.parent;
|
|
73296
73353
|
if (ts.hasInitializer(declaration) && node === declaration.initializer) {
|
|
73297
|
-
var result = getContextualTypeForVariableLikeDeclaration(declaration);
|
|
73354
|
+
var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
|
|
73298
73355
|
if (result) {
|
|
73299
73356
|
return result;
|
|
73300
73357
|
}
|
|
@@ -73304,10 +73361,10 @@ var ts;
|
|
|
73304
73361
|
}
|
|
73305
73362
|
return undefined;
|
|
73306
73363
|
}
|
|
73307
|
-
function getContextualTypeForReturnExpression(node) {
|
|
73364
|
+
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
73308
73365
|
var func = ts.getContainingFunction(node);
|
|
73309
73366
|
if (func) {
|
|
73310
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73367
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73311
73368
|
if (contextualReturnType) {
|
|
73312
73369
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73313
73370
|
if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
|
|
@@ -73337,11 +73394,11 @@ var ts;
|
|
|
73337
73394
|
}
|
|
73338
73395
|
return undefined;
|
|
73339
73396
|
}
|
|
73340
|
-
function getContextualTypeForYieldOperand(node) {
|
|
73397
|
+
function getContextualTypeForYieldOperand(node, contextFlags) {
|
|
73341
73398
|
var func = ts.getContainingFunction(node);
|
|
73342
73399
|
if (func) {
|
|
73343
73400
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73344
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73401
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73345
73402
|
if (contextualReturnType) {
|
|
73346
73403
|
return node.asteriskToken
|
|
73347
73404
|
? contextualReturnType
|
|
@@ -73365,14 +73422,14 @@ var ts;
|
|
|
73365
73422
|
}
|
|
73366
73423
|
function getContextualIterationType(kind, functionDecl) {
|
|
73367
73424
|
var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
|
|
73368
|
-
var contextualReturnType = getContextualReturnType(functionDecl);
|
|
73425
|
+
var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
|
|
73369
73426
|
if (contextualReturnType) {
|
|
73370
73427
|
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
|
|
73371
73428
|
|| undefined;
|
|
73372
73429
|
}
|
|
73373
73430
|
return undefined;
|
|
73374
73431
|
}
|
|
73375
|
-
function getContextualReturnType(functionDecl) {
|
|
73432
|
+
function getContextualReturnType(functionDecl, contextFlags) {
|
|
73376
73433
|
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
|
73377
73434
|
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
|
73378
73435
|
var returnType = getReturnTypeFromAnnotation(functionDecl);
|
|
@@ -73387,7 +73444,7 @@ var ts;
|
|
|
73387
73444
|
}
|
|
73388
73445
|
var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
|
|
73389
73446
|
if (iife) {
|
|
73390
|
-
return getContextualType(iife);
|
|
73447
|
+
return getContextualType(iife, contextFlags);
|
|
73391
73448
|
}
|
|
73392
73449
|
return undefined;
|
|
73393
73450
|
}
|
|
@@ -73640,7 +73697,7 @@ var ts;
|
|
|
73640
73697
|
}
|
|
73641
73698
|
function getContextualTypeForObjectLiteralElement(element, contextFlags) {
|
|
73642
73699
|
var objectLiteral = element.parent;
|
|
73643
|
-
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
|
|
73700
|
+
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
|
|
73644
73701
|
if (propertyAssignmentType) {
|
|
73645
73702
|
return propertyAssignmentType;
|
|
73646
73703
|
}
|
|
@@ -73835,9 +73892,9 @@ var ts;
|
|
|
73835
73892
|
return getContextualTypeForInitializerExpression(node, contextFlags);
|
|
73836
73893
|
case 214 /* ArrowFunction */:
|
|
73837
73894
|
case 247 /* ReturnStatement */:
|
|
73838
|
-
return getContextualTypeForReturnExpression(node);
|
|
73895
|
+
return getContextualTypeForReturnExpression(node, contextFlags);
|
|
73839
73896
|
case 224 /* YieldExpression */:
|
|
73840
|
-
return getContextualTypeForYieldOperand(parent);
|
|
73897
|
+
return getContextualTypeForYieldOperand(parent, contextFlags);
|
|
73841
73898
|
case 218 /* AwaitExpression */:
|
|
73842
73899
|
return getContextualTypeForAwaitOperand(parent, contextFlags);
|
|
73843
73900
|
case 208 /* CallExpression */:
|
|
@@ -73885,7 +73942,7 @@ var ts;
|
|
|
73885
73942
|
}
|
|
73886
73943
|
return undefined;
|
|
73887
73944
|
function tryFindWhenConstTypeReference(node) {
|
|
73888
|
-
return getContextualType(node);
|
|
73945
|
+
return getContextualType(node, contextFlags);
|
|
73889
73946
|
}
|
|
73890
73947
|
}
|
|
73891
73948
|
function getInferenceContext(node) {
|
|
@@ -74187,7 +74244,7 @@ var ts;
|
|
|
74187
74244
|
var elementCount = elements.length;
|
|
74188
74245
|
var elementTypes = [];
|
|
74189
74246
|
var elementFlags = [];
|
|
74190
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74247
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74191
74248
|
var inDestructuringPattern = ts.isAssignmentTarget(node);
|
|
74192
74249
|
var inConstContext = isConstContext(node);
|
|
74193
74250
|
var hasOmittedExpression = false;
|
|
@@ -74358,7 +74415,7 @@ var ts;
|
|
|
74358
74415
|
var propertiesTable = ts.createSymbolTable();
|
|
74359
74416
|
var propertiesArray = [];
|
|
74360
74417
|
var spread = emptyObjectType;
|
|
74361
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74418
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74362
74419
|
var contextualTypeHasPattern = contextualType && contextualType.pattern &&
|
|
74363
74420
|
(contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
|
|
74364
74421
|
var inConstContext = isConstContext(node);
|
|
@@ -74697,7 +74754,7 @@ var ts;
|
|
|
74697
74754
|
if (explicitlySpecifyChildrenAttribute) {
|
|
74698
74755
|
error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
|
|
74699
74756
|
}
|
|
74700
|
-
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
|
|
74757
|
+
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
|
|
74701
74758
|
var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
|
|
74702
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
|
|
74703
74760
|
var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
|
|
@@ -78537,17 +78594,6 @@ var ts;
|
|
|
78537
78594
|
}
|
|
78538
78595
|
}
|
|
78539
78596
|
}
|
|
78540
|
-
var restType = getEffectiveRestType(context);
|
|
78541
|
-
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78542
|
-
// The contextual signature has a generic rest parameter. We first instantiate the contextual
|
|
78543
|
-
// signature (without fixing type parameters) and assign types to contextually typed parameters.
|
|
78544
|
-
var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
|
|
78545
|
-
assignContextualParameterTypes(signature, instantiatedContext);
|
|
78546
|
-
// We then infer from a tuple type representing the parameters that correspond to the contextual
|
|
78547
|
-
// rest parameter.
|
|
78548
|
-
var restPos = getParameterCount(context) - 1;
|
|
78549
|
-
inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
|
|
78550
|
-
}
|
|
78551
78597
|
}
|
|
78552
78598
|
function assignContextualParameterTypes(signature, context) {
|
|
78553
78599
|
if (context.typeParameters) {
|
|
@@ -78740,7 +78786,7 @@ var ts;
|
|
|
78740
78786
|
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
|
78741
78787
|
var contextualType = !contextualSignature ? undefined :
|
|
78742
78788
|
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
|
|
78743
|
-
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
|
|
78789
|
+
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
|
|
78744
78790
|
if (isGenerator) {
|
|
78745
78791
|
yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
|
|
78746
78792
|
returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
|
|
@@ -78811,7 +78857,7 @@ var ts;
|
|
|
78811
78857
|
nextType = iterationTypes && iterationTypes.nextType;
|
|
78812
78858
|
}
|
|
78813
78859
|
else {
|
|
78814
|
-
nextType = getContextualType(yieldExpression);
|
|
78860
|
+
nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
|
|
78815
78861
|
}
|
|
78816
78862
|
if (nextType)
|
|
78817
78863
|
ts.pushIfUnique(nextTypes, nextType);
|
|
@@ -79020,11 +79066,16 @@ var ts;
|
|
|
79020
79066
|
if (isContextSensitive(node)) {
|
|
79021
79067
|
if (contextualSignature) {
|
|
79022
79068
|
var inferenceContext = getInferenceContext(node);
|
|
79069
|
+
var instantiatedContextualSignature = void 0;
|
|
79023
79070
|
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
79024
79071
|
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
79072
|
+
var restType = getEffectiveRestType(contextualSignature);
|
|
79073
|
+
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
79074
|
+
instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
|
|
79075
|
+
}
|
|
79025
79076
|
}
|
|
79026
|
-
|
|
79027
|
-
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
|
|
79077
|
+
instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
|
|
79078
|
+
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
|
|
79028
79079
|
assignContextualParameterTypes(signature, instantiatedContextualSignature);
|
|
79029
79080
|
}
|
|
79030
79081
|
else {
|
|
@@ -80266,7 +80317,7 @@ var ts;
|
|
|
80266
80317
|
type = anyType;
|
|
80267
80318
|
addLazyDiagnostic(function () {
|
|
80268
80319
|
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
80269
|
-
var contextualType = getContextualType(node);
|
|
80320
|
+
var contextualType = getContextualType(node, /*contextFlags*/ undefined);
|
|
80270
80321
|
if (!contextualType || isTypeAny(contextualType)) {
|
|
80271
80322
|
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
80272
80323
|
}
|
|
@@ -80307,7 +80358,7 @@ var ts;
|
|
|
80307
80358
|
texts.push(span.literal.text);
|
|
80308
80359
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
80309
80360
|
}
|
|
80310
|
-
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;
|
|
80311
80362
|
}
|
|
80312
80363
|
function isTemplateLiteralContextualType(type) {
|
|
80313
80364
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
|
|
@@ -80335,7 +80386,7 @@ var ts;
|
|
|
80335
80386
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
80336
80387
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
80337
80388
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
80338
|
-
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)) ?
|
|
80339
80390
|
getRegularTypeOfLiteralType(type) : type;
|
|
80340
80391
|
return result;
|
|
80341
80392
|
}
|
|
@@ -80450,7 +80501,7 @@ var ts;
|
|
|
80450
80501
|
var type = checkExpression(node, checkMode, forceTuple);
|
|
80451
80502
|
return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
|
|
80452
80503
|
isTypeAssertion(node) ? type :
|
|
80453
|
-
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));
|
|
80454
80505
|
}
|
|
80455
80506
|
function checkPropertyAssignment(node, checkMode) {
|
|
80456
80507
|
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
|
@@ -132971,6 +133022,26 @@ var ts;
|
|
|
132971
133022
|
(function (Completions) {
|
|
132972
133023
|
var StringCompletions;
|
|
132973
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
|
+
}
|
|
132974
133045
|
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
|
|
132975
133046
|
if (ts.isInReferenceComment(sourceFile, position)) {
|
|
132976
133047
|
var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
@@ -133252,11 +133323,12 @@ var ts;
|
|
|
133252
133323
|
}
|
|
133253
133324
|
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) {
|
|
133254
133325
|
var literalValue = ts.normalizeSlashes(node.text);
|
|
133326
|
+
var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
|
|
133255
133327
|
var scriptPath = sourceFile.path;
|
|
133256
133328
|
var scriptDirectory = ts.getDirectoryPath(scriptPath);
|
|
133257
133329
|
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
|
|
133258
133330
|
? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
|
|
133259
|
-
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
|
|
133331
|
+
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
|
|
133260
133332
|
function getIncludeExtensionOption() {
|
|
133261
133333
|
var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
|
|
133262
133334
|
return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
|
|
@@ -133272,7 +133344,7 @@ var ts;
|
|
|
133272
133344
|
return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
|
|
133273
133345
|
}
|
|
133274
133346
|
else {
|
|
133275
|
-
return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
|
|
133347
|
+
return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
|
|
133276
133348
|
}
|
|
133277
133349
|
}
|
|
133278
133350
|
function isEmitResolutionKindUsingNodeModules(compilerOptions) {
|
|
@@ -133308,7 +133380,7 @@ var ts;
|
|
|
133308
133380
|
var basePath = compilerOptions.project || host.getCurrentDirectory();
|
|
133309
133381
|
var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
|
133310
133382
|
var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
|
|
133311
|
-
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()); });
|
|
133312
133384
|
}
|
|
133313
133385
|
var IncludeExtensionsOption;
|
|
133314
133386
|
(function (IncludeExtensionsOption) {
|
|
@@ -133319,10 +133391,9 @@ var ts;
|
|
|
133319
133391
|
/**
|
|
133320
133392
|
* Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
|
|
133321
133393
|
*/
|
|
133322
|
-
function getCompletionEntriesForDirectoryFragment(fragment, scriptPath,
|
|
133323
|
-
var
|
|
133324
|
-
|
|
133325
|
-
if (result === void 0) { result = []; }
|
|
133394
|
+
function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) {
|
|
133395
|
+
var _a;
|
|
133396
|
+
if (result === void 0) { result = createNameAndKindSet(); }
|
|
133326
133397
|
if (fragment === undefined) {
|
|
133327
133398
|
fragment = "";
|
|
133328
133399
|
}
|
|
@@ -133346,11 +133417,11 @@ var ts;
|
|
|
133346
133417
|
var packageJson = ts.readJson(packageJsonPath, host);
|
|
133347
133418
|
var typesVersions = packageJson.typesVersions;
|
|
133348
133419
|
if (typeof typesVersions === "object") {
|
|
133349
|
-
var versionPaths = (
|
|
133420
|
+
var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
|
|
133350
133421
|
if (versionPaths) {
|
|
133351
133422
|
var packageDirectory = ts.getDirectoryPath(packageJsonPath);
|
|
133352
133423
|
var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
|
|
133353
|
-
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory,
|
|
133424
|
+
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
|
|
133354
133425
|
// A true result means one of the `versionPaths` was matched, which will block relative resolution
|
|
133355
133426
|
// to files and folders from here. All reachable paths given the pattern match are already added.
|
|
133356
133427
|
return result;
|
|
@@ -133362,39 +133433,17 @@ var ts;
|
|
|
133362
133433
|
if (!ts.tryDirectoryExists(host, baseDirectory))
|
|
133363
133434
|
return result;
|
|
133364
133435
|
// Enumerate the available files if possible
|
|
133365
|
-
var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
|
|
133436
|
+
var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
|
|
133366
133437
|
if (files) {
|
|
133367
|
-
/**
|
|
133368
|
-
* Multiple file entries might map to the same truncated name once we remove extensions
|
|
133369
|
-
* (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
|
|
133370
|
-
*
|
|
133371
|
-
* both foo.ts and foo.tsx become foo
|
|
133372
|
-
*/
|
|
133373
|
-
var foundFiles = new ts.Map(); // maps file to its extension
|
|
133374
133438
|
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
133375
133439
|
var filePath = files_1[_i];
|
|
133376
133440
|
filePath = ts.normalizePath(filePath);
|
|
133377
133441
|
if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
|
|
133378
133442
|
continue;
|
|
133379
133443
|
}
|
|
133380
|
-
var
|
|
133381
|
-
|
|
133382
|
-
if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
|
|
133383
|
-
foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
|
|
133384
|
-
foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
|
|
133385
|
-
}
|
|
133386
|
-
else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
|
|
133387
|
-
foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
|
|
133388
|
-
foundFiles.set(foundFileName, outputExtension);
|
|
133389
|
-
}
|
|
133390
|
-
else {
|
|
133391
|
-
foundFileName = ts.getBaseFileName(filePath);
|
|
133392
|
-
foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
|
|
133393
|
-
}
|
|
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));
|
|
133394
133446
|
}
|
|
133395
|
-
foundFiles.forEach(function (ext, foundFile) {
|
|
133396
|
-
result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
|
|
133397
|
-
});
|
|
133398
133447
|
}
|
|
133399
133448
|
// If possible, get folder completion as well
|
|
133400
133449
|
var directories = ts.tryGetDirectories(host, baseDirectory);
|
|
@@ -133403,27 +133452,52 @@ var ts;
|
|
|
133403
133452
|
var directory = directories_1[_c];
|
|
133404
133453
|
var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
|
|
133405
133454
|
if (directoryName !== "@types") {
|
|
133406
|
-
result.
|
|
133455
|
+
result.add(directoryResult(directoryName));
|
|
133407
133456
|
}
|
|
133408
133457
|
}
|
|
133409
133458
|
}
|
|
133410
133459
|
return result;
|
|
133411
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
|
+
}
|
|
133412
133473
|
/** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
|
|
133413
|
-
function addCompletionEntriesFromPaths(result, fragment, baseDirectory,
|
|
133414
|
-
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) {
|
|
133415
133487
|
var pathResults = [];
|
|
133416
|
-
var
|
|
133417
|
-
for (var
|
|
133418
|
-
|
|
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 === ".")
|
|
133419
133492
|
continue;
|
|
133420
|
-
var
|
|
133493
|
+
var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
|
|
133494
|
+
var patterns = getPatternsForKey(key);
|
|
133421
133495
|
if (patterns) {
|
|
133422
|
-
var pathPattern = ts.tryParsePattern(
|
|
133496
|
+
var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash);
|
|
133423
133497
|
if (!pathPattern)
|
|
133424
133498
|
continue;
|
|
133425
133499
|
var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
|
|
133426
|
-
var isLongestMatch = isMatch && (
|
|
133500
|
+
var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* LessThan */);
|
|
133427
133501
|
if (isLongestMatch) {
|
|
133428
133502
|
// If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
|
|
133429
133503
|
// for `import {} from "some-package/|"` with a typesVersions:
|
|
@@ -133436,13 +133510,13 @@ var ts;
|
|
|
133436
133510
|
// added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
|
|
133437
133511
|
// ./dist/foo and ./foo, when only the latter will actually be resolvable.
|
|
133438
133512
|
// See pathCompletionsTypesVersionsWildcard6.ts.
|
|
133439
|
-
|
|
133513
|
+
matchedPath = key;
|
|
133440
133514
|
pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
|
|
133441
133515
|
}
|
|
133442
|
-
if (typeof pathPattern === "string" ||
|
|
133516
|
+
if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* GreaterThan */) {
|
|
133443
133517
|
pathResults.push({
|
|
133444
133518
|
matchedPattern: isMatch,
|
|
133445
|
-
results: getCompletionsForPathMapping(
|
|
133519
|
+
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
|
|
133446
133520
|
.map(function (_a) {
|
|
133447
133521
|
var name = _a.name, kind = _a.kind, extension = _a.extension;
|
|
133448
133522
|
return nameAndKind(name, kind, extension);
|
|
@@ -133451,10 +133525,8 @@ var ts;
|
|
|
133451
133525
|
}
|
|
133452
133526
|
}
|
|
133453
133527
|
}
|
|
133454
|
-
|
|
133455
|
-
|
|
133456
|
-
pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
|
|
133457
|
-
return matchedPathPrefixLength > -1;
|
|
133528
|
+
pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); });
|
|
133529
|
+
return matchedPath !== undefined;
|
|
133458
133530
|
}
|
|
133459
133531
|
/**
|
|
133460
133532
|
* Check all of the declared modules and those in node modules. Possible sources of modules:
|
|
@@ -133463,22 +133535,22 @@ var ts;
|
|
|
133463
133535
|
* Modules from node_modules (i.e. those listed in package.json)
|
|
133464
133536
|
* This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
|
|
133465
133537
|
*/
|
|
133466
|
-
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) {
|
|
133538
|
+
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) {
|
|
133467
133539
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths;
|
|
133468
|
-
var result =
|
|
133469
|
-
var extensionOptions = getExtensionOptions(compilerOptions);
|
|
133540
|
+
var result = createNameAndKindSet();
|
|
133541
|
+
var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
|
|
133470
133542
|
if (baseUrl) {
|
|
133471
133543
|
var projectDir = compilerOptions.project || host.getCurrentDirectory();
|
|
133472
133544
|
var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl));
|
|
133473
133545
|
getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
|
|
133474
133546
|
if (paths) {
|
|
133475
|
-
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions
|
|
133547
|
+
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
|
|
133476
133548
|
}
|
|
133477
133549
|
}
|
|
133478
133550
|
var fragmentDirectory = getFragmentDirectory(fragment);
|
|
133479
133551
|
for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
|
|
133480
133552
|
var ambientName = _a[_i];
|
|
133481
|
-
result.
|
|
133553
|
+
result.add(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133482
133554
|
}
|
|
133483
133555
|
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
133484
133556
|
if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
|
|
@@ -133486,15 +133558,13 @@ var ts;
|
|
|
133486
133558
|
// (But do if we didn't find anything, e.g. 'package.json' missing.)
|
|
133487
133559
|
var foundGlobal = false;
|
|
133488
133560
|
if (fragmentDirectory === undefined) {
|
|
133489
|
-
var _loop_3 = function (moduleName) {
|
|
133490
|
-
if (!result.some(function (entry) { return entry.name === moduleName; })) {
|
|
133491
|
-
foundGlobal = true;
|
|
133492
|
-
result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133493
|
-
}
|
|
133494
|
-
};
|
|
133495
133561
|
for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
|
|
133496
133562
|
var moduleName = _c[_b];
|
|
133497
|
-
|
|
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
|
+
}
|
|
133498
133568
|
}
|
|
133499
133569
|
}
|
|
133500
133570
|
if (!foundGlobal) {
|
|
@@ -133520,39 +133590,19 @@ var ts;
|
|
|
133520
133590
|
}
|
|
133521
133591
|
packagePath = ts.combinePaths(packagePath, subName);
|
|
133522
133592
|
}
|
|
133523
|
-
var
|
|
133593
|
+
var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
|
|
133594
|
+
var packageFile = ts.combinePaths(packageDirectory, "package.json");
|
|
133524
133595
|
if (ts.tryFileExists(host, packageFile)) {
|
|
133525
133596
|
var packageJson = ts.readJson(packageFile, host);
|
|
133526
|
-
var
|
|
133527
|
-
if (
|
|
133528
|
-
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
|
|
133529
133600
|
return; // null exports or entrypoint only, no sub-modules available
|
|
133530
133601
|
}
|
|
133531
|
-
var keys = ts.getOwnKeys(
|
|
133532
|
-
var
|
|
133533
|
-
var
|
|
133534
|
-
|
|
133535
|
-
return undefined;
|
|
133536
|
-
if (!ts.startsWith(k, "./"))
|
|
133537
|
-
return undefined;
|
|
133538
|
-
var subpath = k.substring(2);
|
|
133539
|
-
if (!ts.startsWith(subpath, fragmentSubpath_1))
|
|
133540
|
-
return undefined;
|
|
133541
|
-
// subpath is a valid export (barring conditions, which we don't currently check here)
|
|
133542
|
-
if (!ts.stringContains(subpath, "*")) {
|
|
133543
|
-
return subpath;
|
|
133544
|
-
}
|
|
133545
|
-
// pattern export - only return everything up to the `*`, so the user can autocomplete, then
|
|
133546
|
-
// keep filling in the pattern (we could speculatively return a list of options by hitting disk,
|
|
133547
|
-
// but conditions will make that somewhat awkward, as each condition may have a different set of possible
|
|
133548
|
-
// options for the `*`.
|
|
133549
|
-
return subpath.slice(0, subpath.indexOf("*"));
|
|
133550
|
-
});
|
|
133551
|
-
ts.forEach(processedKeys, function (k) {
|
|
133552
|
-
if (k) {
|
|
133553
|
-
result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133554
|
-
}
|
|
133555
|
-
});
|
|
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);
|
|
133556
133606
|
return;
|
|
133557
133607
|
}
|
|
133558
133608
|
}
|
|
@@ -133562,31 +133612,44 @@ var ts;
|
|
|
133562
133612
|
ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
|
|
133563
133613
|
}
|
|
133564
133614
|
}
|
|
133565
|
-
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
|
+
}
|
|
133566
133629
|
}
|
|
133567
133630
|
function getFragmentDirectory(fragment) {
|
|
133568
133631
|
return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined;
|
|
133569
133632
|
}
|
|
133570
|
-
function getCompletionsForPathMapping(path, patterns, fragment,
|
|
133633
|
+
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) {
|
|
133571
133634
|
if (!ts.endsWith(path, "*")) {
|
|
133572
133635
|
// For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
|
|
133573
|
-
return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray;
|
|
133636
|
+
return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* scriptElement */) : ts.emptyArray;
|
|
133574
133637
|
}
|
|
133575
133638
|
var pathPrefix = path.slice(0, path.length - 1);
|
|
133576
133639
|
var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
|
|
133577
133640
|
if (remainingFragment === undefined) {
|
|
133578
133641
|
var starIsFullPathComponent = path[path.length - 2] === "/";
|
|
133579
|
-
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) {
|
|
133580
133643
|
var name = _a.name, rest = __rest(_a, ["name"]);
|
|
133581
133644
|
return (__assign({ name: pathPrefix + name }, rest));
|
|
133582
133645
|
}); });
|
|
133583
133646
|
}
|
|
133584
|
-
return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment,
|
|
133585
|
-
function justPathMappingName(name) {
|
|
133586
|
-
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;
|
|
133587
133650
|
}
|
|
133588
133651
|
}
|
|
133589
|
-
function getModulesForPathsPattern(fragment,
|
|
133652
|
+
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) {
|
|
133590
133653
|
if (!host.readDirectory) {
|
|
133591
133654
|
return undefined;
|
|
133592
133655
|
}
|
|
@@ -133605,21 +133668,33 @@ var ts;
|
|
|
133605
133668
|
var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
|
|
133606
133669
|
var normalizedSuffix = ts.normalizePath(parsed.suffix);
|
|
133607
133670
|
// Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
|
|
133608
|
-
var baseDirectory = ts.normalizePath(ts.combinePaths(
|
|
133671
|
+
var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory));
|
|
133609
133672
|
var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
|
|
133610
|
-
// If we have a suffix, then we
|
|
133611
|
-
// that
|
|
133612
|
-
//
|
|
133613
|
-
|
|
133614
|
-
|
|
133615
|
-
|
|
133616
|
-
|
|
133617
|
-
|
|
133618
|
-
|
|
133619
|
-
var
|
|
133620
|
-
var
|
|
133621
|
-
|
|
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
|
+
}
|
|
133622
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); });
|
|
133623
133698
|
return __spreadArray(__spreadArray([], matches, true), directories, true);
|
|
133624
133699
|
function trimPrefixAndSuffix(path) {
|
|
133625
133700
|
var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix);
|
|
@@ -133662,10 +133737,10 @@ var ts;
|
|
|
133662
133737
|
var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
|
|
133663
133738
|
: kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
|
|
133664
133739
|
: ts.Debug.fail();
|
|
133665
|
-
return addReplacementSpans(toComplete, range.pos + prefix.length, names);
|
|
133740
|
+
return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values()));
|
|
133666
133741
|
}
|
|
133667
133742
|
function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) {
|
|
133668
|
-
if (result === void 0) { result =
|
|
133743
|
+
if (result === void 0) { result = createNameAndKindSet(); }
|
|
133669
133744
|
// Check for typings specified in compiler options
|
|
133670
133745
|
var seen = new ts.Map();
|
|
133671
133746
|
var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray;
|
|
@@ -133690,7 +133765,7 @@ var ts;
|
|
|
133690
133765
|
continue;
|
|
133691
133766
|
if (fragmentDirectory === undefined) {
|
|
133692
133767
|
if (!seen.has(packageName)) {
|
|
133693
|
-
result.
|
|
133768
|
+
result.add(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
133694
133769
|
seen.set(packageName, true);
|
|
133695
133770
|
}
|
|
133696
133771
|
}
|
|
@@ -139291,7 +139366,7 @@ var ts;
|
|
|
139291
139366
|
result = references;
|
|
139292
139367
|
continue;
|
|
139293
139368
|
}
|
|
139294
|
-
var
|
|
139369
|
+
var _loop_3 = function (entry) {
|
|
139295
139370
|
if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
|
|
139296
139371
|
result.push(entry);
|
|
139297
139372
|
return "continue";
|
|
@@ -139323,7 +139398,7 @@ var ts;
|
|
|
139323
139398
|
};
|
|
139324
139399
|
for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
|
|
139325
139400
|
var entry = references_2[_b];
|
|
139326
|
-
|
|
139401
|
+
_loop_3(entry);
|
|
139327
139402
|
}
|
|
139328
139403
|
}
|
|
139329
139404
|
return result;
|
|
@@ -140904,8 +140979,8 @@ var ts;
|
|
|
140904
140979
|
var declarations;
|
|
140905
140980
|
if (symbol && symbol.declarations) {
|
|
140906
140981
|
var indices = ts.indicesOf(symbol.declarations);
|
|
140907
|
-
var
|
|
140908
|
-
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; });
|
|
140909
140984
|
var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; });
|
|
140910
140985
|
var lastDecl = void 0;
|
|
140911
140986
|
for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) {
|
|
@@ -141353,7 +141428,7 @@ var ts;
|
|
|
141353
141428
|
}
|
|
141354
141429
|
function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
|
|
141355
141430
|
var allFiles = program.getSourceFiles();
|
|
141356
|
-
var
|
|
141431
|
+
var _loop_4 = function (sourceFile) {
|
|
141357
141432
|
var newFromOld = oldToNew(sourceFile.fileName);
|
|
141358
141433
|
var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
|
|
141359
141434
|
var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
|
|
@@ -141385,7 +141460,7 @@ var ts;
|
|
|
141385
141460
|
};
|
|
141386
141461
|
for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
|
|
141387
141462
|
var sourceFile = allFiles_1[_i];
|
|
141388
|
-
|
|
141463
|
+
_loop_4(sourceFile);
|
|
141389
141464
|
}
|
|
141390
141465
|
}
|
|
141391
141466
|
function combineNormal(pathA, pathB) {
|
|
@@ -142409,7 +142484,7 @@ var ts;
|
|
|
142409
142484
|
if (!patternMatcher)
|
|
142410
142485
|
return ts.emptyArray;
|
|
142411
142486
|
var rawItems = [];
|
|
142412
|
-
var
|
|
142487
|
+
var _loop_5 = function (sourceFile) {
|
|
142413
142488
|
cancellationToken.throwIfCancellationRequested();
|
|
142414
142489
|
if (excludeDtsFiles && sourceFile.isDeclarationFile) {
|
|
142415
142490
|
return "continue";
|
|
@@ -142421,7 +142496,7 @@ var ts;
|
|
|
142421
142496
|
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
|
|
142422
142497
|
for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
|
|
142423
142498
|
var sourceFile = sourceFiles_4[_i];
|
|
142424
|
-
|
|
142499
|
+
_loop_5(sourceFile);
|
|
142425
142500
|
}
|
|
142426
142501
|
rawItems.sort(compareNavigateToItems);
|
|
142427
142502
|
return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
|
|
@@ -144484,13 +144559,13 @@ var ts;
|
|
|
144484
144559
|
// Assumes 'value' is already lowercase.
|
|
144485
144560
|
function indexOfIgnoringCase(str, value) {
|
|
144486
144561
|
var n = str.length - value.length;
|
|
144487
|
-
var
|
|
144562
|
+
var _loop_6 = function (start) {
|
|
144488
144563
|
if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
|
|
144489
144564
|
return { value: start };
|
|
144490
144565
|
}
|
|
144491
144566
|
};
|
|
144492
144567
|
for (var start = 0; start <= n; start++) {
|
|
144493
|
-
var state_3 =
|
|
144568
|
+
var state_3 = _loop_6(start);
|
|
144494
144569
|
if (typeof state_3 === "object")
|
|
144495
144570
|
return state_3.value;
|
|
144496
144571
|
}
|
|
@@ -145957,7 +146032,7 @@ var ts;
|
|
|
145957
146032
|
return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
|
|
145958
146033
|
}
|
|
145959
146034
|
function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
|
|
145960
|
-
var
|
|
146035
|
+
var _loop_7 = function (n) {
|
|
145961
146036
|
// If the node is not a subspan of its parent, this is a big problem.
|
|
145962
146037
|
// There have been crashes that might be caused by this violation.
|
|
145963
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); });
|
|
@@ -145967,7 +146042,7 @@ var ts;
|
|
|
145967
146042
|
}
|
|
145968
146043
|
};
|
|
145969
146044
|
for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
|
|
145970
|
-
var state_4 =
|
|
146045
|
+
var state_4 = _loop_7(n);
|
|
145971
146046
|
if (typeof state_4 === "object")
|
|
145972
146047
|
return state_4.value;
|
|
145973
146048
|
}
|
|
@@ -147580,7 +147655,7 @@ var ts;
|
|
|
147580
147655
|
commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
|
|
147581
147656
|
ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
|
|
147582
147657
|
options = ts.cloneCompilerOptions(options);
|
|
147583
|
-
var
|
|
147658
|
+
var _loop_8 = function (opt) {
|
|
147584
147659
|
if (!ts.hasProperty(options, opt.name)) {
|
|
147585
147660
|
return "continue";
|
|
147586
147661
|
}
|
|
@@ -147599,7 +147674,7 @@ var ts;
|
|
|
147599
147674
|
};
|
|
147600
147675
|
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
|
|
147601
147676
|
var opt = commandLineOptionsStringToEnum_1[_i];
|
|
147602
|
-
|
|
147677
|
+
_loop_8(opt);
|
|
147603
147678
|
}
|
|
147604
147679
|
return options;
|
|
147605
147680
|
}
|
|
@@ -151364,7 +151439,7 @@ var ts;
|
|
|
151364
151439
|
ChangeTracker.prototype.finishDeleteDeclarations = function () {
|
|
151365
151440
|
var _this = this;
|
|
151366
151441
|
var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
|
|
151367
|
-
var
|
|
151442
|
+
var _loop_9 = function (sourceFile, node) {
|
|
151368
151443
|
if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
|
|
151369
151444
|
if (ts.isArray(node)) {
|
|
151370
151445
|
this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
|
|
@@ -151377,7 +151452,7 @@ var ts;
|
|
|
151377
151452
|
var this_1 = this;
|
|
151378
151453
|
for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
|
|
151379
151454
|
var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
|
|
151380
|
-
|
|
151455
|
+
_loop_9(sourceFile, node);
|
|
151381
151456
|
}
|
|
151382
151457
|
deletedNodesInLists.forEach(function (node) {
|
|
151383
151458
|
var sourceFile = node.getSourceFile();
|
|
@@ -151465,14 +151540,14 @@ var ts;
|
|
|
151465
151540
|
// order changes by start position
|
|
151466
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.
|
|
151467
151542
|
var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
|
|
151468
|
-
var
|
|
151543
|
+
var _loop_10 = function (i) {
|
|
151469
151544
|
ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
|
|
151470
151545
|
return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
|
|
151471
151546
|
});
|
|
151472
151547
|
};
|
|
151473
151548
|
// verify that change intervals do not overlap, except possibly at end points.
|
|
151474
151549
|
for (var i = 0; i < normalized.length - 1; i++) {
|
|
151475
|
-
|
|
151550
|
+
_loop_10(i);
|
|
151476
151551
|
}
|
|
151477
151552
|
var textChanges = ts.mapDefined(normalized, function (c) {
|
|
151478
151553
|
var span = ts.createTextSpanFromRange(c.range);
|
|
@@ -152380,7 +152455,7 @@ var ts;
|
|
|
152380
152455
|
}
|
|
152381
152456
|
var isCompleteFix = identifiers.isCompleteFix;
|
|
152382
152457
|
var initializers;
|
|
152383
|
-
var
|
|
152458
|
+
var _loop_11 = function (identifier) {
|
|
152384
152459
|
var symbol = checker.getSymbolAtLocation(identifier);
|
|
152385
152460
|
if (!symbol) {
|
|
152386
152461
|
return "continue";
|
|
@@ -152413,7 +152488,7 @@ var ts;
|
|
|
152413
152488
|
};
|
|
152414
152489
|
for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
|
|
152415
152490
|
var identifier = _a[_i];
|
|
152416
|
-
|
|
152491
|
+
_loop_11(identifier);
|
|
152417
152492
|
}
|
|
152418
152493
|
return initializers && {
|
|
152419
152494
|
initializers: initializers,
|
|
@@ -153298,7 +153373,7 @@ var ts;
|
|
|
153298
153373
|
}
|
|
153299
153374
|
var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
|
|
153300
153375
|
changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " });
|
|
153301
|
-
var
|
|
153376
|
+
var _loop_12 = function (returnStatement) {
|
|
153302
153377
|
ts.forEachChild(returnStatement, function visit(node) {
|
|
153303
153378
|
if (ts.isCallExpression(node)) {
|
|
153304
153379
|
var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
|
|
@@ -153320,7 +153395,7 @@ var ts;
|
|
|
153320
153395
|
};
|
|
153321
153396
|
for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
|
|
153322
153397
|
var returnStatement = returnStatements_1[_i];
|
|
153323
|
-
var state_5 =
|
|
153398
|
+
var state_5 = _loop_12(returnStatement);
|
|
153324
153399
|
if (typeof state_5 === "object")
|
|
153325
153400
|
return state_5.value;
|
|
153326
153401
|
}
|
|
@@ -156655,7 +156730,7 @@ var ts;
|
|
|
156655
156730
|
});
|
|
156656
156731
|
typeDeclToMembers.forEach(function (infos, declaration) {
|
|
156657
156732
|
var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
|
|
156658
|
-
var
|
|
156733
|
+
var _loop_13 = function (info) {
|
|
156659
156734
|
// If some superclass added this property, don't add it again.
|
|
156660
156735
|
if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
|
|
156661
156736
|
var superInfos = typeDeclToMembers.get(superClassOrInterface);
|
|
@@ -156682,7 +156757,7 @@ var ts;
|
|
|
156682
156757
|
};
|
|
156683
156758
|
for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
|
|
156684
156759
|
var info = infos_1[_i];
|
|
156685
|
-
|
|
156760
|
+
_loop_13(info);
|
|
156686
156761
|
}
|
|
156687
156762
|
});
|
|
156688
156763
|
}));
|
|
@@ -159456,7 +159531,7 @@ var ts;
|
|
|
159456
159531
|
function getSignatureFromCalls(calls) {
|
|
159457
159532
|
var parameters = [];
|
|
159458
159533
|
var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
|
|
159459
|
-
var
|
|
159534
|
+
var _loop_14 = function (i) {
|
|
159460
159535
|
var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
|
|
159461
159536
|
symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
|
|
159462
159537
|
if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
|
|
@@ -159465,7 +159540,7 @@ var ts;
|
|
|
159465
159540
|
parameters.push(symbol);
|
|
159466
159541
|
};
|
|
159467
159542
|
for (var i = 0; i < length; i++) {
|
|
159468
|
-
|
|
159543
|
+
_loop_14(i);
|
|
159469
159544
|
}
|
|
159470
159545
|
var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
|
|
159471
159546
|
return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
|
|
@@ -161441,7 +161516,7 @@ var ts;
|
|
|
161441
161516
|
// Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
|
|
161442
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 }`.
|
|
161443
161518
|
var neededNamedImports = new ts.Set();
|
|
161444
|
-
var
|
|
161519
|
+
var _loop_15 = function (element) {
|
|
161445
161520
|
var propertyName = (element.propertyName || element.name).text;
|
|
161446
161521
|
ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
|
|
161447
161522
|
var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
|
|
@@ -161458,7 +161533,7 @@ var ts;
|
|
|
161458
161533
|
};
|
|
161459
161534
|
for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
|
|
161460
161535
|
var element = _a[_i];
|
|
161461
|
-
|
|
161536
|
+
_loop_15(element);
|
|
161462
161537
|
}
|
|
161463
161538
|
changes.replaceNode(sourceFile, toConvert, shouldUseDefault
|
|
161464
161539
|
? ts.factory.createIdentifier(namespaceImportName)
|
|
@@ -163349,7 +163424,7 @@ var ts;
|
|
|
163349
163424
|
: ts.getEnclosingBlockScopeContainer(scopes[0]);
|
|
163350
163425
|
ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
|
|
163351
163426
|
}
|
|
163352
|
-
var
|
|
163427
|
+
var _loop_16 = function (i) {
|
|
163353
163428
|
var scopeUsages = usagesPerScope[i];
|
|
163354
163429
|
// Special case: in the innermost scope, all usages are available.
|
|
163355
163430
|
// (The computed value reflects the value at the top-level of the scope, but the
|
|
@@ -163392,7 +163467,7 @@ var ts;
|
|
|
163392
163467
|
}
|
|
163393
163468
|
};
|
|
163394
163469
|
for (var i = 0; i < scopes.length; i++) {
|
|
163395
|
-
|
|
163470
|
+
_loop_16(i);
|
|
163396
163471
|
}
|
|
163397
163472
|
return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
|
|
163398
163473
|
function isInGenericContext(node) {
|
|
@@ -164093,10 +164168,10 @@ var ts;
|
|
|
164093
164168
|
}
|
|
164094
164169
|
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
|
|
164095
164170
|
var checker = program.getTypeChecker();
|
|
164096
|
-
var
|
|
164171
|
+
var _loop_17 = function (sourceFile) {
|
|
164097
164172
|
if (sourceFile === oldFile)
|
|
164098
164173
|
return "continue";
|
|
164099
|
-
var
|
|
164174
|
+
var _loop_18 = function (statement) {
|
|
164100
164175
|
forEachImportInStatement(statement, function (importNode) {
|
|
164101
164176
|
if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
|
|
164102
164177
|
return;
|
|
@@ -164118,12 +164193,12 @@ var ts;
|
|
|
164118
164193
|
};
|
|
164119
164194
|
for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
|
|
164120
164195
|
var statement = _c[_b];
|
|
164121
|
-
|
|
164196
|
+
_loop_18(statement);
|
|
164122
164197
|
}
|
|
164123
164198
|
};
|
|
164124
164199
|
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
|
|
164125
164200
|
var sourceFile = _a[_i];
|
|
164126
|
-
|
|
164201
|
+
_loop_17(sourceFile);
|
|
164127
164202
|
}
|
|
164128
164203
|
}
|
|
164129
164204
|
function getNamespaceLikeImport(node) {
|
|
@@ -165486,7 +165561,7 @@ var ts;
|
|
|
165486
165561
|
var templateSpans = [];
|
|
165487
165562
|
var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
|
|
165488
165563
|
copyCommentFromStringLiterals(headIndexes, templateHead);
|
|
165489
|
-
var
|
|
165564
|
+
var _loop_19 = function (i) {
|
|
165490
165565
|
var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
|
|
165491
165566
|
copyOperatorComments(i, currentNode);
|
|
165492
165567
|
var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
|
|
@@ -165515,7 +165590,7 @@ var ts;
|
|
|
165515
165590
|
};
|
|
165516
165591
|
var out_i_1;
|
|
165517
165592
|
for (var i = begin; i < nodes.length; i++) {
|
|
165518
|
-
|
|
165593
|
+
_loop_19(i);
|
|
165519
165594
|
i = out_i_1;
|
|
165520
165595
|
}
|
|
165521
165596
|
return ts.factory.createTemplateExpression(templateHead, templateSpans);
|
|
@@ -166127,20 +166202,25 @@ var ts;
|
|
|
166127
166202
|
return this.documentationComment;
|
|
166128
166203
|
};
|
|
166129
166204
|
SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) {
|
|
166130
|
-
|
|
166131
|
-
|
|
166205
|
+
if (context) {
|
|
166206
|
+
if (ts.isGetAccessor(context)) {
|
|
166132
166207
|
if (!this.contextualGetAccessorDocumentationComment) {
|
|
166133
166208
|
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166134
166209
|
}
|
|
166135
|
-
|
|
166136
|
-
|
|
166210
|
+
if (ts.length(this.contextualGetAccessorDocumentationComment)) {
|
|
166211
|
+
return this.contextualGetAccessorDocumentationComment;
|
|
166212
|
+
}
|
|
166213
|
+
}
|
|
166214
|
+
if (ts.isSetAccessor(context)) {
|
|
166137
166215
|
if (!this.contextualSetAccessorDocumentationComment) {
|
|
166138
166216
|
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166139
166217
|
}
|
|
166140
|
-
|
|
166141
|
-
|
|
166142
|
-
|
|
166218
|
+
if (ts.length(this.contextualSetAccessorDocumentationComment)) {
|
|
166219
|
+
return this.contextualSetAccessorDocumentationComment;
|
|
166220
|
+
}
|
|
166221
|
+
}
|
|
166143
166222
|
}
|
|
166223
|
+
return this.getDocumentationComment(checker);
|
|
166144
166224
|
};
|
|
166145
166225
|
SymbolObject.prototype.getJsDocTags = function (checker) {
|
|
166146
166226
|
if (this.tags === undefined) {
|
|
@@ -166149,20 +166229,25 @@ var ts;
|
|
|
166149
166229
|
return this.tags;
|
|
166150
166230
|
};
|
|
166151
166231
|
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
|
|
166152
|
-
|
|
166153
|
-
|
|
166232
|
+
if (context) {
|
|
166233
|
+
if (ts.isGetAccessor(context)) {
|
|
166154
166234
|
if (!this.contextualGetAccessorTags) {
|
|
166155
166235
|
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166156
166236
|
}
|
|
166157
|
-
|
|
166158
|
-
|
|
166237
|
+
if (ts.length(this.contextualGetAccessorTags)) {
|
|
166238
|
+
return this.contextualGetAccessorTags;
|
|
166239
|
+
}
|
|
166240
|
+
}
|
|
166241
|
+
if (ts.isSetAccessor(context)) {
|
|
166159
166242
|
if (!this.contextualSetAccessorTags) {
|
|
166160
166243
|
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166161
166244
|
}
|
|
166162
|
-
|
|
166163
|
-
|
|
166164
|
-
|
|
166245
|
+
if (ts.length(this.contextualSetAccessorTags)) {
|
|
166246
|
+
return this.contextualSetAccessorTags;
|
|
166247
|
+
}
|
|
166248
|
+
}
|
|
166165
166249
|
}
|
|
166250
|
+
return this.getJsDocTags(checker);
|
|
166166
166251
|
};
|
|
166167
166252
|
return SymbolObject;
|
|
166168
166253
|
}());
|
|
@@ -166351,7 +166436,7 @@ var ts;
|
|
|
166351
166436
|
var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
|
|
166352
166437
|
if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
166353
166438
|
var seenSymbols_1 = new ts.Set();
|
|
166354
|
-
var
|
|
166439
|
+
var _loop_20 = function (declaration) {
|
|
166355
166440
|
var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
166356
166441
|
var _a;
|
|
166357
166442
|
if (!seenSymbols_1.has(symbol)) {
|
|
@@ -166368,7 +166453,7 @@ var ts;
|
|
|
166368
166453
|
};
|
|
166369
166454
|
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
166370
166455
|
var declaration = declarations_7[_i];
|
|
166371
|
-
|
|
166456
|
+
_loop_20(declaration);
|
|
166372
166457
|
}
|
|
166373
166458
|
}
|
|
166374
166459
|
return tags;
|
|
@@ -166379,7 +166464,7 @@ var ts;
|
|
|
166379
166464
|
var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
|
|
166380
166465
|
if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
166381
166466
|
var seenSymbols_2 = new ts.Set();
|
|
166382
|
-
var
|
|
166467
|
+
var _loop_21 = function (declaration) {
|
|
166383
166468
|
var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
166384
166469
|
if (!seenSymbols_2.has(symbol)) {
|
|
166385
166470
|
seenSymbols_2.add(symbol);
|
|
@@ -166395,7 +166480,7 @@ var ts;
|
|
|
166395
166480
|
};
|
|
166396
166481
|
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
166397
166482
|
var declaration = declarations_8[_i];
|
|
166398
|
-
|
|
166483
|
+
_loop_21(declaration);
|
|
166399
166484
|
}
|
|
166400
166485
|
}
|
|
166401
166486
|
return doc;
|
|
@@ -166913,7 +166998,10 @@ var ts;
|
|
|
166913
166998
|
program = undefined; // TODO: GH#18217
|
|
166914
166999
|
lastTypesRootVersion = typeRootsVersion;
|
|
166915
167000
|
}
|
|
166916
|
-
|
|
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();
|
|
166917
167005
|
// Get a fresh cache of the host information
|
|
166918
167006
|
var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
|
|
166919
167007
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|