typescript 4.6.0-dev.20211203 → 4.6.0-dev.20211204
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 +37 -28
- package/lib/tsserver.js +85 -38
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +85 -38
- package/lib/typescript.d.ts +2 -0
- package/lib/typescript.js +83 -36
- package/lib/typescriptServices.d.ts +2 -0
- package/lib/typescriptServices.js +83 -36
- package/lib/typingsInstaller.js +38 -28
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211204";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -1037,7 +1037,11 @@ var ts;
|
|
|
1037
1037
|
}
|
|
1038
1038
|
return deduplicated;
|
|
1039
1039
|
}
|
|
1040
|
-
function
|
|
1040
|
+
function createSortedArray() {
|
|
1041
|
+
return []; // TODO: GH#19873
|
|
1042
|
+
}
|
|
1043
|
+
ts.createSortedArray = createSortedArray;
|
|
1044
|
+
function insertSorted(array, insert, compare, allowDuplicates) {
|
|
1041
1045
|
if (array.length === 0) {
|
|
1042
1046
|
array.push(insert);
|
|
1043
1047
|
return;
|
|
@@ -1046,6 +1050,9 @@ var ts;
|
|
|
1046
1050
|
if (insertIndex < 0) {
|
|
1047
1051
|
array.splice(~insertIndex, 0, insert);
|
|
1048
1052
|
}
|
|
1053
|
+
else if (allowDuplicates) {
|
|
1054
|
+
array.splice(insertIndex, 0, insert);
|
|
1055
|
+
}
|
|
1049
1056
|
}
|
|
1050
1057
|
ts.insertSorted = insertSorted;
|
|
1051
1058
|
function sortAndDeduplicate(array, comparer, equalityComparer) {
|
|
@@ -8411,6 +8418,7 @@ var ts;
|
|
|
8411
8418
|
Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."),
|
|
8412
8419
|
An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."),
|
|
8413
8420
|
Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."),
|
|
8421
|
+
Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function: diag(2311, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function_2311", "Cannot find name '{0}'. Did you mean to write this in an async function?"),
|
|
8414
8422
|
An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."),
|
|
8415
8423
|
Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."),
|
|
8416
8424
|
Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."),
|
|
@@ -20952,6 +20960,10 @@ var ts;
|
|
|
20952
20960
|
return text.replace(/\$/gm, "\\$");
|
|
20953
20961
|
}
|
|
20954
20962
|
ts.escapeSnippetText = escapeSnippetText;
|
|
20963
|
+
function isThisTypeParameter(type) {
|
|
20964
|
+
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
20965
|
+
}
|
|
20966
|
+
ts.isThisTypeParameter = isThisTypeParameter;
|
|
20955
20967
|
})(ts || (ts = {}));
|
|
20956
20968
|
/* @internal */
|
|
20957
20969
|
var ts;
|
|
@@ -47034,6 +47046,7 @@ var ts;
|
|
|
47034
47046
|
getIndexInfosOfType: getIndexInfosOfType,
|
|
47035
47047
|
getSignaturesOfType: getSignaturesOfType,
|
|
47036
47048
|
getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); },
|
|
47049
|
+
getIndexType: function (type) { return getIndexType(type); },
|
|
47037
47050
|
getBaseTypes: getBaseTypes,
|
|
47038
47051
|
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
|
|
47039
47052
|
getWidenedType: getWidenedType,
|
|
@@ -48291,11 +48304,12 @@ var ts;
|
|
|
48291
48304
|
*
|
|
48292
48305
|
* @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
|
|
48293
48306
|
*/
|
|
48294
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) {
|
|
48307
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
|
|
48295
48308
|
if (excludeGlobals === void 0) { excludeGlobals = false; }
|
|
48296
|
-
|
|
48309
|
+
if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
|
|
48310
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
|
|
48297
48311
|
}
|
|
48298
|
-
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) {
|
|
48312
|
+
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
48299
48313
|
var _a, _b, _c;
|
|
48300
48314
|
var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
|
48301
48315
|
var result;
|
|
@@ -48612,7 +48626,7 @@ var ts;
|
|
|
48612
48626
|
}
|
|
48613
48627
|
}
|
|
48614
48628
|
if (!result) {
|
|
48615
|
-
if (nameNotFoundMessage) {
|
|
48629
|
+
if (nameNotFoundMessage && produceDiagnostics) {
|
|
48616
48630
|
if (!errorLocation ||
|
|
48617
48631
|
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
48618
48632
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
@@ -48622,7 +48636,7 @@ var ts;
|
|
|
48622
48636
|
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
48623
48637
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
48624
48638
|
var suggestion = void 0;
|
|
48625
|
-
if (suggestionCount < maximumSuggestionCount) {
|
|
48639
|
+
if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
48626
48640
|
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
48627
48641
|
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
48628
48642
|
if (isGlobalScopeAugmentationDeclaration) {
|
|
@@ -48658,7 +48672,7 @@ var ts;
|
|
|
48658
48672
|
return undefined;
|
|
48659
48673
|
}
|
|
48660
48674
|
// Perform extra checks only if error reporting was requested
|
|
48661
|
-
if (nameNotFoundMessage) {
|
|
48675
|
+
if (nameNotFoundMessage && produceDiagnostics) {
|
|
48662
48676
|
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
48663
48677
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
48664
48678
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
@@ -51134,7 +51148,7 @@ var ts;
|
|
|
51134
51148
|
context.approximateLength += 6;
|
|
51135
51149
|
return ts.factory.createKeywordTypeNode(147 /* ObjectKeyword */);
|
|
51136
51150
|
}
|
|
51137
|
-
if (isThisTypeParameter(type)) {
|
|
51151
|
+
if (ts.isThisTypeParameter(type)) {
|
|
51138
51152
|
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
|
|
51139
51153
|
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
|
|
51140
51154
|
context.encounteredError = true;
|
|
@@ -59079,7 +59093,7 @@ var ts;
|
|
|
59079
59093
|
}
|
|
59080
59094
|
function getGlobalSymbol(name, meaning, diagnostic) {
|
|
59081
59095
|
// Don't track references for global symbols anyway, so value if `isReference` is arbitrary
|
|
59082
|
-
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
|
|
59096
|
+
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
|
|
59083
59097
|
}
|
|
59084
59098
|
function getGlobalType(name, arity, reportErrors) {
|
|
59085
59099
|
var symbol = getGlobalTypeSymbol(name, reportErrors);
|
|
@@ -60658,9 +60672,6 @@ var ts;
|
|
|
60658
60672
|
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 /* IsGenericObjectType */ : 0) |
|
|
60659
60673
|
(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 16777216 /* IsGenericIndexType */ : 0);
|
|
60660
60674
|
}
|
|
60661
|
-
function isThisTypeParameter(type) {
|
|
60662
|
-
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
60663
|
-
}
|
|
60664
60675
|
function getSimplifiedType(type, writing) {
|
|
60665
60676
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
|
|
60666
60677
|
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
|
|
@@ -65858,7 +65869,7 @@ var ts;
|
|
|
65858
65869
|
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
|
|
65859
65870
|
// no flags for all other types (including non-falsy literal types).
|
|
65860
65871
|
function getFalsyFlags(type) {
|
|
65861
|
-
return type.flags &
|
|
65872
|
+
return type.flags & 3145728 /* UnionOrIntersection */ ? getFalsyFlagsOfTypes(type.types) :
|
|
65862
65873
|
type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
|
|
65863
65874
|
type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
|
|
65864
65875
|
type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
|
|
@@ -67474,6 +67485,11 @@ var ts;
|
|
|
67474
67485
|
case "BigInt64Array":
|
|
67475
67486
|
case "BigUint64Array":
|
|
67476
67487
|
return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later;
|
|
67488
|
+
case "await":
|
|
67489
|
+
if (ts.isCallExpression(node.parent)) {
|
|
67490
|
+
return ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function;
|
|
67491
|
+
}
|
|
67492
|
+
// falls through
|
|
67477
67493
|
default:
|
|
67478
67494
|
if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
|
|
67479
67495
|
return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
|
|
@@ -69031,7 +69047,7 @@ var ts;
|
|
|
69031
69047
|
function narrowByInKeyword(type, name, assumeTrue) {
|
|
69032
69048
|
if (type.flags & 1048576 /* Union */
|
|
69033
69049
|
|| type.flags & 524288 /* Object */ && declaredType !== type
|
|
69034
|
-
|| isThisTypeParameter(type)
|
|
69050
|
+
|| ts.isThisTypeParameter(type)
|
|
69035
69051
|
|| type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
|
|
69036
69052
|
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
|
|
69037
69053
|
}
|
|
@@ -71851,15 +71867,9 @@ var ts;
|
|
|
71851
71867
|
}
|
|
71852
71868
|
}
|
|
71853
71869
|
function isValidSpreadType(type) {
|
|
71854
|
-
|
|
71855
|
-
|
|
71856
|
-
|
|
71857
|
-
return isValidSpreadType(constraint);
|
|
71858
|
-
}
|
|
71859
|
-
}
|
|
71860
|
-
return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
71861
|
-
getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
|
|
71862
|
-
type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType));
|
|
71870
|
+
var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType));
|
|
71871
|
+
return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
71872
|
+
t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType));
|
|
71863
71873
|
}
|
|
71864
71874
|
function checkJsxSelfClosingElementDeferred(node) {
|
|
71865
71875
|
checkJsxOpeningLikeElementOrOpeningFragment(node);
|
|
@@ -72810,7 +72820,7 @@ var ts;
|
|
|
72810
72820
|
}
|
|
72811
72821
|
var propType;
|
|
72812
72822
|
if (!prop) {
|
|
72813
|
-
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ?
|
|
72823
|
+
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
|
|
72814
72824
|
getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined;
|
|
72815
72825
|
if (!(indexInfo && indexInfo.type)) {
|
|
72816
72826
|
var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true);
|
|
@@ -72827,7 +72837,7 @@ var ts;
|
|
|
72827
72837
|
return anyType;
|
|
72828
72838
|
}
|
|
72829
72839
|
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
|
|
72830
|
-
reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72840
|
+
reportNonexistentProperty(right, ts.isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72831
72841
|
}
|
|
72832
72842
|
return errorType;
|
|
72833
72843
|
}
|
|
@@ -73120,7 +73130,7 @@ var ts;
|
|
|
73120
73130
|
}
|
|
73121
73131
|
function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
|
|
73122
73132
|
ts.Debug.assert(outerName !== undefined, "outername should always be defined");
|
|
73123
|
-
var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, function (symbols, name, meaning) {
|
|
73133
|
+
var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, function (symbols, name, meaning) {
|
|
73124
73134
|
ts.Debug.assertEqual(outerName, name, "name should equal outerName");
|
|
73125
73135
|
var symbol = getSymbol(symbols, name, meaning);
|
|
73126
73136
|
// Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
|
|
@@ -73366,7 +73376,7 @@ var ts;
|
|
|
73366
73376
|
}
|
|
73367
73377
|
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
|
|
73368
73378
|
var accessFlags = ts.isAssignmentTarget(node) ?
|
|
73369
|
-
4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73379
|
+
4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73370
73380
|
32 /* ExpressionPosition */;
|
|
73371
73381
|
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
|
|
73372
73382
|
return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
|
|
@@ -128197,7 +128207,7 @@ var ts;
|
|
|
128197
128207
|
case 0 /* Paths */:
|
|
128198
128208
|
return convertPathCompletions(completion.paths);
|
|
128199
128209
|
case 1 /* Properties */: {
|
|
128200
|
-
var entries =
|
|
128210
|
+
var entries = ts.createSortedArray();
|
|
128201
128211
|
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
|
|
128202
128212
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
128203
128213
|
}
|
|
@@ -128395,7 +128405,7 @@ var ts;
|
|
|
128395
128405
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
128396
128406
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
128397
128407
|
return;
|
|
128398
|
-
var type =
|
|
128408
|
+
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
128399
128409
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
128400
128410
|
return getStringLiteralTypes(type, uniques);
|
|
128401
128411
|
});
|
|
@@ -129079,6 +129089,29 @@ var ts;
|
|
|
129079
129089
|
}
|
|
129080
129090
|
}
|
|
129081
129091
|
Completions.getCompletionsAtPosition = getCompletionsAtPosition;
|
|
129092
|
+
// Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order.
|
|
129093
|
+
// So, it's important that we sort those ties in the order we want them displayed if it matters. We don't
|
|
129094
|
+
// strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to
|
|
129095
|
+
// do the work of comparing them so we can sort those ties appropriately; plus, it makes the order returned
|
|
129096
|
+
// by the language service consistent with what TS Server does and what editors typically do. This also makes
|
|
129097
|
+
// completions tests make more sense. We used to sort only alphabetically and only in the server layer, but
|
|
129098
|
+
// this made tests really weird, since most fourslash tests don't use the server.
|
|
129099
|
+
function compareCompletionEntries(entryInArray, entryToInsert) {
|
|
129100
|
+
var _a, _b;
|
|
129101
|
+
var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText);
|
|
129102
|
+
if (result === 0 /* EqualTo */) {
|
|
129103
|
+
result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name);
|
|
129104
|
+
}
|
|
129105
|
+
if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) {
|
|
129106
|
+
// Sort same-named auto-imports by module specifier
|
|
129107
|
+
result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier);
|
|
129108
|
+
}
|
|
129109
|
+
if (result === 0 /* EqualTo */) {
|
|
129110
|
+
// Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first.
|
|
129111
|
+
return -1 /* LessThan */;
|
|
129112
|
+
}
|
|
129113
|
+
return result;
|
|
129114
|
+
}
|
|
129082
129115
|
function completionEntryDataIsResolved(data) {
|
|
129083
129116
|
return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier);
|
|
129084
129117
|
}
|
|
@@ -129165,7 +129198,7 @@ var ts;
|
|
|
129165
129198
|
return completionInfo;
|
|
129166
129199
|
}
|
|
129167
129200
|
}
|
|
129168
|
-
var entries =
|
|
129201
|
+
var entries = ts.createSortedArray();
|
|
129169
129202
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129170
129203
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129171
129204
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
@@ -129183,13 +129216,13 @@ var ts;
|
|
|
129183
129216
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
129184
129217
|
var keywordEntry = _a[_i];
|
|
129185
129218
|
if (!entryNames.has(keywordEntry.name)) {
|
|
129186
|
-
|
|
129219
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129187
129220
|
}
|
|
129188
129221
|
}
|
|
129189
129222
|
}
|
|
129190
129223
|
for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
|
|
129191
129224
|
var literal = literals_1[_b];
|
|
129192
|
-
|
|
129225
|
+
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129193
129226
|
}
|
|
129194
129227
|
return {
|
|
129195
129228
|
isGlobalCompletion: isInSnippetScope,
|
|
@@ -129265,13 +129298,13 @@ var ts;
|
|
|
129265
129298
|
var realName = ts.unescapeLeadingUnderscores(name);
|
|
129266
129299
|
if (!uniqueNames.has(realName) && ts.isIdentifierText(realName, target)) {
|
|
129267
129300
|
uniqueNames.add(realName);
|
|
129268
|
-
|
|
129301
|
+
ts.insertSorted(entries, {
|
|
129269
129302
|
name: realName,
|
|
129270
129303
|
kind: "warning" /* warning */,
|
|
129271
129304
|
kindModifiers: "",
|
|
129272
129305
|
sortText: SortText.JavascriptIdentifiers,
|
|
129273
129306
|
isFromUncheckedFile: true
|
|
129274
|
-
});
|
|
129307
|
+
}, compareCompletionEntries);
|
|
129275
129308
|
}
|
|
129276
129309
|
});
|
|
129277
129310
|
}
|
|
@@ -129695,7 +129728,7 @@ var ts;
|
|
|
129695
129728
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
129696
129729
|
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129697
129730
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
129698
|
-
|
|
129731
|
+
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129699
129732
|
}
|
|
129700
129733
|
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start));
|
|
129701
129734
|
// Prevent consumers of this map from having to worry about
|
|
@@ -152172,6 +152205,7 @@ var ts;
|
|
|
152172
152205
|
var errorCodes = [
|
|
152173
152206
|
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
152174
152207
|
ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
152208
|
+
ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
152175
152209
|
];
|
|
152176
152210
|
codefix.registerCodeFix({
|
|
152177
152211
|
errorCodes: errorCodes,
|
|
@@ -159982,6 +160016,9 @@ var ts;
|
|
|
159982
160016
|
TypeObject.prototype.isClass = function () {
|
|
159983
160017
|
return !!(ts.getObjectFlags(this) & 1 /* Class */);
|
|
159984
160018
|
};
|
|
160019
|
+
TypeObject.prototype.isIndexType = function () {
|
|
160020
|
+
return !!(this.flags & 4194304 /* Index */);
|
|
160021
|
+
};
|
|
159985
160022
|
Object.defineProperty(TypeObject.prototype, "typeArguments", {
|
|
159986
160023
|
/**
|
|
159987
160024
|
* This polyfills `referenceType.typeArguments` for API consumers
|
|
@@ -160014,6 +160051,16 @@ var ts;
|
|
|
160014
160051
|
SignatureObject.prototype.getReturnType = function () {
|
|
160015
160052
|
return this.checker.getReturnTypeOfSignature(this);
|
|
160016
160053
|
};
|
|
160054
|
+
SignatureObject.prototype.getTypeParameterAtPosition = function (pos) {
|
|
160055
|
+
var type = this.checker.getParameterType(this, pos);
|
|
160056
|
+
if (type.isIndexType() && ts.isThisTypeParameter(type.type)) {
|
|
160057
|
+
var constraint = type.type.getConstraint();
|
|
160058
|
+
if (constraint) {
|
|
160059
|
+
return this.checker.getIndexType(constraint);
|
|
160060
|
+
}
|
|
160061
|
+
}
|
|
160062
|
+
return type;
|
|
160063
|
+
};
|
|
160017
160064
|
SignatureObject.prototype.getDocumentationComment = function () {
|
|
160018
160065
|
return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
|
|
160019
160066
|
};
|
|
@@ -171971,14 +172018,14 @@ var ts;
|
|
|
171971
172018
|
if (kind === "completions-full" /* CompletionsFull */)
|
|
171972
172019
|
return completions;
|
|
171973
172020
|
var prefix = args.prefix || "";
|
|
171974
|
-
var entries = ts.
|
|
172021
|
+
var entries = ts.mapDefined(completions.entries, function (entry) {
|
|
171975
172022
|
if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) {
|
|
171976
172023
|
var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, sourceDisplay = entry.sourceDisplay, isSnippet = entry.isSnippet, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport, isImportStatementCompletion = entry.isImportStatementCompletion, data = entry.data;
|
|
171977
172024
|
var convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined;
|
|
171978
172025
|
// Use `hasAction || undefined` to avoid serializing `false`.
|
|
171979
172026
|
return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, isSnippet: isSnippet, hasAction: hasAction || undefined, source: source, sourceDisplay: sourceDisplay, isRecommended: isRecommended, isPackageJsonImport: isPackageJsonImport, isImportStatementCompletion: isImportStatementCompletion, data: data };
|
|
171980
172027
|
}
|
|
171981
|
-
})
|
|
172028
|
+
});
|
|
171982
172029
|
if (kind === "completions" /* Completions */) {
|
|
171983
172030
|
if (completions.metadata)
|
|
171984
172031
|
entries.metadata = completions.metadata;
|
package/lib/typescript.d.ts
CHANGED
|
@@ -5560,6 +5560,7 @@ declare namespace ts {
|
|
|
5560
5560
|
isTypeParameter(): this is TypeParameter;
|
|
5561
5561
|
isClassOrInterface(): this is InterfaceType;
|
|
5562
5562
|
isClass(): this is InterfaceType;
|
|
5563
|
+
isIndexType(): this is IndexType;
|
|
5563
5564
|
}
|
|
5564
5565
|
interface TypeReference {
|
|
5565
5566
|
typeArguments?: readonly Type[];
|
|
@@ -5568,6 +5569,7 @@ declare namespace ts {
|
|
|
5568
5569
|
getDeclaration(): SignatureDeclaration;
|
|
5569
5570
|
getTypeParameters(): TypeParameter[] | undefined;
|
|
5570
5571
|
getParameters(): Symbol[];
|
|
5572
|
+
getTypeParameterAtPosition(pos: number): Type;
|
|
5571
5573
|
getReturnType(): Type;
|
|
5572
5574
|
getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[];
|
|
5573
5575
|
getJsDocTags(): JSDocTagInfo[];
|