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
|
@@ -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.20211206";
|
|
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;
|
|
@@ -41647,7 +41659,10 @@ var ts;
|
|
|
41647
41659
|
}
|
|
41648
41660
|
}
|
|
41649
41661
|
var failedLookupLocations = [];
|
|
41650
|
-
var
|
|
41662
|
+
var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
|
|
41663
|
+
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
|
|
41664
|
+
NodeResolutionFeatures.None;
|
|
41665
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
|
|
41651
41666
|
var resolved = primaryLookup();
|
|
41652
41667
|
var primary = true;
|
|
41653
41668
|
if (!resolved) {
|
|
@@ -42322,13 +42337,15 @@ var ts;
|
|
|
42322
42337
|
// not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
|
|
42323
42338
|
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
|
|
42324
42339
|
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
|
|
42340
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
|
|
42341
|
+
NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
|
|
42325
42342
|
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
|
|
42326
42343
|
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
|
|
42327
42344
|
function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42328
|
-
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.
|
|
42345
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42329
42346
|
}
|
|
42330
42347
|
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42331
|
-
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.
|
|
42348
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42332
42349
|
}
|
|
42333
42350
|
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42334
42351
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
@@ -47034,6 +47051,7 @@ var ts;
|
|
|
47034
47051
|
getIndexInfosOfType: getIndexInfosOfType,
|
|
47035
47052
|
getSignaturesOfType: getSignaturesOfType,
|
|
47036
47053
|
getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); },
|
|
47054
|
+
getIndexType: function (type) { return getIndexType(type); },
|
|
47037
47055
|
getBaseTypes: getBaseTypes,
|
|
47038
47056
|
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
|
|
47039
47057
|
getWidenedType: getWidenedType,
|
|
@@ -48291,11 +48309,12 @@ var ts;
|
|
|
48291
48309
|
*
|
|
48292
48310
|
* @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
|
|
48293
48311
|
*/
|
|
48294
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) {
|
|
48312
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
|
|
48295
48313
|
if (excludeGlobals === void 0) { excludeGlobals = false; }
|
|
48296
|
-
|
|
48314
|
+
if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
|
|
48315
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
|
|
48297
48316
|
}
|
|
48298
|
-
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) {
|
|
48317
|
+
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
48299
48318
|
var _a, _b, _c;
|
|
48300
48319
|
var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
|
48301
48320
|
var result;
|
|
@@ -48612,7 +48631,7 @@ var ts;
|
|
|
48612
48631
|
}
|
|
48613
48632
|
}
|
|
48614
48633
|
if (!result) {
|
|
48615
|
-
if (nameNotFoundMessage) {
|
|
48634
|
+
if (nameNotFoundMessage && produceDiagnostics) {
|
|
48616
48635
|
if (!errorLocation ||
|
|
48617
48636
|
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
48618
48637
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
@@ -48622,7 +48641,7 @@ var ts;
|
|
|
48622
48641
|
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
48623
48642
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
48624
48643
|
var suggestion = void 0;
|
|
48625
|
-
if (suggestionCount < maximumSuggestionCount) {
|
|
48644
|
+
if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
48626
48645
|
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
48627
48646
|
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
48628
48647
|
if (isGlobalScopeAugmentationDeclaration) {
|
|
@@ -48658,7 +48677,7 @@ var ts;
|
|
|
48658
48677
|
return undefined;
|
|
48659
48678
|
}
|
|
48660
48679
|
// Perform extra checks only if error reporting was requested
|
|
48661
|
-
if (nameNotFoundMessage) {
|
|
48680
|
+
if (nameNotFoundMessage && produceDiagnostics) {
|
|
48662
48681
|
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
48663
48682
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
48664
48683
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
@@ -51134,7 +51153,7 @@ var ts;
|
|
|
51134
51153
|
context.approximateLength += 6;
|
|
51135
51154
|
return ts.factory.createKeywordTypeNode(147 /* ObjectKeyword */);
|
|
51136
51155
|
}
|
|
51137
|
-
if (isThisTypeParameter(type)) {
|
|
51156
|
+
if (ts.isThisTypeParameter(type)) {
|
|
51138
51157
|
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
|
|
51139
51158
|
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
|
|
51140
51159
|
context.encounteredError = true;
|
|
@@ -59079,7 +59098,7 @@ var ts;
|
|
|
59079
59098
|
}
|
|
59080
59099
|
function getGlobalSymbol(name, meaning, diagnostic) {
|
|
59081
59100
|
// Don't track references for global symbols anyway, so value if `isReference` is arbitrary
|
|
59082
|
-
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
|
|
59101
|
+
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
|
|
59083
59102
|
}
|
|
59084
59103
|
function getGlobalType(name, arity, reportErrors) {
|
|
59085
59104
|
var symbol = getGlobalTypeSymbol(name, reportErrors);
|
|
@@ -60658,9 +60677,6 @@ var ts;
|
|
|
60658
60677
|
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 /* IsGenericObjectType */ : 0) |
|
|
60659
60678
|
(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 16777216 /* IsGenericIndexType */ : 0);
|
|
60660
60679
|
}
|
|
60661
|
-
function isThisTypeParameter(type) {
|
|
60662
|
-
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
60663
|
-
}
|
|
60664
60680
|
function getSimplifiedType(type, writing) {
|
|
60665
60681
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
|
|
60666
60682
|
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
|
|
@@ -65858,7 +65874,7 @@ var ts;
|
|
|
65858
65874
|
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
|
|
65859
65875
|
// no flags for all other types (including non-falsy literal types).
|
|
65860
65876
|
function getFalsyFlags(type) {
|
|
65861
|
-
return type.flags &
|
|
65877
|
+
return type.flags & 3145728 /* UnionOrIntersection */ ? getFalsyFlagsOfTypes(type.types) :
|
|
65862
65878
|
type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
|
|
65863
65879
|
type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
|
|
65864
65880
|
type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
|
|
@@ -67474,6 +67490,11 @@ var ts;
|
|
|
67474
67490
|
case "BigInt64Array":
|
|
67475
67491
|
case "BigUint64Array":
|
|
67476
67492
|
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;
|
|
67493
|
+
case "await":
|
|
67494
|
+
if (ts.isCallExpression(node.parent)) {
|
|
67495
|
+
return ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function;
|
|
67496
|
+
}
|
|
67497
|
+
// falls through
|
|
67477
67498
|
default:
|
|
67478
67499
|
if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
|
|
67479
67500
|
return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
|
|
@@ -69031,7 +69052,7 @@ var ts;
|
|
|
69031
69052
|
function narrowByInKeyword(type, name, assumeTrue) {
|
|
69032
69053
|
if (type.flags & 1048576 /* Union */
|
|
69033
69054
|
|| type.flags & 524288 /* Object */ && declaredType !== type
|
|
69034
|
-
|| isThisTypeParameter(type)
|
|
69055
|
+
|| ts.isThisTypeParameter(type)
|
|
69035
69056
|
|| type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
|
|
69036
69057
|
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
|
|
69037
69058
|
}
|
|
@@ -71851,15 +71872,9 @@ var ts;
|
|
|
71851
71872
|
}
|
|
71852
71873
|
}
|
|
71853
71874
|
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));
|
|
71875
|
+
var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType));
|
|
71876
|
+
return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
71877
|
+
t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType));
|
|
71863
71878
|
}
|
|
71864
71879
|
function checkJsxSelfClosingElementDeferred(node) {
|
|
71865
71880
|
checkJsxOpeningLikeElementOrOpeningFragment(node);
|
|
@@ -72810,7 +72825,7 @@ var ts;
|
|
|
72810
72825
|
}
|
|
72811
72826
|
var propType;
|
|
72812
72827
|
if (!prop) {
|
|
72813
|
-
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ?
|
|
72828
|
+
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
|
|
72814
72829
|
getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined;
|
|
72815
72830
|
if (!(indexInfo && indexInfo.type)) {
|
|
72816
72831
|
var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true);
|
|
@@ -72827,7 +72842,7 @@ var ts;
|
|
|
72827
72842
|
return anyType;
|
|
72828
72843
|
}
|
|
72829
72844
|
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
|
|
72830
|
-
reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72845
|
+
reportNonexistentProperty(right, ts.isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72831
72846
|
}
|
|
72832
72847
|
return errorType;
|
|
72833
72848
|
}
|
|
@@ -73120,7 +73135,7 @@ var ts;
|
|
|
73120
73135
|
}
|
|
73121
73136
|
function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
|
|
73122
73137
|
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) {
|
|
73138
|
+
var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, function (symbols, name, meaning) {
|
|
73124
73139
|
ts.Debug.assertEqual(outerName, name, "name should equal outerName");
|
|
73125
73140
|
var symbol = getSymbol(symbols, name, meaning);
|
|
73126
73141
|
// 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 +73381,7 @@ var ts;
|
|
|
73366
73381
|
}
|
|
73367
73382
|
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
|
|
73368
73383
|
var accessFlags = ts.isAssignmentTarget(node) ?
|
|
73369
|
-
4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73384
|
+
4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73370
73385
|
32 /* ExpressionPosition */;
|
|
73371
73386
|
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
|
|
73372
73387
|
return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
|
|
@@ -86828,18 +86843,22 @@ var ts;
|
|
|
86828
86843
|
return false;
|
|
86829
86844
|
}
|
|
86830
86845
|
function checkNumericLiteralValueSize(node) {
|
|
86846
|
+
// We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "."
|
|
86847
|
+
// e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`.
|
|
86848
|
+
var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1;
|
|
86849
|
+
var isScientific = node.numericLiteralFlags & 16 /* Scientific */;
|
|
86831
86850
|
// Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint
|
|
86832
|
-
// Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1
|
|
86833
86851
|
// Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway
|
|
86834
|
-
if (
|
|
86852
|
+
if (isFractional || isScientific) {
|
|
86835
86853
|
return;
|
|
86836
86854
|
}
|
|
86837
|
-
//
|
|
86838
|
-
//
|
|
86839
|
-
//
|
|
86840
|
-
//
|
|
86841
|
-
|
|
86842
|
-
|
|
86855
|
+
// Here `node` is guaranteed to be a numeric literal representing an integer.
|
|
86856
|
+
// We need to judge whether the integer `node` represents is <= 2 ** 53 - 1, which can be accomplished by comparing to `value` defined below because:
|
|
86857
|
+
// 1) when `node` represents an integer <= 2 ** 53 - 1, `node.text` is its exact string representation and thus `value` precisely represents the integer.
|
|
86858
|
+
// 2) otherwise, although `node.text` may be imprecise string representation, its mathematical value and consequently `value` cannot be less than 2 ** 53,
|
|
86859
|
+
// thus the result of the predicate won't be affected.
|
|
86860
|
+
var value = +node.text;
|
|
86861
|
+
if (value <= Math.pow(2, 53) - 1) {
|
|
86843
86862
|
return;
|
|
86844
86863
|
}
|
|
86845
86864
|
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));
|
|
@@ -90301,7 +90320,7 @@ var ts;
|
|
|
90301
90320
|
// ], C.prototype, "prop");
|
|
90302
90321
|
//
|
|
90303
90322
|
var prefix = getClassMemberPrefix(node, member);
|
|
90304
|
-
var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/
|
|
90323
|
+
var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
|
|
90305
90324
|
var descriptor = languageVersion > 0 /* ES3 */
|
|
90306
90325
|
? member.kind === 166 /* PropertyDeclaration */
|
|
90307
90326
|
// We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
|
|
@@ -128193,7 +128212,7 @@ var ts;
|
|
|
128193
128212
|
case 0 /* Paths */:
|
|
128194
128213
|
return convertPathCompletions(completion.paths);
|
|
128195
128214
|
case 1 /* Properties */: {
|
|
128196
|
-
var entries =
|
|
128215
|
+
var entries = ts.createSortedArray();
|
|
128197
128216
|
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
|
|
128198
128217
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
128199
128218
|
}
|
|
@@ -128391,7 +128410,7 @@ var ts;
|
|
|
128391
128410
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
128392
128411
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
128393
128412
|
return;
|
|
128394
|
-
var type =
|
|
128413
|
+
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
128395
128414
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
128396
128415
|
return getStringLiteralTypes(type, uniques);
|
|
128397
128416
|
});
|
|
@@ -129075,6 +129094,29 @@ var ts;
|
|
|
129075
129094
|
}
|
|
129076
129095
|
}
|
|
129077
129096
|
Completions.getCompletionsAtPosition = getCompletionsAtPosition;
|
|
129097
|
+
// Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order.
|
|
129098
|
+
// So, it's important that we sort those ties in the order we want them displayed if it matters. We don't
|
|
129099
|
+
// strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to
|
|
129100
|
+
// do the work of comparing them so we can sort those ties appropriately; plus, it makes the order returned
|
|
129101
|
+
// by the language service consistent with what TS Server does and what editors typically do. This also makes
|
|
129102
|
+
// completions tests make more sense. We used to sort only alphabetically and only in the server layer, but
|
|
129103
|
+
// this made tests really weird, since most fourslash tests don't use the server.
|
|
129104
|
+
function compareCompletionEntries(entryInArray, entryToInsert) {
|
|
129105
|
+
var _a, _b;
|
|
129106
|
+
var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText);
|
|
129107
|
+
if (result === 0 /* EqualTo */) {
|
|
129108
|
+
result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name);
|
|
129109
|
+
}
|
|
129110
|
+
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)) {
|
|
129111
|
+
// Sort same-named auto-imports by module specifier
|
|
129112
|
+
result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier);
|
|
129113
|
+
}
|
|
129114
|
+
if (result === 0 /* EqualTo */) {
|
|
129115
|
+
// Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first.
|
|
129116
|
+
return -1 /* LessThan */;
|
|
129117
|
+
}
|
|
129118
|
+
return result;
|
|
129119
|
+
}
|
|
129078
129120
|
function completionEntryDataIsResolved(data) {
|
|
129079
129121
|
return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier);
|
|
129080
129122
|
}
|
|
@@ -129161,7 +129203,7 @@ var ts;
|
|
|
129161
129203
|
return completionInfo;
|
|
129162
129204
|
}
|
|
129163
129205
|
}
|
|
129164
|
-
var entries =
|
|
129206
|
+
var entries = ts.createSortedArray();
|
|
129165
129207
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129166
129208
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129167
129209
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
@@ -129179,13 +129221,13 @@ var ts;
|
|
|
129179
129221
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
129180
129222
|
var keywordEntry = _a[_i];
|
|
129181
129223
|
if (!entryNames.has(keywordEntry.name)) {
|
|
129182
|
-
|
|
129224
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129183
129225
|
}
|
|
129184
129226
|
}
|
|
129185
129227
|
}
|
|
129186
129228
|
for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
|
|
129187
129229
|
var literal = literals_1[_b];
|
|
129188
|
-
|
|
129230
|
+
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129189
129231
|
}
|
|
129190
129232
|
return {
|
|
129191
129233
|
isGlobalCompletion: isInSnippetScope,
|
|
@@ -129261,13 +129303,13 @@ var ts;
|
|
|
129261
129303
|
var realName = ts.unescapeLeadingUnderscores(name);
|
|
129262
129304
|
if (!uniqueNames.has(realName) && ts.isIdentifierText(realName, target)) {
|
|
129263
129305
|
uniqueNames.add(realName);
|
|
129264
|
-
|
|
129306
|
+
ts.insertSorted(entries, {
|
|
129265
129307
|
name: realName,
|
|
129266
129308
|
kind: "warning" /* warning */,
|
|
129267
129309
|
kindModifiers: "",
|
|
129268
129310
|
sortText: SortText.JavascriptIdentifiers,
|
|
129269
129311
|
isFromUncheckedFile: true
|
|
129270
|
-
});
|
|
129312
|
+
}, compareCompletionEntries);
|
|
129271
129313
|
}
|
|
129272
129314
|
});
|
|
129273
129315
|
}
|
|
@@ -129691,7 +129733,7 @@ var ts;
|
|
|
129691
129733
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
129692
129734
|
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129693
129735
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
129694
|
-
|
|
129736
|
+
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129695
129737
|
}
|
|
129696
129738
|
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start));
|
|
129697
129739
|
// Prevent consumers of this map from having to worry about
|
|
@@ -152168,6 +152210,7 @@ var ts;
|
|
|
152168
152210
|
var errorCodes = [
|
|
152169
152211
|
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
152170
152212
|
ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
152213
|
+
ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
152171
152214
|
];
|
|
152172
152215
|
codefix.registerCodeFix({
|
|
152173
152216
|
errorCodes: errorCodes,
|
|
@@ -159978,6 +160021,9 @@ var ts;
|
|
|
159978
160021
|
TypeObject.prototype.isClass = function () {
|
|
159979
160022
|
return !!(ts.getObjectFlags(this) & 1 /* Class */);
|
|
159980
160023
|
};
|
|
160024
|
+
TypeObject.prototype.isIndexType = function () {
|
|
160025
|
+
return !!(this.flags & 4194304 /* Index */);
|
|
160026
|
+
};
|
|
159981
160027
|
Object.defineProperty(TypeObject.prototype, "typeArguments", {
|
|
159982
160028
|
/**
|
|
159983
160029
|
* This polyfills `referenceType.typeArguments` for API consumers
|
|
@@ -160010,6 +160056,16 @@ var ts;
|
|
|
160010
160056
|
SignatureObject.prototype.getReturnType = function () {
|
|
160011
160057
|
return this.checker.getReturnTypeOfSignature(this);
|
|
160012
160058
|
};
|
|
160059
|
+
SignatureObject.prototype.getTypeParameterAtPosition = function (pos) {
|
|
160060
|
+
var type = this.checker.getParameterType(this, pos);
|
|
160061
|
+
if (type.isIndexType() && ts.isThisTypeParameter(type.type)) {
|
|
160062
|
+
var constraint = type.type.getConstraint();
|
|
160063
|
+
if (constraint) {
|
|
160064
|
+
return this.checker.getIndexType(constraint);
|
|
160065
|
+
}
|
|
160066
|
+
}
|
|
160067
|
+
return type;
|
|
160068
|
+
};
|
|
160013
160069
|
SignatureObject.prototype.getDocumentationComment = function () {
|
|
160014
160070
|
return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
|
|
160015
160071
|
};
|