typescript 4.6.0-dev.20211202 → 4.6.0-dev.20211206
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 +51 -35
- package/lib/tsserver.js +106 -50
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +106 -50
- package/lib/typescript.d.ts +2 -0
- package/lib/typescript.js +104 -48
- package/lib/typescriptServices.d.ts +2 -0
- package/lib/typescriptServices.js +104 -48
- package/lib/typingsInstaller.js +59 -40
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211206";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -843,7 +843,11 @@ var ts;
|
|
|
843
843
|
}
|
|
844
844
|
return deduplicated;
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function createSortedArray() {
|
|
847
|
+
return []; // TODO: GH#19873
|
|
848
|
+
}
|
|
849
|
+
ts.createSortedArray = createSortedArray;
|
|
850
|
+
function insertSorted(array, insert, compare, allowDuplicates) {
|
|
847
851
|
if (array.length === 0) {
|
|
848
852
|
array.push(insert);
|
|
849
853
|
return;
|
|
@@ -852,6 +856,9 @@ var ts;
|
|
|
852
856
|
if (insertIndex < 0) {
|
|
853
857
|
array.splice(~insertIndex, 0, insert);
|
|
854
858
|
}
|
|
859
|
+
else if (allowDuplicates) {
|
|
860
|
+
array.splice(insertIndex, 0, insert);
|
|
861
|
+
}
|
|
855
862
|
}
|
|
856
863
|
ts.insertSorted = insertSorted;
|
|
857
864
|
function sortAndDeduplicate(array, comparer, equalityComparer) {
|
|
@@ -8217,6 +8224,7 @@ var ts;
|
|
|
8217
8224
|
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."),
|
|
8218
8225
|
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."),
|
|
8219
8226
|
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."),
|
|
8227
|
+
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?"),
|
|
8220
8228
|
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."),
|
|
8221
8229
|
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."),
|
|
8222
8230
|
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)."),
|
|
@@ -20758,6 +20766,10 @@ var ts;
|
|
|
20758
20766
|
return text.replace(/\$/gm, "\\$");
|
|
20759
20767
|
}
|
|
20760
20768
|
ts.escapeSnippetText = escapeSnippetText;
|
|
20769
|
+
function isThisTypeParameter(type) {
|
|
20770
|
+
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
20771
|
+
}
|
|
20772
|
+
ts.isThisTypeParameter = isThisTypeParameter;
|
|
20761
20773
|
})(ts || (ts = {}));
|
|
20762
20774
|
/* @internal */
|
|
20763
20775
|
var ts;
|
|
@@ -41453,7 +41465,10 @@ var ts;
|
|
|
41453
41465
|
}
|
|
41454
41466
|
}
|
|
41455
41467
|
var failedLookupLocations = [];
|
|
41456
|
-
var
|
|
41468
|
+
var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
|
|
41469
|
+
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
|
|
41470
|
+
NodeResolutionFeatures.None;
|
|
41471
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
|
|
41457
41472
|
var resolved = primaryLookup();
|
|
41458
41473
|
var primary = true;
|
|
41459
41474
|
if (!resolved) {
|
|
@@ -42128,13 +42143,15 @@ var ts;
|
|
|
42128
42143
|
// not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
|
|
42129
42144
|
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
|
|
42130
42145
|
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
|
|
42146
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
|
|
42147
|
+
NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
|
|
42131
42148
|
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
|
|
42132
42149
|
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
|
|
42133
42150
|
function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42134
|
-
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.
|
|
42151
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42135
42152
|
}
|
|
42136
42153
|
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42137
|
-
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.
|
|
42154
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42138
42155
|
}
|
|
42139
42156
|
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42140
42157
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
@@ -46840,6 +46857,7 @@ var ts;
|
|
|
46840
46857
|
getIndexInfosOfType: getIndexInfosOfType,
|
|
46841
46858
|
getSignaturesOfType: getSignaturesOfType,
|
|
46842
46859
|
getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); },
|
|
46860
|
+
getIndexType: function (type) { return getIndexType(type); },
|
|
46843
46861
|
getBaseTypes: getBaseTypes,
|
|
46844
46862
|
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
|
|
46845
46863
|
getWidenedType: getWidenedType,
|
|
@@ -48097,11 +48115,12 @@ var ts;
|
|
|
48097
48115
|
*
|
|
48098
48116
|
* @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
|
|
48099
48117
|
*/
|
|
48100
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) {
|
|
48118
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
|
|
48101
48119
|
if (excludeGlobals === void 0) { excludeGlobals = false; }
|
|
48102
|
-
|
|
48120
|
+
if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
|
|
48121
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
|
|
48103
48122
|
}
|
|
48104
|
-
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) {
|
|
48123
|
+
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
48105
48124
|
var _a, _b, _c;
|
|
48106
48125
|
var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
|
48107
48126
|
var result;
|
|
@@ -48418,7 +48437,7 @@ var ts;
|
|
|
48418
48437
|
}
|
|
48419
48438
|
}
|
|
48420
48439
|
if (!result) {
|
|
48421
|
-
if (nameNotFoundMessage) {
|
|
48440
|
+
if (nameNotFoundMessage && produceDiagnostics) {
|
|
48422
48441
|
if (!errorLocation ||
|
|
48423
48442
|
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
48424
48443
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
@@ -48428,7 +48447,7 @@ var ts;
|
|
|
48428
48447
|
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
48429
48448
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
48430
48449
|
var suggestion = void 0;
|
|
48431
|
-
if (suggestionCount < maximumSuggestionCount) {
|
|
48450
|
+
if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
48432
48451
|
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
48433
48452
|
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
48434
48453
|
if (isGlobalScopeAugmentationDeclaration) {
|
|
@@ -48464,7 +48483,7 @@ var ts;
|
|
|
48464
48483
|
return undefined;
|
|
48465
48484
|
}
|
|
48466
48485
|
// Perform extra checks only if error reporting was requested
|
|
48467
|
-
if (nameNotFoundMessage) {
|
|
48486
|
+
if (nameNotFoundMessage && produceDiagnostics) {
|
|
48468
48487
|
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
48469
48488
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
48470
48489
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
@@ -50940,7 +50959,7 @@ var ts;
|
|
|
50940
50959
|
context.approximateLength += 6;
|
|
50941
50960
|
return ts.factory.createKeywordTypeNode(147 /* ObjectKeyword */);
|
|
50942
50961
|
}
|
|
50943
|
-
if (isThisTypeParameter(type)) {
|
|
50962
|
+
if (ts.isThisTypeParameter(type)) {
|
|
50944
50963
|
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
|
|
50945
50964
|
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
|
|
50946
50965
|
context.encounteredError = true;
|
|
@@ -58885,7 +58904,7 @@ var ts;
|
|
|
58885
58904
|
}
|
|
58886
58905
|
function getGlobalSymbol(name, meaning, diagnostic) {
|
|
58887
58906
|
// Don't track references for global symbols anyway, so value if `isReference` is arbitrary
|
|
58888
|
-
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
|
|
58907
|
+
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
|
|
58889
58908
|
}
|
|
58890
58909
|
function getGlobalType(name, arity, reportErrors) {
|
|
58891
58910
|
var symbol = getGlobalTypeSymbol(name, reportErrors);
|
|
@@ -60464,9 +60483,6 @@ var ts;
|
|
|
60464
60483
|
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 /* IsGenericObjectType */ : 0) |
|
|
60465
60484
|
(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 16777216 /* IsGenericIndexType */ : 0);
|
|
60466
60485
|
}
|
|
60467
|
-
function isThisTypeParameter(type) {
|
|
60468
|
-
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
60469
|
-
}
|
|
60470
60486
|
function getSimplifiedType(type, writing) {
|
|
60471
60487
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
|
|
60472
60488
|
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
|
|
@@ -65664,7 +65680,7 @@ var ts;
|
|
|
65664
65680
|
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
|
|
65665
65681
|
// no flags for all other types (including non-falsy literal types).
|
|
65666
65682
|
function getFalsyFlags(type) {
|
|
65667
|
-
return type.flags &
|
|
65683
|
+
return type.flags & 3145728 /* UnionOrIntersection */ ? getFalsyFlagsOfTypes(type.types) :
|
|
65668
65684
|
type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
|
|
65669
65685
|
type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
|
|
65670
65686
|
type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
|
|
@@ -67280,6 +67296,11 @@ var ts;
|
|
|
67280
67296
|
case "BigInt64Array":
|
|
67281
67297
|
case "BigUint64Array":
|
|
67282
67298
|
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;
|
|
67299
|
+
case "await":
|
|
67300
|
+
if (ts.isCallExpression(node.parent)) {
|
|
67301
|
+
return ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function;
|
|
67302
|
+
}
|
|
67303
|
+
// falls through
|
|
67283
67304
|
default:
|
|
67284
67305
|
if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
|
|
67285
67306
|
return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
|
|
@@ -68837,7 +68858,7 @@ var ts;
|
|
|
68837
68858
|
function narrowByInKeyword(type, name, assumeTrue) {
|
|
68838
68859
|
if (type.flags & 1048576 /* Union */
|
|
68839
68860
|
|| type.flags & 524288 /* Object */ && declaredType !== type
|
|
68840
|
-
|| isThisTypeParameter(type)
|
|
68861
|
+
|| ts.isThisTypeParameter(type)
|
|
68841
68862
|
|| type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
|
|
68842
68863
|
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
|
|
68843
68864
|
}
|
|
@@ -71657,15 +71678,9 @@ var ts;
|
|
|
71657
71678
|
}
|
|
71658
71679
|
}
|
|
71659
71680
|
function isValidSpreadType(type) {
|
|
71660
|
-
|
|
71661
|
-
|
|
71662
|
-
|
|
71663
|
-
return isValidSpreadType(constraint);
|
|
71664
|
-
}
|
|
71665
|
-
}
|
|
71666
|
-
return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
71667
|
-
getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
|
|
71668
|
-
type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType));
|
|
71681
|
+
var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType));
|
|
71682
|
+
return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
71683
|
+
t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType));
|
|
71669
71684
|
}
|
|
71670
71685
|
function checkJsxSelfClosingElementDeferred(node) {
|
|
71671
71686
|
checkJsxOpeningLikeElementOrOpeningFragment(node);
|
|
@@ -72616,7 +72631,7 @@ var ts;
|
|
|
72616
72631
|
}
|
|
72617
72632
|
var propType;
|
|
72618
72633
|
if (!prop) {
|
|
72619
|
-
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ?
|
|
72634
|
+
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
|
|
72620
72635
|
getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined;
|
|
72621
72636
|
if (!(indexInfo && indexInfo.type)) {
|
|
72622
72637
|
var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true);
|
|
@@ -72633,7 +72648,7 @@ var ts;
|
|
|
72633
72648
|
return anyType;
|
|
72634
72649
|
}
|
|
72635
72650
|
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
|
|
72636
|
-
reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72651
|
+
reportNonexistentProperty(right, ts.isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72637
72652
|
}
|
|
72638
72653
|
return errorType;
|
|
72639
72654
|
}
|
|
@@ -72926,7 +72941,7 @@ var ts;
|
|
|
72926
72941
|
}
|
|
72927
72942
|
function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
|
|
72928
72943
|
ts.Debug.assert(outerName !== undefined, "outername should always be defined");
|
|
72929
|
-
var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, function (symbols, name, meaning) {
|
|
72944
|
+
var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, function (symbols, name, meaning) {
|
|
72930
72945
|
ts.Debug.assertEqual(outerName, name, "name should equal outerName");
|
|
72931
72946
|
var symbol = getSymbol(symbols, name, meaning);
|
|
72932
72947
|
// 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
|
|
@@ -73172,7 +73187,7 @@ var ts;
|
|
|
73172
73187
|
}
|
|
73173
73188
|
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
|
|
73174
73189
|
var accessFlags = ts.isAssignmentTarget(node) ?
|
|
73175
|
-
4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73190
|
+
4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73176
73191
|
32 /* ExpressionPosition */;
|
|
73177
73192
|
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
|
|
73178
73193
|
return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
|
|
@@ -86634,18 +86649,22 @@ var ts;
|
|
|
86634
86649
|
return false;
|
|
86635
86650
|
}
|
|
86636
86651
|
function checkNumericLiteralValueSize(node) {
|
|
86652
|
+
// We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "."
|
|
86653
|
+
// e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`.
|
|
86654
|
+
var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1;
|
|
86655
|
+
var isScientific = node.numericLiteralFlags & 16 /* Scientific */;
|
|
86637
86656
|
// Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint
|
|
86638
|
-
// Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1
|
|
86639
86657
|
// Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway
|
|
86640
|
-
if (
|
|
86658
|
+
if (isFractional || isScientific) {
|
|
86641
86659
|
return;
|
|
86642
86660
|
}
|
|
86643
|
-
//
|
|
86644
|
-
//
|
|
86645
|
-
//
|
|
86646
|
-
//
|
|
86647
|
-
|
|
86648
|
-
|
|
86661
|
+
// Here `node` is guaranteed to be a numeric literal representing an integer.
|
|
86662
|
+
// We need to judge whether the integer `node` represents is <= 2 ** 53 - 1, which can be accomplished by comparing to `value` defined below because:
|
|
86663
|
+
// 1) when `node` represents an integer <= 2 ** 53 - 1, `node.text` is its exact string representation and thus `value` precisely represents the integer.
|
|
86664
|
+
// 2) otherwise, although `node.text` may be imprecise string representation, its mathematical value and consequently `value` cannot be less than 2 ** 53,
|
|
86665
|
+
// thus the result of the predicate won't be affected.
|
|
86666
|
+
var value = +node.text;
|
|
86667
|
+
if (value <= Math.pow(2, 53) - 1) {
|
|
86649
86668
|
return;
|
|
86650
86669
|
}
|
|
86651
86670
|
addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers));
|
|
@@ -90107,7 +90126,7 @@ var ts;
|
|
|
90107
90126
|
// ], C.prototype, "prop");
|
|
90108
90127
|
//
|
|
90109
90128
|
var prefix = getClassMemberPrefix(node, member);
|
|
90110
|
-
var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/
|
|
90129
|
+
var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
|
|
90111
90130
|
var descriptor = languageVersion > 0 /* ES3 */
|
|
90112
90131
|
? member.kind === 166 /* PropertyDeclaration */
|
|
90113
90132
|
// We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
|
|
@@ -127611,7 +127630,7 @@ var ts;
|
|
|
127611
127630
|
case 0 /* Paths */:
|
|
127612
127631
|
return convertPathCompletions(completion.paths);
|
|
127613
127632
|
case 1 /* Properties */: {
|
|
127614
|
-
var entries =
|
|
127633
|
+
var entries = ts.createSortedArray();
|
|
127615
127634
|
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
|
|
127616
127635
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
127617
127636
|
}
|
|
@@ -127809,7 +127828,7 @@ var ts;
|
|
|
127809
127828
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
127810
127829
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
127811
127830
|
return;
|
|
127812
|
-
var type =
|
|
127831
|
+
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
127813
127832
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
127814
127833
|
return getStringLiteralTypes(type, uniques);
|
|
127815
127834
|
});
|
|
@@ -128493,6 +128512,29 @@ var ts;
|
|
|
128493
128512
|
}
|
|
128494
128513
|
}
|
|
128495
128514
|
Completions.getCompletionsAtPosition = getCompletionsAtPosition;
|
|
128515
|
+
// Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order.
|
|
128516
|
+
// So, it's important that we sort those ties in the order we want them displayed if it matters. We don't
|
|
128517
|
+
// strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to
|
|
128518
|
+
// do the work of comparing them so we can sort those ties appropriately; plus, it makes the order returned
|
|
128519
|
+
// by the language service consistent with what TS Server does and what editors typically do. This also makes
|
|
128520
|
+
// completions tests make more sense. We used to sort only alphabetically and only in the server layer, but
|
|
128521
|
+
// this made tests really weird, since most fourslash tests don't use the server.
|
|
128522
|
+
function compareCompletionEntries(entryInArray, entryToInsert) {
|
|
128523
|
+
var _a, _b;
|
|
128524
|
+
var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText);
|
|
128525
|
+
if (result === 0 /* EqualTo */) {
|
|
128526
|
+
result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name);
|
|
128527
|
+
}
|
|
128528
|
+
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)) {
|
|
128529
|
+
// Sort same-named auto-imports by module specifier
|
|
128530
|
+
result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier);
|
|
128531
|
+
}
|
|
128532
|
+
if (result === 0 /* EqualTo */) {
|
|
128533
|
+
// Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first.
|
|
128534
|
+
return -1 /* LessThan */;
|
|
128535
|
+
}
|
|
128536
|
+
return result;
|
|
128537
|
+
}
|
|
128496
128538
|
function completionEntryDataIsResolved(data) {
|
|
128497
128539
|
return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier);
|
|
128498
128540
|
}
|
|
@@ -128579,7 +128621,7 @@ var ts;
|
|
|
128579
128621
|
return completionInfo;
|
|
128580
128622
|
}
|
|
128581
128623
|
}
|
|
128582
|
-
var entries =
|
|
128624
|
+
var entries = ts.createSortedArray();
|
|
128583
128625
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128584
128626
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128585
128627
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
@@ -128597,13 +128639,13 @@ var ts;
|
|
|
128597
128639
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
128598
128640
|
var keywordEntry = _a[_i];
|
|
128599
128641
|
if (!entryNames.has(keywordEntry.name)) {
|
|
128600
|
-
|
|
128642
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
128601
128643
|
}
|
|
128602
128644
|
}
|
|
128603
128645
|
}
|
|
128604
128646
|
for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
|
|
128605
128647
|
var literal = literals_1[_b];
|
|
128606
|
-
|
|
128648
|
+
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
128607
128649
|
}
|
|
128608
128650
|
return {
|
|
128609
128651
|
isGlobalCompletion: isInSnippetScope,
|
|
@@ -128679,13 +128721,13 @@ var ts;
|
|
|
128679
128721
|
var realName = ts.unescapeLeadingUnderscores(name);
|
|
128680
128722
|
if (!uniqueNames.has(realName) && ts.isIdentifierText(realName, target)) {
|
|
128681
128723
|
uniqueNames.add(realName);
|
|
128682
|
-
|
|
128724
|
+
ts.insertSorted(entries, {
|
|
128683
128725
|
name: realName,
|
|
128684
128726
|
kind: "warning" /* warning */,
|
|
128685
128727
|
kindModifiers: "",
|
|
128686
128728
|
sortText: SortText.JavascriptIdentifiers,
|
|
128687
128729
|
isFromUncheckedFile: true
|
|
128688
|
-
});
|
|
128730
|
+
}, compareCompletionEntries);
|
|
128689
128731
|
}
|
|
128690
128732
|
});
|
|
128691
128733
|
}
|
|
@@ -129109,7 +129151,7 @@ var ts;
|
|
|
129109
129151
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
129110
129152
|
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129111
129153
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
129112
|
-
|
|
129154
|
+
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129113
129155
|
}
|
|
129114
129156
|
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start));
|
|
129115
129157
|
// Prevent consumers of this map from having to worry about
|
|
@@ -151586,6 +151628,7 @@ var ts;
|
|
|
151586
151628
|
var errorCodes = [
|
|
151587
151629
|
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
151588
151630
|
ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
151631
|
+
ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
151589
151632
|
];
|
|
151590
151633
|
codefix.registerCodeFix({
|
|
151591
151634
|
errorCodes: errorCodes,
|
|
@@ -159396,6 +159439,9 @@ var ts;
|
|
|
159396
159439
|
TypeObject.prototype.isClass = function () {
|
|
159397
159440
|
return !!(ts.getObjectFlags(this) & 1 /* Class */);
|
|
159398
159441
|
};
|
|
159442
|
+
TypeObject.prototype.isIndexType = function () {
|
|
159443
|
+
return !!(this.flags & 4194304 /* Index */);
|
|
159444
|
+
};
|
|
159399
159445
|
Object.defineProperty(TypeObject.prototype, "typeArguments", {
|
|
159400
159446
|
/**
|
|
159401
159447
|
* This polyfills `referenceType.typeArguments` for API consumers
|
|
@@ -159428,6 +159474,16 @@ var ts;
|
|
|
159428
159474
|
SignatureObject.prototype.getReturnType = function () {
|
|
159429
159475
|
return this.checker.getReturnTypeOfSignature(this);
|
|
159430
159476
|
};
|
|
159477
|
+
SignatureObject.prototype.getTypeParameterAtPosition = function (pos) {
|
|
159478
|
+
var type = this.checker.getParameterType(this, pos);
|
|
159479
|
+
if (type.isIndexType() && ts.isThisTypeParameter(type.type)) {
|
|
159480
|
+
var constraint = type.type.getConstraint();
|
|
159481
|
+
if (constraint) {
|
|
159482
|
+
return this.checker.getIndexType(constraint);
|
|
159483
|
+
}
|
|
159484
|
+
}
|
|
159485
|
+
return type;
|
|
159486
|
+
};
|
|
159431
159487
|
SignatureObject.prototype.getDocumentationComment = function () {
|
|
159432
159488
|
return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
|
|
159433
159489
|
};
|
|
@@ -171773,14 +171829,14 @@ var ts;
|
|
|
171773
171829
|
if (kind === "completions-full" /* CompletionsFull */)
|
|
171774
171830
|
return completions;
|
|
171775
171831
|
var prefix = args.prefix || "";
|
|
171776
|
-
var entries = ts.
|
|
171832
|
+
var entries = ts.mapDefined(completions.entries, function (entry) {
|
|
171777
171833
|
if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) {
|
|
171778
171834
|
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;
|
|
171779
171835
|
var convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined;
|
|
171780
171836
|
// Use `hasAction || undefined` to avoid serializing `false`.
|
|
171781
171837
|
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 };
|
|
171782
171838
|
}
|
|
171783
|
-
})
|
|
171839
|
+
});
|
|
171784
171840
|
if (kind === "completions" /* Completions */) {
|
|
171785
171841
|
if (completions.metadata)
|
|
171786
171842
|
entries.metadata = completions.metadata;
|
package/lib/tsserverlibrary.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[];
|