typescript 4.9.0-dev.20220920 → 4.9.0-dev.20220921
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 +151 -72
- package/lib/tsserver.js +322 -126
- package/lib/tsserverlibrary.js +322 -126
- package/lib/typescript.js +322 -126
- package/lib/typescriptServices.js +322 -126
- package/lib/typingsInstaller.js +157 -73
- package/package.json +1 -1
|
@@ -99,7 +99,7 @@ var ts;
|
|
|
99
99
|
// The following is baselined as a literal template type without intervention
|
|
100
100
|
/** The version of the TypeScript compiler release */
|
|
101
101
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
102
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
102
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220921");
|
|
103
103
|
/* @internal */
|
|
104
104
|
var Comparison;
|
|
105
105
|
(function (Comparison) {
|
|
@@ -3008,7 +3008,7 @@ var ts;
|
|
|
3008
3008
|
];
|
|
3009
3009
|
for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
|
|
3010
3010
|
var ctor = nodeConstructors_1[_i];
|
|
3011
|
-
if (!ts.hasProperty(ctor, "__debugKind")) {
|
|
3011
|
+
if (!ts.hasProperty(ctor.prototype, "__debugKind")) {
|
|
3012
3012
|
Object.defineProperties(ctor.prototype, {
|
|
3013
3013
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
3014
3014
|
__tsDebuggerDisplay: {
|
|
@@ -9123,6 +9123,7 @@ var ts;
|
|
|
9123
9123
|
_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
|
|
9124
9124
|
We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
|
|
9125
9125
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
9126
|
+
This_condition_will_always_return_0: diag(2845, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
9126
9127
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
9127
9128
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
9128
9129
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -10065,6 +10066,8 @@ var ts;
|
|
|
10065
10066
|
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
10066
10067
|
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
10067
10068
|
Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
|
|
10069
|
+
Use_0: diag(95174, ts.DiagnosticCategory.Message, "Use_0_95174", "Use `{0}`."),
|
|
10070
|
+
Use_Number_isNaN_in_all_conditions: diag(95175, ts.DiagnosticCategory.Message, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
|
|
10068
10071
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
10069
10072
|
Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
10070
10073
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -11887,12 +11890,36 @@ var ts;
|
|
|
11887
11890
|
pos++;
|
|
11888
11891
|
return token = 0 /* SyntaxKind.Unknown */;
|
|
11889
11892
|
}
|
|
11890
|
-
|
|
11893
|
+
var charAfterHash = codePointAt(text, pos + 1);
|
|
11894
|
+
if (charAfterHash === 92 /* CharacterCodes.backslash */) {
|
|
11891
11895
|
pos++;
|
|
11892
|
-
|
|
11896
|
+
var extendedCookedChar_1 = peekExtendedUnicodeEscape();
|
|
11897
|
+
if (extendedCookedChar_1 >= 0 && isIdentifierStart(extendedCookedChar_1, languageVersion)) {
|
|
11898
|
+
pos += 3;
|
|
11899
|
+
tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */;
|
|
11900
|
+
tokenValue = "#" + scanExtendedUnicodeEscape() + scanIdentifierParts();
|
|
11901
|
+
return token = 80 /* SyntaxKind.PrivateIdentifier */;
|
|
11902
|
+
}
|
|
11903
|
+
var cookedChar_1 = peekUnicodeEscape();
|
|
11904
|
+
if (cookedChar_1 >= 0 && isIdentifierStart(cookedChar_1, languageVersion)) {
|
|
11905
|
+
pos += 6;
|
|
11906
|
+
tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */;
|
|
11907
|
+
tokenValue = "#" + String.fromCharCode(cookedChar_1) + scanIdentifierParts();
|
|
11908
|
+
return token = 80 /* SyntaxKind.PrivateIdentifier */;
|
|
11909
|
+
}
|
|
11910
|
+
pos--;
|
|
11911
|
+
}
|
|
11912
|
+
if (isIdentifierStart(charAfterHash, languageVersion)) {
|
|
11913
|
+
pos++;
|
|
11914
|
+
// We're relying on scanIdentifier's behavior and adjusting the token kind after the fact.
|
|
11915
|
+
// Notably absent from this block is the fact that calling a function named "scanIdentifier",
|
|
11916
|
+
// but identifiers don't include '#', and that function doesn't deal with it at all.
|
|
11917
|
+
// This works because 'scanIdentifier' tries to reuse source characters and builds up substrings;
|
|
11918
|
+
// however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us.
|
|
11919
|
+
scanIdentifier(charAfterHash, languageVersion);
|
|
11893
11920
|
}
|
|
11894
11921
|
else {
|
|
11895
|
-
tokenValue =
|
|
11922
|
+
tokenValue = "#";
|
|
11896
11923
|
error(ts.Diagnostics.Invalid_character, pos++, charSize(ch));
|
|
11897
11924
|
}
|
|
11898
11925
|
return token = 80 /* SyntaxKind.PrivateIdentifier */;
|
|
@@ -33130,7 +33157,7 @@ var ts;
|
|
|
33130
33157
|
}
|
|
33131
33158
|
function parsePrivateIdentifier() {
|
|
33132
33159
|
var pos = getNodePos();
|
|
33133
|
-
var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.
|
|
33160
|
+
var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenValue()));
|
|
33134
33161
|
nextToken();
|
|
33135
33162
|
return finishNode(node, pos);
|
|
33136
33163
|
}
|
|
@@ -49763,6 +49790,7 @@ var ts;
|
|
|
49763
49790
|
var deferredGlobalOmitSymbol;
|
|
49764
49791
|
var deferredGlobalAwaitedSymbol;
|
|
49765
49792
|
var deferredGlobalBigIntType;
|
|
49793
|
+
var deferredGlobalNaNSymbol;
|
|
49766
49794
|
var deferredGlobalRecordSymbol;
|
|
49767
49795
|
var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
|
|
49768
49796
|
var flowLoopStart = 0;
|
|
@@ -60251,7 +60279,7 @@ var ts;
|
|
|
60251
60279
|
var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp);
|
|
60252
60280
|
// If the symbols are instances of one another with identical types - consider the symbols
|
|
60253
60281
|
// equivalent and just use the first one, which thus allows us to avoid eliding private
|
|
60254
|
-
// members when intersecting a (this-)instantiations of a class with
|
|
60282
|
+
// members when intersecting a (this-)instantiations of a class with its raw base or another instance
|
|
60255
60283
|
if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) {
|
|
60256
60284
|
// If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used
|
|
60257
60285
|
// to do when we recorded multiple distinct symbols so that we still get, eg, `Array<T>.length` printed
|
|
@@ -60299,7 +60327,11 @@ var ts;
|
|
|
60299
60327
|
}
|
|
60300
60328
|
}
|
|
60301
60329
|
}
|
|
60302
|
-
if (!singleProp ||
|
|
60330
|
+
if (!singleProp ||
|
|
60331
|
+
isUnion &&
|
|
60332
|
+
(propSet || checkFlags & 48 /* CheckFlags.Partial */) &&
|
|
60333
|
+
checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */) &&
|
|
60334
|
+
!(propSet && getCommonDeclarationsOfSymbols(ts.arrayFrom(propSet.values())))) {
|
|
60303
60335
|
// No property was found, or, in a union, a property has a private or protected declaration in one
|
|
60304
60336
|
// constituent, but is missing or has a different declaration in another constituent.
|
|
60305
60337
|
return undefined;
|
|
@@ -60401,6 +60433,33 @@ var ts;
|
|
|
60401
60433
|
}
|
|
60402
60434
|
return property;
|
|
60403
60435
|
}
|
|
60436
|
+
function getCommonDeclarationsOfSymbols(symbols) {
|
|
60437
|
+
var commonDeclarations;
|
|
60438
|
+
var _loop_14 = function (symbol) {
|
|
60439
|
+
if (!symbol.declarations) {
|
|
60440
|
+
return { value: undefined };
|
|
60441
|
+
}
|
|
60442
|
+
if (!commonDeclarations) {
|
|
60443
|
+
commonDeclarations = new ts.Set(symbol.declarations);
|
|
60444
|
+
return "continue";
|
|
60445
|
+
}
|
|
60446
|
+
commonDeclarations.forEach(function (declaration) {
|
|
60447
|
+
if (!ts.contains(symbol.declarations, declaration)) {
|
|
60448
|
+
commonDeclarations.delete(declaration);
|
|
60449
|
+
}
|
|
60450
|
+
});
|
|
60451
|
+
if (commonDeclarations.size === 0) {
|
|
60452
|
+
return { value: undefined };
|
|
60453
|
+
}
|
|
60454
|
+
};
|
|
60455
|
+
for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) {
|
|
60456
|
+
var symbol = symbols_3[_i];
|
|
60457
|
+
var state_4 = _loop_14(symbol);
|
|
60458
|
+
if (typeof state_4 === "object")
|
|
60459
|
+
return state_4.value;
|
|
60460
|
+
}
|
|
60461
|
+
return commonDeclarations;
|
|
60462
|
+
}
|
|
60404
60463
|
function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) {
|
|
60405
60464
|
var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
60406
60465
|
// We need to filter out partial properties in union types
|
|
@@ -61115,7 +61174,7 @@ var ts;
|
|
|
61115
61174
|
function getIndexInfosOfIndexSymbol(indexSymbol) {
|
|
61116
61175
|
if (indexSymbol.declarations) {
|
|
61117
61176
|
var indexInfos_4 = [];
|
|
61118
|
-
var
|
|
61177
|
+
var _loop_15 = function (declaration) {
|
|
61119
61178
|
if (declaration.parameters.length === 1) {
|
|
61120
61179
|
var parameter = declaration.parameters[0];
|
|
61121
61180
|
if (parameter.type) {
|
|
@@ -61129,7 +61188,7 @@ var ts;
|
|
|
61129
61188
|
};
|
|
61130
61189
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
61131
61190
|
var declaration = _a[_i];
|
|
61132
|
-
|
|
61191
|
+
_loop_15(declaration);
|
|
61133
61192
|
}
|
|
61134
61193
|
return indexInfos_4;
|
|
61135
61194
|
}
|
|
@@ -61146,7 +61205,7 @@ var ts;
|
|
|
61146
61205
|
var _a;
|
|
61147
61206
|
var inferences;
|
|
61148
61207
|
if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
|
|
61149
|
-
var
|
|
61208
|
+
var _loop_16 = function (declaration) {
|
|
61150
61209
|
if (declaration.parent.kind === 192 /* SyntaxKind.InferType */) {
|
|
61151
61210
|
// When an 'infer T' declaration is immediately contained in a type reference node
|
|
61152
61211
|
// (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
|
|
@@ -61210,7 +61269,7 @@ var ts;
|
|
|
61210
61269
|
};
|
|
61211
61270
|
for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
|
|
61212
61271
|
var declaration = _b[_i];
|
|
61213
|
-
|
|
61272
|
+
_loop_16(declaration);
|
|
61214
61273
|
}
|
|
61215
61274
|
}
|
|
61216
61275
|
return inferences && getIntersectionType(inferences);
|
|
@@ -61867,6 +61926,9 @@ var ts;
|
|
|
61867
61926
|
function getGlobalBigIntType() {
|
|
61868
61927
|
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
61869
61928
|
}
|
|
61929
|
+
function getGlobalNaNSymbol() {
|
|
61930
|
+
return (deferredGlobalNaNSymbol || (deferredGlobalNaNSymbol = getGlobalValueSymbol("NaN", /*reportErrors*/ false)));
|
|
61931
|
+
}
|
|
61870
61932
|
function getGlobalRecordSymbol() {
|
|
61871
61933
|
deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
|
|
61872
61934
|
return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
|
|
@@ -62107,7 +62169,7 @@ var ts;
|
|
|
62107
62169
|
var lastRequiredIndex = -1;
|
|
62108
62170
|
var firstRestIndex = -1;
|
|
62109
62171
|
var lastOptionalOrRestIndex = -1;
|
|
62110
|
-
var
|
|
62172
|
+
var _loop_17 = function (i) {
|
|
62111
62173
|
var type = elementTypes[i];
|
|
62112
62174
|
var flags = target.elementFlags[i];
|
|
62113
62175
|
if (flags & 8 /* ElementFlags.Variadic */) {
|
|
@@ -62137,9 +62199,9 @@ var ts;
|
|
|
62137
62199
|
}
|
|
62138
62200
|
};
|
|
62139
62201
|
for (var i = 0; i < elementTypes.length; i++) {
|
|
62140
|
-
var
|
|
62141
|
-
if (typeof
|
|
62142
|
-
return
|
|
62202
|
+
var state_5 = _loop_17(i);
|
|
62203
|
+
if (typeof state_5 === "object")
|
|
62204
|
+
return state_5.value;
|
|
62143
62205
|
}
|
|
62144
62206
|
// Turn optional elements preceding the last required element into required elements
|
|
62145
62207
|
for (var i = 0; i < lastRequiredIndex; i++) {
|
|
@@ -62167,7 +62229,7 @@ var ts;
|
|
|
62167
62229
|
if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) {
|
|
62168
62230
|
lastOptionalOrRestIndex = expandedFlags.length;
|
|
62169
62231
|
}
|
|
62170
|
-
expandedTypes.push(type);
|
|
62232
|
+
expandedTypes.push(flags & 2 /* ElementFlags.Optional */ ? addOptionality(type, /*isProperty*/ true) : type);
|
|
62171
62233
|
expandedFlags.push(flags);
|
|
62172
62234
|
if (expandedDeclarations && declaration) {
|
|
62173
62235
|
expandedDeclarations.push(declaration);
|
|
@@ -62333,7 +62395,7 @@ var ts;
|
|
|
62333
62395
|
var templates = ts.filter(types, isPatternLiteralType);
|
|
62334
62396
|
if (templates.length) {
|
|
62335
62397
|
var i = types.length;
|
|
62336
|
-
var
|
|
62398
|
+
var _loop_18 = function () {
|
|
62337
62399
|
i--;
|
|
62338
62400
|
var t = types[i];
|
|
62339
62401
|
if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
|
|
@@ -62341,7 +62403,7 @@ var ts;
|
|
|
62341
62403
|
}
|
|
62342
62404
|
};
|
|
62343
62405
|
while (i > 0) {
|
|
62344
|
-
|
|
62406
|
+
_loop_18();
|
|
62345
62407
|
}
|
|
62346
62408
|
}
|
|
62347
62409
|
}
|
|
@@ -62418,14 +62480,14 @@ var ts;
|
|
|
62418
62480
|
var namedUnions = [];
|
|
62419
62481
|
addNamedUnions(namedUnions, types);
|
|
62420
62482
|
var reducedTypes = [];
|
|
62421
|
-
var
|
|
62483
|
+
var _loop_19 = function (t) {
|
|
62422
62484
|
if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
|
|
62423
62485
|
reducedTypes.push(t);
|
|
62424
62486
|
}
|
|
62425
62487
|
};
|
|
62426
62488
|
for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
|
|
62427
62489
|
var t = typeSet_1[_i];
|
|
62428
|
-
|
|
62490
|
+
_loop_19(t);
|
|
62429
62491
|
}
|
|
62430
62492
|
if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
|
|
62431
62493
|
return namedUnions[0];
|
|
@@ -63655,7 +63717,7 @@ var ts;
|
|
|
63655
63717
|
var result;
|
|
63656
63718
|
var extraTypes;
|
|
63657
63719
|
var tailCount = 0;
|
|
63658
|
-
var
|
|
63720
|
+
var _loop_20 = function () {
|
|
63659
63721
|
if (tailCount === 1000) {
|
|
63660
63722
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63661
63723
|
result = errorType;
|
|
@@ -63776,10 +63838,10 @@ var ts;
|
|
|
63776
63838
|
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63777
63839
|
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63778
63840
|
while (true) {
|
|
63779
|
-
var
|
|
63780
|
-
if (typeof
|
|
63781
|
-
return
|
|
63782
|
-
if (
|
|
63841
|
+
var state_6 = _loop_20();
|
|
63842
|
+
if (typeof state_6 === "object")
|
|
63843
|
+
return state_6.value;
|
|
63844
|
+
if (state_6 === "break")
|
|
63783
63845
|
break;
|
|
63784
63846
|
}
|
|
63785
63847
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
@@ -66394,7 +66456,7 @@ var ts;
|
|
|
66394
66456
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66395
66457
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66396
66458
|
}
|
|
66397
|
-
var
|
|
66459
|
+
var _loop_21 = function (prop) {
|
|
66398
66460
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66399
66461
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66400
66462
|
if (reportErrors) {
|
|
@@ -66457,9 +66519,9 @@ var ts;
|
|
|
66457
66519
|
};
|
|
66458
66520
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66459
66521
|
var prop = _b[_i];
|
|
66460
|
-
var
|
|
66461
|
-
if (typeof
|
|
66462
|
-
return
|
|
66522
|
+
var state_7 = _loop_21(prop);
|
|
66523
|
+
if (typeof state_7 === "object")
|
|
66524
|
+
return state_7.value;
|
|
66463
66525
|
}
|
|
66464
66526
|
return false;
|
|
66465
66527
|
}
|
|
@@ -67450,11 +67512,11 @@ var ts;
|
|
|
67450
67512
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67451
67513
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67452
67514
|
var matchingTypes = [];
|
|
67453
|
-
var
|
|
67515
|
+
var _loop_22 = function (combination) {
|
|
67454
67516
|
var hasMatch = false;
|
|
67455
67517
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67456
67518
|
var type = _d[_c];
|
|
67457
|
-
var
|
|
67519
|
+
var _loop_23 = function (i) {
|
|
67458
67520
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67459
67521
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67460
67522
|
if (!targetProperty)
|
|
@@ -67470,8 +67532,8 @@ var ts;
|
|
|
67470
67532
|
}
|
|
67471
67533
|
};
|
|
67472
67534
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67473
|
-
var
|
|
67474
|
-
switch (
|
|
67535
|
+
var state_9 = _loop_23(i);
|
|
67536
|
+
switch (state_9) {
|
|
67475
67537
|
case "continue-outer": continue outer;
|
|
67476
67538
|
}
|
|
67477
67539
|
}
|
|
@@ -67484,9 +67546,9 @@ var ts;
|
|
|
67484
67546
|
};
|
|
67485
67547
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67486
67548
|
var combination = discriminantCombinations_1[_a];
|
|
67487
|
-
var
|
|
67488
|
-
if (typeof
|
|
67489
|
-
return
|
|
67549
|
+
var state_8 = _loop_22(combination);
|
|
67550
|
+
if (typeof state_8 === "object")
|
|
67551
|
+
return state_8.value;
|
|
67490
67552
|
}
|
|
67491
67553
|
// Compare the remaining non-discriminant properties of each match.
|
|
67492
67554
|
var result = -1 /* Ternary.True */;
|
|
@@ -68191,7 +68253,7 @@ var ts;
|
|
|
68191
68253
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
68192
68254
|
links.variances = ts.emptyArray;
|
|
68193
68255
|
var variances = [];
|
|
68194
|
-
var
|
|
68256
|
+
var _loop_24 = function (tp) {
|
|
68195
68257
|
var modifiers = getVarianceModifiers(tp);
|
|
68196
68258
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68197
68259
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68229,7 +68291,7 @@ var ts;
|
|
|
68229
68291
|
};
|
|
68230
68292
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68231
68293
|
var tp = typeParameters_2[_i];
|
|
68232
|
-
|
|
68294
|
+
_loop_24(tp);
|
|
68233
68295
|
}
|
|
68234
68296
|
links.variances = variances;
|
|
68235
68297
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -68821,7 +68883,8 @@ var ts;
|
|
|
68821
68883
|
function getOptionalType(type, isProperty) {
|
|
68822
68884
|
if (isProperty === void 0) { isProperty = false; }
|
|
68823
68885
|
ts.Debug.assert(strictNullChecks);
|
|
68824
|
-
|
|
68886
|
+
var missingOrUndefined = isProperty ? missingType : undefinedType;
|
|
68887
|
+
return type.flags & 32768 /* TypeFlags.Undefined */ || type.flags & 1048576 /* TypeFlags.Union */ && type.types[0] === missingOrUndefined ? type : getUnionType([type, missingOrUndefined]);
|
|
68825
68888
|
}
|
|
68826
68889
|
function getGlobalNonNullableTypeInstantiation(type) {
|
|
68827
68890
|
if (!deferredGlobalNonNullableTypeAlias) {
|
|
@@ -70186,7 +70249,7 @@ var ts;
|
|
|
70186
70249
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70187
70250
|
// succeed. That would be a pointless and confusing outcome.
|
|
70188
70251
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70189
|
-
var
|
|
70252
|
+
var _loop_25 = function (i) {
|
|
70190
70253
|
var source_1 = matches ? matches[i] : neverType;
|
|
70191
70254
|
var target_3 = types[i];
|
|
70192
70255
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70236,7 +70299,7 @@ var ts;
|
|
|
70236
70299
|
inferFromTypes(source_1, target_3);
|
|
70237
70300
|
};
|
|
70238
70301
|
for (var i = 0; i < types.length; i++) {
|
|
70239
|
-
|
|
70302
|
+
_loop_25(i);
|
|
70240
70303
|
}
|
|
70241
70304
|
}
|
|
70242
70305
|
}
|
|
@@ -70700,7 +70763,7 @@ var ts;
|
|
|
70700
70763
|
return name;
|
|
70701
70764
|
}
|
|
70702
70765
|
}
|
|
70703
|
-
if (ts.hasOnlyExpressionInitializer(declaration)) {
|
|
70766
|
+
if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
|
|
70704
70767
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
70705
70768
|
return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
|
|
70706
70769
|
}
|
|
@@ -70760,7 +70823,7 @@ var ts;
|
|
|
70760
70823
|
function mapTypesByKeyProperty(types, name) {
|
|
70761
70824
|
var map = new ts.Map();
|
|
70762
70825
|
var count = 0;
|
|
70763
|
-
var
|
|
70826
|
+
var _loop_26 = function (type) {
|
|
70764
70827
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70765
70828
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70766
70829
|
if (discriminant) {
|
|
@@ -70786,9 +70849,9 @@ var ts;
|
|
|
70786
70849
|
};
|
|
70787
70850
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70788
70851
|
var type = types_15[_i];
|
|
70789
|
-
var
|
|
70790
|
-
if (typeof
|
|
70791
|
-
return
|
|
70852
|
+
var state_10 = _loop_26(type);
|
|
70853
|
+
if (typeof state_10 === "object")
|
|
70854
|
+
return state_10.value;
|
|
70792
70855
|
}
|
|
70793
70856
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70794
70857
|
}
|
|
@@ -77243,7 +77306,7 @@ var ts;
|
|
|
77243
77306
|
if (spreadIndex >= 0) {
|
|
77244
77307
|
// Create synthetic arguments from spreads of tuple types.
|
|
77245
77308
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77246
|
-
var
|
|
77309
|
+
var _loop_27 = function (i) {
|
|
77247
77310
|
var arg = args[i];
|
|
77248
77311
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77249
77312
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77260,7 +77323,7 @@ var ts;
|
|
|
77260
77323
|
}
|
|
77261
77324
|
};
|
|
77262
77325
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77263
|
-
|
|
77326
|
+
_loop_27(i);
|
|
77264
77327
|
}
|
|
77265
77328
|
return effectiveArgs_1;
|
|
77266
77329
|
}
|
|
@@ -77589,7 +77652,7 @@ var ts;
|
|
|
77589
77652
|
var min_3 = Number.MAX_VALUE;
|
|
77590
77653
|
var minIndex = 0;
|
|
77591
77654
|
var i_1 = 0;
|
|
77592
|
-
var
|
|
77655
|
+
var _loop_28 = function (c) {
|
|
77593
77656
|
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
|
77594
77657
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77595
77658
|
if (diags_2) {
|
|
@@ -77607,7 +77670,7 @@ var ts;
|
|
|
77607
77670
|
};
|
|
77608
77671
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77609
77672
|
var c = candidatesForArgumentError_1[_a];
|
|
77610
|
-
|
|
77673
|
+
_loop_28(c);
|
|
77611
77674
|
}
|
|
77612
77675
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77613
77676
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77765,7 +77828,7 @@ var ts;
|
|
|
77765
77828
|
}
|
|
77766
77829
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77767
77830
|
var parameters = [];
|
|
77768
|
-
var
|
|
77831
|
+
var _loop_29 = function (i) {
|
|
77769
77832
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77770
77833
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77771
77834
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77773,7 +77836,7 @@ var ts;
|
|
|
77773
77836
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77774
77837
|
};
|
|
77775
77838
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77776
|
-
|
|
77839
|
+
_loop_29(i);
|
|
77777
77840
|
}
|
|
77778
77841
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77779
77842
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -80555,6 +80618,7 @@ var ts;
|
|
|
80555
80618
|
var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */;
|
|
80556
80619
|
error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
80557
80620
|
}
|
|
80621
|
+
checkNaNEquality(errorNode, operator, left, right);
|
|
80558
80622
|
reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
|
|
80559
80623
|
return booleanType;
|
|
80560
80624
|
case 102 /* SyntaxKind.InstanceOfKeyword */:
|
|
@@ -80760,6 +80824,26 @@ var ts;
|
|
|
80760
80824
|
return undefined;
|
|
80761
80825
|
}
|
|
80762
80826
|
}
|
|
80827
|
+
function checkNaNEquality(errorNode, operator, left, right) {
|
|
80828
|
+
var isLeftNaN = isGlobalNaN(ts.skipParentheses(left));
|
|
80829
|
+
var isRightNaN = isGlobalNaN(ts.skipParentheses(right));
|
|
80830
|
+
if (isLeftNaN || isRightNaN) {
|
|
80831
|
+
var err = error(errorNode, ts.Diagnostics.This_condition_will_always_return_0, ts.tokenToString(operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? 95 /* SyntaxKind.FalseKeyword */ : 110 /* SyntaxKind.TrueKeyword */));
|
|
80832
|
+
if (isLeftNaN && isRightNaN)
|
|
80833
|
+
return;
|
|
80834
|
+
var operatorString = operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? ts.tokenToString(53 /* SyntaxKind.ExclamationToken */) : "";
|
|
80835
|
+
var location = isLeftNaN ? right : left;
|
|
80836
|
+
var expression = ts.skipParentheses(location);
|
|
80837
|
+
ts.addRelatedInfo(err, ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_mean_0, "".concat(operatorString, "Number.isNaN(").concat(ts.isEntityNameExpression(expression) ? ts.entityNameToString(expression) : "...", ")")));
|
|
80838
|
+
}
|
|
80839
|
+
}
|
|
80840
|
+
function isGlobalNaN(expr) {
|
|
80841
|
+
if (ts.isIdentifier(expr) && expr.escapedText === "NaN") {
|
|
80842
|
+
var globalNaNSymbol = getGlobalNaNSymbol();
|
|
80843
|
+
return !!globalNaNSymbol && globalNaNSymbol === getResolvedSymbol(expr);
|
|
80844
|
+
}
|
|
80845
|
+
return false;
|
|
80846
|
+
}
|
|
80763
80847
|
}
|
|
80764
80848
|
function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
|
|
80765
80849
|
var effectiveLeft = leftType;
|
|
@@ -81797,7 +81881,7 @@ var ts;
|
|
|
81797
81881
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
81798
81882
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
81799
81883
|
var indexSignatureMap_1 = new ts.Map();
|
|
81800
|
-
var
|
|
81884
|
+
var _loop_30 = function (declaration) {
|
|
81801
81885
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
81802
81886
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
81803
81887
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -81812,7 +81896,7 @@ var ts;
|
|
|
81812
81896
|
};
|
|
81813
81897
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
81814
81898
|
var declaration = _a[_i];
|
|
81815
|
-
|
|
81899
|
+
_loop_30(declaration);
|
|
81816
81900
|
}
|
|
81817
81901
|
indexSignatureMap_1.forEach(function (entry) {
|
|
81818
81902
|
if (entry.declarations.length > 1) {
|
|
@@ -85412,7 +85496,7 @@ var ts;
|
|
|
85412
85496
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85413
85497
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85414
85498
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85415
|
-
var
|
|
85499
|
+
var _loop_31 = function (info) {
|
|
85416
85500
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85417
85501
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85418
85502
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85429,7 +85513,7 @@ var ts;
|
|
|
85429
85513
|
};
|
|
85430
85514
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85431
85515
|
var info = indexInfos_9[_i];
|
|
85432
|
-
|
|
85516
|
+
_loop_31(info);
|
|
85433
85517
|
}
|
|
85434
85518
|
}
|
|
85435
85519
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85437,7 +85521,7 @@ var ts;
|
|
|
85437
85521
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85438
85522
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85439
85523
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85440
|
-
var
|
|
85524
|
+
var _loop_32 = function (info) {
|
|
85441
85525
|
if (info === checkInfo)
|
|
85442
85526
|
return "continue";
|
|
85443
85527
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85452,7 +85536,7 @@ var ts;
|
|
|
85452
85536
|
};
|
|
85453
85537
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85454
85538
|
var info = indexInfos_10[_i];
|
|
85455
|
-
|
|
85539
|
+
_loop_32(info);
|
|
85456
85540
|
}
|
|
85457
85541
|
}
|
|
85458
85542
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85772,7 +85856,7 @@ var ts;
|
|
|
85772
85856
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
85773
85857
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
85774
85858
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
85775
|
-
var
|
|
85859
|
+
var _loop_33 = function (member) {
|
|
85776
85860
|
if (ts.hasAmbientModifier(member)) {
|
|
85777
85861
|
return "continue";
|
|
85778
85862
|
}
|
|
@@ -85789,7 +85873,7 @@ var ts;
|
|
|
85789
85873
|
};
|
|
85790
85874
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
85791
85875
|
var member = _a[_i];
|
|
85792
|
-
|
|
85876
|
+
_loop_33(member);
|
|
85793
85877
|
}
|
|
85794
85878
|
}
|
|
85795
85879
|
/**
|
|
@@ -85877,7 +85961,7 @@ var ts;
|
|
|
85877
85961
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
85878
85962
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
85879
85963
|
var issuedMemberError = false;
|
|
85880
|
-
var
|
|
85964
|
+
var _loop_34 = function (member) {
|
|
85881
85965
|
if (ts.isStatic(member)) {
|
|
85882
85966
|
return "continue";
|
|
85883
85967
|
}
|
|
@@ -85896,7 +85980,7 @@ var ts;
|
|
|
85896
85980
|
};
|
|
85897
85981
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
85898
85982
|
var member = _a[_i];
|
|
85899
|
-
|
|
85983
|
+
_loop_34(member);
|
|
85900
85984
|
}
|
|
85901
85985
|
if (!issuedMemberError) {
|
|
85902
85986
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -85967,7 +86051,7 @@ var ts;
|
|
|
85967
86051
|
var _a, _b, _c, _d;
|
|
85968
86052
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
85969
86053
|
var baseProperties = getPropertiesOfType(baseType);
|
|
85970
|
-
var
|
|
86054
|
+
var _loop_35 = function (baseProperty) {
|
|
85971
86055
|
var base = getTargetSymbol(baseProperty);
|
|
85972
86056
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
85973
86057
|
return "continue";
|
|
@@ -86077,8 +86161,8 @@ var ts;
|
|
|
86077
86161
|
};
|
|
86078
86162
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86079
86163
|
var baseProperty = baseProperties_1[_i];
|
|
86080
|
-
var
|
|
86081
|
-
switch (
|
|
86164
|
+
var state_11 = _loop_35(baseProperty);
|
|
86165
|
+
switch (state_11) {
|
|
86082
86166
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86083
86167
|
}
|
|
86084
86168
|
}
|
|
@@ -124921,7 +125005,7 @@ var ts;
|
|
|
124921
125005
|
});
|
|
124922
125006
|
// Sort by paths closest to importing file Name directory
|
|
124923
125007
|
var sortedPaths = [];
|
|
124924
|
-
var
|
|
125008
|
+
var _loop_36 = function (directory) {
|
|
124925
125009
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
124926
125010
|
var pathsInDirectory;
|
|
124927
125011
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -124945,9 +125029,9 @@ var ts;
|
|
|
124945
125029
|
};
|
|
124946
125030
|
var out_directory_1;
|
|
124947
125031
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
124948
|
-
var
|
|
125032
|
+
var state_12 = _loop_36(directory);
|
|
124949
125033
|
directory = out_directory_1;
|
|
124950
|
-
if (
|
|
125034
|
+
if (state_12 === "break")
|
|
124951
125035
|
break;
|
|
124952
125036
|
}
|
|
124953
125037
|
if (allFileNames.size) {
|
|
@@ -125016,7 +125100,7 @@ var ts;
|
|
|
125016
125100
|
}
|
|
125017
125101
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125018
125102
|
for (var key in paths) {
|
|
125019
|
-
var
|
|
125103
|
+
var _loop_37 = function (patternText_1) {
|
|
125020
125104
|
var pattern = ts.normalizePath(patternText_1);
|
|
125021
125105
|
var indexOfStar = pattern.indexOf("*");
|
|
125022
125106
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125083,9 +125167,9 @@ var ts;
|
|
|
125083
125167
|
};
|
|
125084
125168
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125085
125169
|
var patternText_1 = _a[_i];
|
|
125086
|
-
var
|
|
125087
|
-
if (typeof
|
|
125088
|
-
return
|
|
125170
|
+
var state_13 = _loop_37(patternText_1);
|
|
125171
|
+
if (typeof state_13 === "object")
|
|
125172
|
+
return state_13.value;
|
|
125089
125173
|
}
|
|
125090
125174
|
}
|
|
125091
125175
|
function validateEnding(_a) {
|
|
@@ -135424,7 +135508,7 @@ var ts;
|
|
|
135424
135508
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
135425
135509
|
}
|
|
135426
135510
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
135427
|
-
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag,
|
|
135511
|
+
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importStatementCompletion = completionData.importStatementCompletion, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
135428
135512
|
// Verify if the file is JSX language variant
|
|
135429
135513
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) {
|
|
135430
135514
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -135438,7 +135522,7 @@ var ts;
|
|
|
135438
135522
|
return undefined;
|
|
135439
135523
|
}
|
|
135440
135524
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
135441
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer,
|
|
135525
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
135442
135526
|
if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) {
|
|
135443
135527
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
135444
135528
|
var keywordEntry = _a[_i];
|
|
@@ -135556,7 +135640,7 @@ var ts;
|
|
|
135556
135640
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
135557
135641
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority };
|
|
135558
135642
|
}
|
|
135559
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer,
|
|
135643
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
135560
135644
|
var _a, _b;
|
|
135561
135645
|
var insertText;
|
|
135562
135646
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
@@ -135612,8 +135696,8 @@ var ts;
|
|
|
135612
135696
|
}
|
|
135613
135697
|
if (originIsResolvedExport(origin)) {
|
|
135614
135698
|
sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
|
|
135615
|
-
if (
|
|
135616
|
-
(_a = getInsertTextAndReplacementSpanForImportCompletion(name,
|
|
135699
|
+
if (importStatementCompletion) {
|
|
135700
|
+
(_a = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
|
|
135617
135701
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
135618
135702
|
}
|
|
135619
135703
|
}
|
|
@@ -135668,7 +135752,7 @@ var ts;
|
|
|
135668
135752
|
}
|
|
135669
135753
|
if (originIsExport(origin) || originIsResolvedExport(origin)) {
|
|
135670
135754
|
data = originToCompletionEntryData(origin);
|
|
135671
|
-
hasAction = !
|
|
135755
|
+
hasAction = !importStatementCompletion;
|
|
135672
135756
|
}
|
|
135673
135757
|
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
|
135674
135758
|
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
|
@@ -135691,7 +135775,7 @@ var ts;
|
|
|
135691
135775
|
labelDetails: labelDetails,
|
|
135692
135776
|
isSnippet: isSnippet,
|
|
135693
135777
|
isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
|
|
135694
|
-
isImportStatementCompletion: !!
|
|
135778
|
+
isImportStatementCompletion: !!importStatementCompletion || undefined,
|
|
135695
135779
|
data: data,
|
|
135696
135780
|
};
|
|
135697
135781
|
}
|
|
@@ -136063,19 +136147,16 @@ var ts;
|
|
|
136063
136147
|
};
|
|
136064
136148
|
return unresolvedOrigin;
|
|
136065
136149
|
}
|
|
136066
|
-
function getInsertTextAndReplacementSpanForImportCompletion(name,
|
|
136067
|
-
var
|
|
136068
|
-
var sourceFile = importCompletionNode.getSourceFile();
|
|
136069
|
-
var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile);
|
|
136150
|
+
function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences) {
|
|
136151
|
+
var replacementSpan = importStatementCompletion.replacementSpan;
|
|
136070
136152
|
var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
|
|
136071
136153
|
var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ :
|
|
136072
136154
|
origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ :
|
|
136073
136155
|
0 /* ExportKind.Named */;
|
|
136074
136156
|
var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
|
|
136075
136157
|
var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
|
|
136076
|
-
var
|
|
136077
|
-
var
|
|
136078
|
-
var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : " ";
|
|
136158
|
+
var isImportSpecifierTypeOnly = importStatementCompletion.couldBeTypeOnlyImportSpecifier;
|
|
136159
|
+
var topLevelTypeOnlyText = importStatementCompletion.isTopLevelTypeOnly ? " ".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : " ";
|
|
136079
136160
|
var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : "";
|
|
136080
136161
|
var suffix = useSemicolons ? ";" : "";
|
|
136081
136162
|
switch (importKind) {
|
|
@@ -136109,7 +136190,7 @@ var ts;
|
|
|
136109
136190
|
return CompletionSource.TypeOnlyAlias;
|
|
136110
136191
|
}
|
|
136111
136192
|
}
|
|
136112
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer,
|
|
136193
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
136113
136194
|
var _a;
|
|
136114
136195
|
var start = ts.timestamp();
|
|
136115
136196
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -136130,7 +136211,7 @@ var ts;
|
|
|
136130
136211
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
136131
136212
|
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
136132
136213
|
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
|
|
136133
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer,
|
|
136214
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
136134
136215
|
if (!entry) {
|
|
136135
136216
|
continue;
|
|
136136
136217
|
}
|
|
@@ -136321,7 +136402,7 @@ var ts;
|
|
|
136321
136402
|
Completions.createCompletionDetails = createCompletionDetails;
|
|
136322
136403
|
function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken) {
|
|
136323
136404
|
if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
|
|
136324
|
-
if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).
|
|
136405
|
+
if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementSpan) {
|
|
136325
136406
|
// Import statement completion: 'import c|'
|
|
136326
136407
|
return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
|
|
136327
136408
|
}
|
|
@@ -136522,34 +136603,34 @@ var ts;
|
|
|
136522
136603
|
var isStartingCloseTag = false;
|
|
136523
136604
|
var isJsxInitializer = false;
|
|
136524
136605
|
var isJsxIdentifierExpected = false;
|
|
136525
|
-
var
|
|
136606
|
+
var importStatementCompletion;
|
|
136526
136607
|
var location = ts.getTouchingPropertyName(sourceFile, position);
|
|
136527
136608
|
var keywordFilters = 0 /* KeywordCompletionFilters.None */;
|
|
136528
136609
|
var isNewIdentifierLocation = false;
|
|
136529
136610
|
var flags = 0 /* CompletionInfoFlags.None */;
|
|
136530
136611
|
if (contextToken) {
|
|
136531
|
-
var
|
|
136532
|
-
|
|
136533
|
-
|
|
136534
|
-
if (importStatementCompletion.isKeywordOnlyCompletion) {
|
|
136612
|
+
var importStatementCompletionInfo = getImportStatementCompletionInfo(contextToken);
|
|
136613
|
+
if (importStatementCompletionInfo.keywordCompletion) {
|
|
136614
|
+
if (importStatementCompletionInfo.isKeywordOnlyCompletion) {
|
|
136535
136615
|
return {
|
|
136536
136616
|
kind: 4 /* CompletionDataKind.Keywords */,
|
|
136537
|
-
keywordCompletions: [keywordToCompletionEntry(
|
|
136538
|
-
isNewIdentifierLocation: isNewIdentifierLocation,
|
|
136617
|
+
keywordCompletions: [keywordToCompletionEntry(importStatementCompletionInfo.keywordCompletion)],
|
|
136618
|
+
isNewIdentifierLocation: importStatementCompletionInfo.isNewIdentifierLocation,
|
|
136539
136619
|
};
|
|
136540
136620
|
}
|
|
136541
|
-
keywordFilters = keywordFiltersFromSyntaxKind(
|
|
136621
|
+
keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletionInfo.keywordCompletion);
|
|
136542
136622
|
}
|
|
136543
|
-
if (
|
|
136623
|
+
if (importStatementCompletionInfo.replacementSpan && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
|
|
136544
136624
|
// Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier`
|
|
136545
136625
|
// added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature
|
|
136546
136626
|
// is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
|
|
136547
136627
|
// to opt in with the `includeCompletionsForImportStatements` user preference.
|
|
136548
|
-
importCompletionNode = importStatementCompletion.replacementNode;
|
|
136549
136628
|
flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */;
|
|
136629
|
+
importStatementCompletion = importStatementCompletionInfo;
|
|
136630
|
+
isNewIdentifierLocation = importStatementCompletionInfo.isNewIdentifierLocation;
|
|
136550
136631
|
}
|
|
136551
136632
|
// Bail out if this is a known invalid completion location
|
|
136552
|
-
if (!
|
|
136633
|
+
if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
|
|
136553
136634
|
log("Returning an empty list because completion was requested in an invalid position.");
|
|
136554
136635
|
return keywordFilters
|
|
136555
136636
|
? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierDefinitionLocation())
|
|
@@ -136595,7 +136676,7 @@ var ts;
|
|
|
136595
136676
|
return undefined;
|
|
136596
136677
|
}
|
|
136597
136678
|
}
|
|
136598
|
-
else if (!
|
|
136679
|
+
else if (!importStatementCompletion) {
|
|
136599
136680
|
// <UI.Test /* completion position */ />
|
|
136600
136681
|
// If the tagname is a property access expression, we will then walk up to the top most of property access expression.
|
|
136601
136682
|
// Then, try to get a JSX container and its associated attributes type.
|
|
@@ -136738,7 +136819,7 @@ var ts;
|
|
|
136738
136819
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
136739
136820
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
136740
136821
|
isRightOfOpenTag: isRightOfOpenTag,
|
|
136741
|
-
|
|
136822
|
+
importStatementCompletion: importStatementCompletion,
|
|
136742
136823
|
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
|
|
136743
136824
|
flags: flags,
|
|
136744
136825
|
};
|
|
@@ -136992,7 +137073,7 @@ var ts;
|
|
|
136992
137073
|
return 1 /* GlobalsSearch.Success */;
|
|
136993
137074
|
}
|
|
136994
137075
|
function tryGetImportCompletionSymbols() {
|
|
136995
|
-
if (!
|
|
137076
|
+
if (!importStatementCompletion)
|
|
136996
137077
|
return 0 /* GlobalsSearch.Continue */;
|
|
136997
137078
|
isNewIdentifierLocation = true;
|
|
136998
137079
|
collectAutoImports();
|
|
@@ -137075,7 +137156,7 @@ var ts;
|
|
|
137075
137156
|
}
|
|
137076
137157
|
function shouldOfferImportCompletions() {
|
|
137077
137158
|
// If already typing an import statement, provide completions for it.
|
|
137078
|
-
if (
|
|
137159
|
+
if (importStatementCompletion)
|
|
137079
137160
|
return true;
|
|
137080
137161
|
// If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols
|
|
137081
137162
|
if (isNonContextualObjectLiteral)
|
|
@@ -137105,7 +137186,7 @@ var ts;
|
|
|
137105
137186
|
}
|
|
137106
137187
|
function isTypeOnlyCompletion() {
|
|
137107
137188
|
return insideJsDocTagTypeExpression
|
|
137108
|
-
|| !!
|
|
137189
|
+
|| !!importStatementCompletion && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
|
|
137109
137190
|
|| !isContextTokenValueLocation(contextToken) &&
|
|
137110
137191
|
(ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
|
|
137111
137192
|
|| ts.isPartOfTypeNode(location)
|
|
@@ -137155,8 +137236,7 @@ var ts;
|
|
|
137155
137236
|
flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */;
|
|
137156
137237
|
// import { type | -> token text should be blank
|
|
137157
137238
|
var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
|
|
137158
|
-
&&
|
|
137159
|
-
&& couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
|
|
137239
|
+
&& importStatementCompletion;
|
|
137160
137240
|
var lowerCaseTokenText = isAfterTypeOnlyImportSpecifierModifier ? "" :
|
|
137161
137241
|
previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
|
|
137162
137242
|
"";
|
|
@@ -137164,14 +137244,14 @@ var ts;
|
|
|
137164
137244
|
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
|
|
137165
137245
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
137166
137246
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
137167
|
-
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!
|
|
137247
|
+
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importStatementCompletion, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
137168
137248
|
exportInfo.search(sourceFile.path,
|
|
137169
137249
|
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
|
137170
137250
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
137171
137251
|
return false;
|
|
137172
137252
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
137173
137253
|
return false;
|
|
137174
|
-
if (!isTypeOnlyLocation && !
|
|
137254
|
+
if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & 111551 /* SymbolFlags.Value */))
|
|
137175
137255
|
return false;
|
|
137176
137256
|
if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */)))
|
|
137177
137257
|
return false;
|
|
@@ -137252,7 +137332,7 @@ var ts;
|
|
|
137252
137332
|
return;
|
|
137253
137333
|
}
|
|
137254
137334
|
symbolToOriginInfoMap[symbols.length] = origin;
|
|
137255
|
-
symbolToSortTextMap[symbolId] =
|
|
137335
|
+
symbolToSortTextMap[symbolId] = importStatementCompletion ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
|
|
137256
137336
|
symbols.push(symbol);
|
|
137257
137337
|
}
|
|
137258
137338
|
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
|
|
@@ -138519,6 +138599,7 @@ var ts;
|
|
|
138519
138599
|
return undefined;
|
|
138520
138600
|
}
|
|
138521
138601
|
function getImportStatementCompletionInfo(contextToken) {
|
|
138602
|
+
var _a, _b, _c;
|
|
138522
138603
|
var keywordCompletion;
|
|
138523
138604
|
var isKeywordOnlyCompletion = false;
|
|
138524
138605
|
var candidate = getCandidate();
|
|
@@ -138526,9 +138607,9 @@ var ts;
|
|
|
138526
138607
|
isKeywordOnlyCompletion: isKeywordOnlyCompletion,
|
|
138527
138608
|
keywordCompletion: keywordCompletion,
|
|
138528
138609
|
isNewIdentifierLocation: !!(candidate || keywordCompletion === 154 /* SyntaxKind.TypeKeyword */),
|
|
138529
|
-
|
|
138530
|
-
|
|
138531
|
-
|
|
138610
|
+
isTopLevelTypeOnly: !!((_b = (_a = ts.tryCast(candidate, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || !!((_c = ts.tryCast(candidate, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly),
|
|
138611
|
+
couldBeTypeOnlyImportSpecifier: !!candidate && couldBeTypeOnlyImportSpecifier(candidate, contextToken),
|
|
138612
|
+
replacementSpan: getSingleLineReplacementSpanForImportCompletionNode(candidate),
|
|
138532
138613
|
};
|
|
138533
138614
|
function getCandidate() {
|
|
138534
138615
|
var parent = contextToken.parent;
|
|
@@ -138570,14 +138651,71 @@ var ts;
|
|
|
138570
138651
|
return undefined;
|
|
138571
138652
|
}
|
|
138572
138653
|
}
|
|
138654
|
+
function getSingleLineReplacementSpanForImportCompletionNode(node) {
|
|
138655
|
+
var _a, _b, _c;
|
|
138656
|
+
if (!node)
|
|
138657
|
+
return undefined;
|
|
138658
|
+
var top = (_a = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration))) !== null && _a !== void 0 ? _a : node;
|
|
138659
|
+
var sourceFile = top.getSourceFile();
|
|
138660
|
+
if (ts.rangeIsOnSingleLine(top, sourceFile)) {
|
|
138661
|
+
return ts.createTextSpanFromNode(top, sourceFile);
|
|
138662
|
+
}
|
|
138663
|
+
// ImportKeyword was necessarily on one line; ImportSpecifier was necessarily parented in an ImportDeclaration
|
|
138664
|
+
ts.Debug.assert(top.kind !== 100 /* SyntaxKind.ImportKeyword */ && top.kind !== 273 /* SyntaxKind.ImportSpecifier */);
|
|
138665
|
+
// Guess which point in the import might actually be a later statement parsed as part of the import
|
|
138666
|
+
// during parser recovery - either in the middle of named imports, or the module specifier.
|
|
138667
|
+
var potentialSplitPoint = top.kind === 269 /* SyntaxKind.ImportDeclaration */
|
|
138668
|
+
? (_c = getPotentiallyInvalidImportSpecifier((_b = top.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings)) !== null && _c !== void 0 ? _c : top.moduleSpecifier
|
|
138669
|
+
: top.moduleReference;
|
|
138670
|
+
var withoutModuleSpecifier = {
|
|
138671
|
+
pos: top.getFirstToken().getStart(),
|
|
138672
|
+
end: potentialSplitPoint.pos,
|
|
138673
|
+
};
|
|
138674
|
+
// The module specifier/reference was previously found to be missing, empty, or
|
|
138675
|
+
// not a string literal - in this last case, it's likely that statement on a following
|
|
138676
|
+
// line was parsed as the module specifier of a partially-typed import, e.g.
|
|
138677
|
+
// import Foo|
|
|
138678
|
+
// interface Blah {}
|
|
138679
|
+
// This appears to be a multiline-import, and editors can't replace multiple lines.
|
|
138680
|
+
// But if everything but the "module specifier" is on one line, by this point we can
|
|
138681
|
+
// assume that the "module specifier" is actually just another statement, and return
|
|
138682
|
+
// the single-line range of the import excluding that probable statement.
|
|
138683
|
+
if (ts.rangeIsOnSingleLine(withoutModuleSpecifier, sourceFile)) {
|
|
138684
|
+
return ts.createTextSpanFromRange(withoutModuleSpecifier);
|
|
138685
|
+
}
|
|
138686
|
+
}
|
|
138687
|
+
// Tries to identify the first named import that is not really a named import, but rather
|
|
138688
|
+
// just parser recovery for a situation like:
|
|
138689
|
+
// import { Foo|
|
|
138690
|
+
// interface Bar {}
|
|
138691
|
+
// in which `Foo`, `interface`, and `Bar` are all parsed as import specifiers. The caller
|
|
138692
|
+
// will also check if this token is on a separate line from the rest of the import.
|
|
138693
|
+
function getPotentiallyInvalidImportSpecifier(namedBindings) {
|
|
138694
|
+
var _a;
|
|
138695
|
+
return ts.find((_a = ts.tryCast(namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements, function (e) {
|
|
138696
|
+
var _a;
|
|
138697
|
+
return !e.propertyName &&
|
|
138698
|
+
ts.isStringANonContextualKeyword(e.name.text) &&
|
|
138699
|
+
((_a = ts.findPrecedingToken(e.name.pos, namedBindings.getSourceFile(), namedBindings)) === null || _a === void 0 ? void 0 : _a.kind) !== 27 /* SyntaxKind.CommaToken */;
|
|
138700
|
+
});
|
|
138701
|
+
}
|
|
138573
138702
|
function couldBeTypeOnlyImportSpecifier(importSpecifier, contextToken) {
|
|
138574
138703
|
return ts.isImportSpecifier(importSpecifier)
|
|
138575
138704
|
&& (importSpecifier.isTypeOnly || contextToken === importSpecifier.name && ts.isTypeKeywordTokenOrIdentifier(contextToken));
|
|
138576
138705
|
}
|
|
138577
138706
|
function canCompleteFromNamedBindings(namedBindings) {
|
|
138578
|
-
|
|
138579
|
-
|
|
138580
|
-
|
|
138707
|
+
if (!isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier) || namedBindings.parent.name) {
|
|
138708
|
+
return false;
|
|
138709
|
+
}
|
|
138710
|
+
if (ts.isNamedImports(namedBindings)) {
|
|
138711
|
+
// We can only complete on named imports if there are no other named imports already,
|
|
138712
|
+
// but parser recovery sometimes puts later statements in the named imports list, so
|
|
138713
|
+
// we try to only consider the probably-valid ones.
|
|
138714
|
+
var invalidNamedImport = getPotentiallyInvalidImportSpecifier(namedBindings);
|
|
138715
|
+
var validImports = invalidNamedImport ? namedBindings.elements.indexOf(invalidNamedImport) : namedBindings.elements.length;
|
|
138716
|
+
return validImports < 2;
|
|
138717
|
+
}
|
|
138718
|
+
return true;
|
|
138581
138719
|
}
|
|
138582
138720
|
function isModuleSpecifierMissingOrEmpty(specifier) {
|
|
138583
138721
|
var _a;
|
|
@@ -157310,7 +157448,7 @@ var ts;
|
|
|
157310
157448
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
157311
157449
|
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
157312
157450
|
return;
|
|
157313
|
-
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
157451
|
+
var declaration = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
157314
157452
|
if (declaration === undefined)
|
|
157315
157453
|
return;
|
|
157316
157454
|
if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
|
|
@@ -157344,14 +157482,6 @@ var ts;
|
|
|
157344
157482
|
}
|
|
157345
157483
|
}
|
|
157346
157484
|
}
|
|
157347
|
-
function findAncestorMatchingSpan(sourceFile, span) {
|
|
157348
|
-
var end = ts.textSpanEnd(span);
|
|
157349
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
157350
|
-
while (token.end < end) {
|
|
157351
|
-
token = token.parent;
|
|
157352
|
-
}
|
|
157353
|
-
return token;
|
|
157354
|
-
}
|
|
157355
157485
|
function tryGetConstraintFromDiagnosticMessage(messageText) {
|
|
157356
157486
|
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
|
|
157357
157487
|
return constraint;
|
|
@@ -158897,6 +159027,63 @@ var ts;
|
|
|
158897
159027
|
})(ts || (ts = {}));
|
|
158898
159028
|
/* @internal */
|
|
158899
159029
|
var ts;
|
|
159030
|
+
(function (ts) {
|
|
159031
|
+
var codefix;
|
|
159032
|
+
(function (codefix) {
|
|
159033
|
+
var fixId = "fixNaNEquality";
|
|
159034
|
+
var errorCodes = [
|
|
159035
|
+
ts.Diagnostics.This_condition_will_always_return_0.code,
|
|
159036
|
+
];
|
|
159037
|
+
codefix.registerCodeFix({
|
|
159038
|
+
errorCodes: errorCodes,
|
|
159039
|
+
getCodeActions: function (context) {
|
|
159040
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
159041
|
+
var info = getInfo(program, sourceFile, span);
|
|
159042
|
+
if (info === undefined)
|
|
159043
|
+
return;
|
|
159044
|
+
var suggestion = info.suggestion, expression = info.expression, arg = info.arg;
|
|
159045
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, arg, expression); });
|
|
159046
|
+
return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Use_0, suggestion], fixId, ts.Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
159047
|
+
},
|
|
159048
|
+
fixIds: [fixId],
|
|
159049
|
+
getAllCodeActions: function (context) {
|
|
159050
|
+
return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
159051
|
+
var info = getInfo(context.program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
159052
|
+
if (info) {
|
|
159053
|
+
doChange(changes, diag.file, info.arg, info.expression);
|
|
159054
|
+
}
|
|
159055
|
+
});
|
|
159056
|
+
}
|
|
159057
|
+
});
|
|
159058
|
+
function getInfo(program, sourceFile, span) {
|
|
159059
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
159060
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
159061
|
+
return;
|
|
159062
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_mean_0.code; });
|
|
159063
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
159064
|
+
return;
|
|
159065
|
+
var token = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
159066
|
+
if (token === undefined)
|
|
159067
|
+
return;
|
|
159068
|
+
if (ts.isExpression(token) && ts.isBinaryExpression(token.parent)) {
|
|
159069
|
+
return { suggestion: getSuggestion(related.messageText), expression: token.parent, arg: token };
|
|
159070
|
+
}
|
|
159071
|
+
return undefined;
|
|
159072
|
+
}
|
|
159073
|
+
function doChange(changes, sourceFile, arg, expression) {
|
|
159074
|
+
var callExpression = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Number"), ts.factory.createIdentifier("isNaN")), /*typeArguments*/ undefined, [arg]);
|
|
159075
|
+
var operator = expression.operatorToken.kind;
|
|
159076
|
+
changes.replaceNode(sourceFile, expression, operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */
|
|
159077
|
+
? ts.factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, callExpression) : callExpression);
|
|
159078
|
+
}
|
|
159079
|
+
function getSuggestion(messageText) {
|
|
159080
|
+
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/\'(.*)\'/) || [], _ = _a[0], suggestion = _a[1];
|
|
159081
|
+
return suggestion;
|
|
159082
|
+
}
|
|
159083
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
159084
|
+
})(ts || (ts = {}));
|
|
159085
|
+
/* @internal */
|
|
159086
|
+
var ts;
|
|
158900
159087
|
(function (ts) {
|
|
158901
159088
|
var codefix;
|
|
158902
159089
|
(function (codefix) {
|
|
@@ -161614,6 +161801,15 @@ var ts;
|
|
|
161614
161801
|
symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true); });
|
|
161615
161802
|
}
|
|
161616
161803
|
codefix.importSymbols = importSymbols;
|
|
161804
|
+
function findAncestorMatchingSpan(sourceFile, span) {
|
|
161805
|
+
var end = ts.textSpanEnd(span);
|
|
161806
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
161807
|
+
while (token.end < end) {
|
|
161808
|
+
token = token.parent;
|
|
161809
|
+
}
|
|
161810
|
+
return token;
|
|
161811
|
+
}
|
|
161812
|
+
codefix.findAncestorMatchingSpan = findAncestorMatchingSpan;
|
|
161617
161813
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
161618
161814
|
})(ts || (ts = {}));
|
|
161619
161815
|
/* @internal */
|