typescript 4.6.0-dev.20211203 → 4.6.0-dev.20211207
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 +59 -41
- package/lib/tsserver.js +110 -53
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +110 -53
- package/lib/typescript.d.ts +2 -0
- package/lib/typescript.js +108 -51
- package/lib/typescriptServices.d.ts +2 -0
- package/lib/typescriptServices.js +108 -51
- package/lib/typingsInstaller.js +62 -42
- package/package.json +1 -1
package/lib/typescript.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.20211207";
|
|
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) {
|
|
@@ -8124,7 +8131,7 @@ var ts;
|
|
|
8124
8131
|
Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
|
|
8125
8132
|
A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."),
|
|
8126
8133
|
A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."),
|
|
8127
|
-
|
|
8134
|
+
An_object_literal_cannot_have_multiple_properties_with_the_same_name: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_1117", "An object literal cannot have multiple properties with the same name."),
|
|
8128
8135
|
An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."),
|
|
8129
8136
|
An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."),
|
|
8130
8137
|
An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
|
|
@@ -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;
|
|
@@ -33802,10 +33814,14 @@ var ts;
|
|
|
33802
33814
|
// - "(x,y)" is a comma expression parsed as a signature with two parameters.
|
|
33803
33815
|
// - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
|
|
33804
33816
|
// - "a ? (b): function() {}" will too, since function() is a valid JSDoc function type.
|
|
33805
|
-
// - "a ? (b): (function() {})" as well, but inside of a parenthesized type.
|
|
33817
|
+
// - "a ? (b): (function() {})" as well, but inside of a parenthesized type with an arbitrary amount of nesting.
|
|
33806
33818
|
//
|
|
33807
33819
|
// So we need just a bit of lookahead to ensure that it can only be a signature.
|
|
33808
|
-
var
|
|
33820
|
+
var unwrappedType = type;
|
|
33821
|
+
while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 190 /* ParenthesizedType */) {
|
|
33822
|
+
unwrappedType = unwrappedType.type; // Skip parens if need be
|
|
33823
|
+
}
|
|
33824
|
+
var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType);
|
|
33809
33825
|
if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) {
|
|
33810
33826
|
// Returning undefined here will cause our caller to rewind to where we started from.
|
|
33811
33827
|
return undefined;
|
|
@@ -41647,7 +41663,10 @@ var ts;
|
|
|
41647
41663
|
}
|
|
41648
41664
|
}
|
|
41649
41665
|
var failedLookupLocations = [];
|
|
41650
|
-
var
|
|
41666
|
+
var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
|
|
41667
|
+
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
|
|
41668
|
+
NodeResolutionFeatures.None;
|
|
41669
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
|
|
41651
41670
|
var resolved = primaryLookup();
|
|
41652
41671
|
var primary = true;
|
|
41653
41672
|
if (!resolved) {
|
|
@@ -42322,13 +42341,15 @@ var ts;
|
|
|
42322
42341
|
// not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
|
|
42323
42342
|
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
|
|
42324
42343
|
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
|
|
42344
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
|
|
42345
|
+
NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
|
|
42325
42346
|
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
|
|
42326
42347
|
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
|
|
42327
42348
|
function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42328
|
-
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.
|
|
42349
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42329
42350
|
}
|
|
42330
42351
|
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42331
|
-
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.
|
|
42352
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42332
42353
|
}
|
|
42333
42354
|
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42334
42355
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
@@ -45131,10 +45152,6 @@ var ts;
|
|
|
45131
45152
|
seen.set(identifier.escapedText, currentKind);
|
|
45132
45153
|
continue;
|
|
45133
45154
|
}
|
|
45134
|
-
if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) {
|
|
45135
|
-
var span = ts.getErrorSpanForNode(file, identifier);
|
|
45136
|
-
file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode));
|
|
45137
|
-
}
|
|
45138
45155
|
}
|
|
45139
45156
|
}
|
|
45140
45157
|
return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */);
|
|
@@ -45368,7 +45385,7 @@ var ts;
|
|
|
45368
45385
|
}
|
|
45369
45386
|
}
|
|
45370
45387
|
function checkStrictModeNumericLiteral(node) {
|
|
45371
|
-
if (inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
|
|
45388
|
+
if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
|
|
45372
45389
|
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
|
|
45373
45390
|
}
|
|
45374
45391
|
}
|
|
@@ -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
|
|
@@ -48971,10 +48990,12 @@ var ts;
|
|
|
48971
48990
|
}
|
|
48972
48991
|
/* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached.
|
|
48973
48992
|
* If at any point current node is equal to 'parent' node - return true.
|
|
48993
|
+
* If current node is an IIFE, continue walking up.
|
|
48974
48994
|
* Return false if 'stopAt' node is reached or isFunctionLike(current) === true.
|
|
48975
48995
|
*/
|
|
48976
48996
|
function isSameScopeDescendentOf(initial, parent, stopAt) {
|
|
48977
|
-
return !!parent && !!ts.findAncestor(initial, function (n) { return n ===
|
|
48997
|
+
return !!parent && !!ts.findAncestor(initial, function (n) { return n === parent
|
|
48998
|
+
|| (n === stopAt || ts.isFunctionLike(n) && !ts.getImmediatelyInvokedFunctionExpression(n) ? "quit" : false); });
|
|
48978
48999
|
}
|
|
48979
49000
|
function getAnyImportSyntax(node) {
|
|
48980
49001
|
switch (node.kind) {
|
|
@@ -51134,7 +51155,7 @@ var ts;
|
|
|
51134
51155
|
context.approximateLength += 6;
|
|
51135
51156
|
return ts.factory.createKeywordTypeNode(147 /* ObjectKeyword */);
|
|
51136
51157
|
}
|
|
51137
|
-
if (isThisTypeParameter(type)) {
|
|
51158
|
+
if (ts.isThisTypeParameter(type)) {
|
|
51138
51159
|
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
|
|
51139
51160
|
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
|
|
51140
51161
|
context.encounteredError = true;
|
|
@@ -59079,7 +59100,7 @@ var ts;
|
|
|
59079
59100
|
}
|
|
59080
59101
|
function getGlobalSymbol(name, meaning, diagnostic) {
|
|
59081
59102
|
// Don't track references for global symbols anyway, so value if `isReference` is arbitrary
|
|
59082
|
-
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
|
|
59103
|
+
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
|
|
59083
59104
|
}
|
|
59084
59105
|
function getGlobalType(name, arity, reportErrors) {
|
|
59085
59106
|
var symbol = getGlobalTypeSymbol(name, reportErrors);
|
|
@@ -60658,9 +60679,6 @@ var ts;
|
|
|
60658
60679
|
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 /* IsGenericObjectType */ : 0) |
|
|
60659
60680
|
(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 16777216 /* IsGenericIndexType */ : 0);
|
|
60660
60681
|
}
|
|
60661
|
-
function isThisTypeParameter(type) {
|
|
60662
|
-
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
60663
|
-
}
|
|
60664
60682
|
function getSimplifiedType(type, writing) {
|
|
60665
60683
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
|
|
60666
60684
|
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
|
|
@@ -65759,7 +65777,7 @@ var ts;
|
|
|
65759
65777
|
}
|
|
65760
65778
|
function getBaseTypeOfLiteralType(type) {
|
|
65761
65779
|
return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) :
|
|
65762
|
-
type.flags & 128 /* StringLiteral */ ? stringType :
|
|
65780
|
+
type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType :
|
|
65763
65781
|
type.flags & 256 /* NumberLiteral */ ? numberType :
|
|
65764
65782
|
type.flags & 2048 /* BigIntLiteral */ ? bigintType :
|
|
65765
65783
|
type.flags & 512 /* BooleanLiteral */ ? booleanType :
|
|
@@ -65858,7 +65876,7 @@ var ts;
|
|
|
65858
65876
|
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
|
|
65859
65877
|
// no flags for all other types (including non-falsy literal types).
|
|
65860
65878
|
function getFalsyFlags(type) {
|
|
65861
|
-
return type.flags &
|
|
65879
|
+
return type.flags & 3145728 /* UnionOrIntersection */ ? getFalsyFlagsOfTypes(type.types) :
|
|
65862
65880
|
type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
|
|
65863
65881
|
type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
|
|
65864
65882
|
type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
|
|
@@ -67474,6 +67492,11 @@ var ts;
|
|
|
67474
67492
|
case "BigInt64Array":
|
|
67475
67493
|
case "BigUint64Array":
|
|
67476
67494
|
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;
|
|
67495
|
+
case "await":
|
|
67496
|
+
if (ts.isCallExpression(node.parent)) {
|
|
67497
|
+
return ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function;
|
|
67498
|
+
}
|
|
67499
|
+
// falls through
|
|
67477
67500
|
default:
|
|
67478
67501
|
if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
|
|
67479
67502
|
return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
|
|
@@ -69031,7 +69054,7 @@ var ts;
|
|
|
69031
69054
|
function narrowByInKeyword(type, name, assumeTrue) {
|
|
69032
69055
|
if (type.flags & 1048576 /* Union */
|
|
69033
69056
|
|| type.flags & 524288 /* Object */ && declaredType !== type
|
|
69034
|
-
|| isThisTypeParameter(type)
|
|
69057
|
+
|| ts.isThisTypeParameter(type)
|
|
69035
69058
|
|| type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
|
|
69036
69059
|
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
|
|
69037
69060
|
}
|
|
@@ -71851,15 +71874,9 @@ var ts;
|
|
|
71851
71874
|
}
|
|
71852
71875
|
}
|
|
71853
71876
|
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));
|
|
71877
|
+
var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType));
|
|
71878
|
+
return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
71879
|
+
t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType));
|
|
71863
71880
|
}
|
|
71864
71881
|
function checkJsxSelfClosingElementDeferred(node) {
|
|
71865
71882
|
checkJsxOpeningLikeElementOrOpeningFragment(node);
|
|
@@ -72810,7 +72827,7 @@ var ts;
|
|
|
72810
72827
|
}
|
|
72811
72828
|
var propType;
|
|
72812
72829
|
if (!prop) {
|
|
72813
|
-
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ?
|
|
72830
|
+
var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
|
|
72814
72831
|
getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined;
|
|
72815
72832
|
if (!(indexInfo && indexInfo.type)) {
|
|
72816
72833
|
var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true);
|
|
@@ -72827,7 +72844,7 @@ var ts;
|
|
|
72827
72844
|
return anyType;
|
|
72828
72845
|
}
|
|
72829
72846
|
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
|
|
72830
|
-
reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72847
|
+
reportNonexistentProperty(right, ts.isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
|
|
72831
72848
|
}
|
|
72832
72849
|
return errorType;
|
|
72833
72850
|
}
|
|
@@ -73120,7 +73137,7 @@ var ts;
|
|
|
73120
73137
|
}
|
|
73121
73138
|
function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
|
|
73122
73139
|
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) {
|
|
73140
|
+
var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, function (symbols, name, meaning) {
|
|
73124
73141
|
ts.Debug.assertEqual(outerName, name, "name should equal outerName");
|
|
73125
73142
|
var symbol = getSymbol(symbols, name, meaning);
|
|
73126
73143
|
// 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 +73383,7 @@ var ts;
|
|
|
73366
73383
|
}
|
|
73367
73384
|
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
|
|
73368
73385
|
var accessFlags = ts.isAssignmentTarget(node) ?
|
|
73369
|
-
4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73386
|
+
4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
|
|
73370
73387
|
32 /* ExpressionPosition */;
|
|
73371
73388
|
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
|
|
73372
73389
|
return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
|
|
@@ -86128,9 +86145,12 @@ var ts;
|
|
|
86128
86145
|
seen.set(effectiveName, currentKind);
|
|
86129
86146
|
}
|
|
86130
86147
|
else {
|
|
86131
|
-
if ((currentKind &
|
|
86148
|
+
if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) {
|
|
86132
86149
|
grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
|
|
86133
86150
|
}
|
|
86151
|
+
else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) {
|
|
86152
|
+
grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name));
|
|
86153
|
+
}
|
|
86134
86154
|
else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) {
|
|
86135
86155
|
if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) {
|
|
86136
86156
|
seen.set(effectiveName, currentKind | existingKind);
|
|
@@ -128197,7 +128217,7 @@ var ts;
|
|
|
128197
128217
|
case 0 /* Paths */:
|
|
128198
128218
|
return convertPathCompletions(completion.paths);
|
|
128199
128219
|
case 1 /* Properties */: {
|
|
128200
|
-
var entries =
|
|
128220
|
+
var entries = ts.createSortedArray();
|
|
128201
128221
|
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
128222
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
128203
128223
|
}
|
|
@@ -128395,7 +128415,7 @@ var ts;
|
|
|
128395
128415
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
128396
128416
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
128397
128417
|
return;
|
|
128398
|
-
var type =
|
|
128418
|
+
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
128399
128419
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
128400
128420
|
return getStringLiteralTypes(type, uniques);
|
|
128401
128421
|
});
|
|
@@ -129079,6 +129099,29 @@ var ts;
|
|
|
129079
129099
|
}
|
|
129080
129100
|
}
|
|
129081
129101
|
Completions.getCompletionsAtPosition = getCompletionsAtPosition;
|
|
129102
|
+
// Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order.
|
|
129103
|
+
// So, it's important that we sort those ties in the order we want them displayed if it matters. We don't
|
|
129104
|
+
// strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to
|
|
129105
|
+
// do the work of comparing them so we can sort those ties appropriately; plus, it makes the order returned
|
|
129106
|
+
// by the language service consistent with what TS Server does and what editors typically do. This also makes
|
|
129107
|
+
// completions tests make more sense. We used to sort only alphabetically and only in the server layer, but
|
|
129108
|
+
// this made tests really weird, since most fourslash tests don't use the server.
|
|
129109
|
+
function compareCompletionEntries(entryInArray, entryToInsert) {
|
|
129110
|
+
var _a, _b;
|
|
129111
|
+
var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText);
|
|
129112
|
+
if (result === 0 /* EqualTo */) {
|
|
129113
|
+
result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name);
|
|
129114
|
+
}
|
|
129115
|
+
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)) {
|
|
129116
|
+
// Sort same-named auto-imports by module specifier
|
|
129117
|
+
result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier);
|
|
129118
|
+
}
|
|
129119
|
+
if (result === 0 /* EqualTo */) {
|
|
129120
|
+
// Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first.
|
|
129121
|
+
return -1 /* LessThan */;
|
|
129122
|
+
}
|
|
129123
|
+
return result;
|
|
129124
|
+
}
|
|
129082
129125
|
function completionEntryDataIsResolved(data) {
|
|
129083
129126
|
return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier);
|
|
129084
129127
|
}
|
|
@@ -129165,7 +129208,7 @@ var ts;
|
|
|
129165
129208
|
return completionInfo;
|
|
129166
129209
|
}
|
|
129167
129210
|
}
|
|
129168
|
-
var entries =
|
|
129211
|
+
var entries = ts.createSortedArray();
|
|
129169
129212
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129170
129213
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129171
129214
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
@@ -129183,13 +129226,13 @@ var ts;
|
|
|
129183
129226
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
129184
129227
|
var keywordEntry = _a[_i];
|
|
129185
129228
|
if (!entryNames.has(keywordEntry.name)) {
|
|
129186
|
-
|
|
129229
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129187
129230
|
}
|
|
129188
129231
|
}
|
|
129189
129232
|
}
|
|
129190
129233
|
for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
|
|
129191
129234
|
var literal = literals_1[_b];
|
|
129192
|
-
|
|
129235
|
+
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129193
129236
|
}
|
|
129194
129237
|
return {
|
|
129195
129238
|
isGlobalCompletion: isInSnippetScope,
|
|
@@ -129265,13 +129308,13 @@ var ts;
|
|
|
129265
129308
|
var realName = ts.unescapeLeadingUnderscores(name);
|
|
129266
129309
|
if (!uniqueNames.has(realName) && ts.isIdentifierText(realName, target)) {
|
|
129267
129310
|
uniqueNames.add(realName);
|
|
129268
|
-
|
|
129311
|
+
ts.insertSorted(entries, {
|
|
129269
129312
|
name: realName,
|
|
129270
129313
|
kind: "warning" /* warning */,
|
|
129271
129314
|
kindModifiers: "",
|
|
129272
129315
|
sortText: SortText.JavascriptIdentifiers,
|
|
129273
129316
|
isFromUncheckedFile: true
|
|
129274
|
-
});
|
|
129317
|
+
}, compareCompletionEntries);
|
|
129275
129318
|
}
|
|
129276
129319
|
});
|
|
129277
129320
|
}
|
|
@@ -129695,7 +129738,7 @@ var ts;
|
|
|
129695
129738
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
129696
129739
|
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129697
129740
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
129698
|
-
|
|
129741
|
+
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129699
129742
|
}
|
|
129700
129743
|
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start));
|
|
129701
129744
|
// Prevent consumers of this map from having to worry about
|
|
@@ -141451,7 +141494,7 @@ var ts;
|
|
|
141451
141494
|
displayParts.push(ts.spacePart());
|
|
141452
141495
|
displayParts.push(ts.operatorPart(63 /* EqualsToken */));
|
|
141453
141496
|
displayParts.push(ts.spacePart());
|
|
141454
|
-
ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
|
|
141497
|
+
ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
|
|
141455
141498
|
}
|
|
141456
141499
|
if (symbolFlags & 384 /* Enum */) {
|
|
141457
141500
|
prefixNextMeaning();
|
|
@@ -152172,6 +152215,7 @@ var ts;
|
|
|
152172
152215
|
var errorCodes = [
|
|
152173
152216
|
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
152174
152217
|
ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
152218
|
+
ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
152175
152219
|
];
|
|
152176
152220
|
codefix.registerCodeFix({
|
|
152177
152221
|
errorCodes: errorCodes,
|
|
@@ -159982,6 +160026,9 @@ var ts;
|
|
|
159982
160026
|
TypeObject.prototype.isClass = function () {
|
|
159983
160027
|
return !!(ts.getObjectFlags(this) & 1 /* Class */);
|
|
159984
160028
|
};
|
|
160029
|
+
TypeObject.prototype.isIndexType = function () {
|
|
160030
|
+
return !!(this.flags & 4194304 /* Index */);
|
|
160031
|
+
};
|
|
159985
160032
|
Object.defineProperty(TypeObject.prototype, "typeArguments", {
|
|
159986
160033
|
/**
|
|
159987
160034
|
* This polyfills `referenceType.typeArguments` for API consumers
|
|
@@ -160014,6 +160061,16 @@ var ts;
|
|
|
160014
160061
|
SignatureObject.prototype.getReturnType = function () {
|
|
160015
160062
|
return this.checker.getReturnTypeOfSignature(this);
|
|
160016
160063
|
};
|
|
160064
|
+
SignatureObject.prototype.getTypeParameterAtPosition = function (pos) {
|
|
160065
|
+
var type = this.checker.getParameterType(this, pos);
|
|
160066
|
+
if (type.isIndexType() && ts.isThisTypeParameter(type.type)) {
|
|
160067
|
+
var constraint = type.type.getConstraint();
|
|
160068
|
+
if (constraint) {
|
|
160069
|
+
return this.checker.getIndexType(constraint);
|
|
160070
|
+
}
|
|
160071
|
+
}
|
|
160072
|
+
return type;
|
|
160073
|
+
};
|
|
160017
160074
|
SignatureObject.prototype.getDocumentationComment = function () {
|
|
160018
160075
|
return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
|
|
160019
160076
|
};
|
|
@@ -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[];
|