typescript 4.5.0-dev.20211101 → 4.6.0-dev.20211104
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/lib.es5.d.ts +1 -1
- package/lib/tsc.js +156 -90
- package/lib/tsserver.js +225 -122
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +225 -122
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +225 -122
- package/lib/typescriptServices.d.ts +1 -1
- package/lib/typescriptServices.js +225 -122
- package/lib/typingsInstaller.js +208 -111
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -96,11 +96,11 @@ var ts;
|
|
|
96
96
|
(function (ts) {
|
|
97
97
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
98
98
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
99
|
-
ts.versionMajorMinor = "4.
|
|
99
|
+
ts.versionMajorMinor = "4.6";
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211104";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4800,6 +4800,7 @@ var ts;
|
|
|
4800
4800
|
NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 33554432] = "ConstructorReferenceInClass";
|
|
4801
4801
|
NodeCheckFlags[NodeCheckFlags["ContainsClassWithPrivateIdentifiers"] = 67108864] = "ContainsClassWithPrivateIdentifiers";
|
|
4802
4802
|
NodeCheckFlags[NodeCheckFlags["ContainsSuperPropertyInStaticInitializer"] = 134217728] = "ContainsSuperPropertyInStaticInitializer";
|
|
4803
|
+
NodeCheckFlags[NodeCheckFlags["InCheckIdentifier"] = 268435456] = "InCheckIdentifier";
|
|
4803
4804
|
})(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {}));
|
|
4804
4805
|
var TypeFlags;
|
|
4805
4806
|
(function (TypeFlags) {
|
|
@@ -4873,8 +4874,6 @@ var ts;
|
|
|
4873
4874
|
// 'Narrowable' types are types where narrowing actually narrows.
|
|
4874
4875
|
// This *should* be every type other than null, undefined, void, and never
|
|
4875
4876
|
TypeFlags[TypeFlags["Narrowable"] = 536624127] = "Narrowable";
|
|
4876
|
-
/* @internal */
|
|
4877
|
-
TypeFlags[TypeFlags["NotPrimitiveUnion"] = 468598819] = "NotPrimitiveUnion";
|
|
4878
4877
|
// The following flags are aggregated during union and intersection type construction
|
|
4879
4878
|
/* @internal */
|
|
4880
4879
|
TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask";
|
|
@@ -4887,6 +4886,10 @@ var ts;
|
|
|
4887
4886
|
TypeFlags[TypeFlags["IncludesWildcard"] = 8388608] = "IncludesWildcard";
|
|
4888
4887
|
/* @internal */
|
|
4889
4888
|
TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject";
|
|
4889
|
+
/* @internal */
|
|
4890
|
+
TypeFlags[TypeFlags["IncludesInstantiable"] = 33554432] = "IncludesInstantiable";
|
|
4891
|
+
/* @internal */
|
|
4892
|
+
TypeFlags[TypeFlags["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
|
|
4890
4893
|
})(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {}));
|
|
4891
4894
|
// Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags
|
|
4892
4895
|
// are specific to certain types and reuse the same bit position. Those ObjectFlags require a check
|
|
@@ -8101,7 +8104,7 @@ var ts;
|
|
|
8101
8104
|
Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
|
|
8102
8105
|
Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
|
|
8103
8106
|
Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
|
|
8104
|
-
|
|
8107
|
+
Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."),
|
|
8105
8108
|
Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
|
|
8106
8109
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
8107
8110
|
String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
|
|
@@ -8701,11 +8704,12 @@ var ts;
|
|
|
8701
8704
|
Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers: diag(2818, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818", "Duplicate identifier '{0}'. Compiler reserves name '{1}' when emitting 'super' references in static initializers."),
|
|
8702
8705
|
Namespace_name_cannot_be_0: diag(2819, ts.DiagnosticCategory.Error, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."),
|
|
8703
8706
|
Type_0_is_not_assignable_to_type_1_Did_you_mean_2: diag(2820, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820", "Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?"),
|
|
8704
|
-
|
|
8707
|
+
Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."),
|
|
8705
8708
|
Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
|
|
8706
8709
|
Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
|
|
8707
8710
|
Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."),
|
|
8708
8711
|
Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
|
|
8712
|
+
Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
|
|
8709
8713
|
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}'."),
|
|
8710
8714
|
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}'."),
|
|
8711
8715
|
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}'."),
|
|
@@ -11732,6 +11736,7 @@ var ts;
|
|
|
11732
11736
|
tokenValue = tokenValue.slice(0, -1);
|
|
11733
11737
|
pos--;
|
|
11734
11738
|
}
|
|
11739
|
+
return getIdentifierToken();
|
|
11735
11740
|
}
|
|
11736
11741
|
return token;
|
|
11737
11742
|
}
|
|
@@ -54118,12 +54123,15 @@ var ts;
|
|
|
54118
54123
|
}
|
|
54119
54124
|
/** Return the inferred type for a binding element */
|
|
54120
54125
|
function getTypeForBindingElement(declaration) {
|
|
54121
|
-
var
|
|
54122
|
-
|
|
54123
|
-
|
|
54124
|
-
|
|
54126
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent);
|
|
54127
|
+
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54128
|
+
}
|
|
54129
|
+
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
54130
|
+
// If an any type was inferred for parent, infer that for the binding element
|
|
54131
|
+
if (isTypeAny(parentType)) {
|
|
54125
54132
|
return parentType;
|
|
54126
54133
|
}
|
|
54134
|
+
var pattern = declaration.parent;
|
|
54127
54135
|
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
|
|
54128
54136
|
if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
|
|
54129
54137
|
parentType = getNonNullableType(parentType);
|
|
@@ -59335,6 +59343,8 @@ var ts;
|
|
|
59335
59343
|
// We ignore 'never' types in unions
|
|
59336
59344
|
if (!(flags & 131072 /* Never */)) {
|
|
59337
59345
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
59346
|
+
if (flags & 465829888 /* Instantiable */)
|
|
59347
|
+
includes |= 33554432 /* IncludesInstantiable */;
|
|
59338
59348
|
if (type === wildcardType)
|
|
59339
59349
|
includes |= 8388608 /* IncludesWildcard */;
|
|
59340
59350
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -59548,7 +59558,7 @@ var ts;
|
|
|
59548
59558
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
59549
59559
|
}
|
|
59550
59560
|
}
|
|
59551
|
-
var objectFlags = (includes &
|
|
59561
|
+
var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
|
|
59552
59562
|
(includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
|
|
59553
59563
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
59554
59564
|
}
|
|
@@ -62743,7 +62753,7 @@ var ts;
|
|
|
62743
62753
|
return true;
|
|
62744
62754
|
}
|
|
62745
62755
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
62746
|
-
var related = relation.get(getRelationKey(source, target, 0 /* None */, relation));
|
|
62756
|
+
var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false));
|
|
62747
62757
|
if (related !== undefined) {
|
|
62748
62758
|
return !!(related & 1 /* Succeeded */);
|
|
62749
62759
|
}
|
|
@@ -63592,7 +63602,8 @@ var ts;
|
|
|
63592
63602
|
if (overflow) {
|
|
63593
63603
|
return 0 /* False */;
|
|
63594
63604
|
}
|
|
63595
|
-
var
|
|
63605
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
|
|
63606
|
+
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
63596
63607
|
var entry = relation.get(id);
|
|
63597
63608
|
if (entry !== undefined) {
|
|
63598
63609
|
if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
|
|
@@ -63619,16 +63630,13 @@ var ts;
|
|
|
63619
63630
|
targetStack = [];
|
|
63620
63631
|
}
|
|
63621
63632
|
else {
|
|
63622
|
-
//
|
|
63623
|
-
//
|
|
63624
|
-
//
|
|
63625
|
-
var broadestEquivalentId = id.
|
|
63626
|
-
var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined);
|
|
63627
|
-
return "=" + index;
|
|
63628
|
-
}); }).join(",");
|
|
63633
|
+
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
63634
|
+
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
63635
|
+
// were unconstrained.
|
|
63636
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
63629
63637
|
for (var i = 0; i < maybeCount; i++) {
|
|
63630
63638
|
// If source and target are already being compared, consider them related with assumptions
|
|
63631
|
-
if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
|
|
63639
|
+
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
63632
63640
|
return 3 /* Maybe */;
|
|
63633
63641
|
}
|
|
63634
63642
|
}
|
|
@@ -63923,7 +63931,7 @@ var ts;
|
|
|
63923
63931
|
originalErrorInfo = undefined;
|
|
63924
63932
|
}
|
|
63925
63933
|
}
|
|
63926
|
-
else if (isGenericMappedType(target)) {
|
|
63934
|
+
else if (isGenericMappedType(target) && relation !== identityRelation) {
|
|
63927
63935
|
// Check if source type `S` is related to target type `{ [P in Q]: T }` or `{ [P in Q as R]: T}`.
|
|
63928
63936
|
var keysRemapped = !!target.declaration.nameType;
|
|
63929
63937
|
var templateType = getTemplateTypeFromMappedType(target);
|
|
@@ -65135,48 +65143,56 @@ var ts;
|
|
|
65135
65143
|
function isTypeReferenceWithGenericArguments(type) {
|
|
65136
65144
|
return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
|
|
65137
65145
|
}
|
|
65138
|
-
|
|
65139
|
-
|
|
65140
|
-
|
|
65141
|
-
|
|
65142
|
-
|
|
65143
|
-
|
|
65144
|
-
|
|
65145
|
-
|
|
65146
|
-
|
|
65147
|
-
if (
|
|
65148
|
-
|
|
65149
|
-
|
|
65150
|
-
|
|
65151
|
-
|
|
65146
|
+
function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
|
|
65147
|
+
var typeParameters = [];
|
|
65148
|
+
var constraintMarker = "";
|
|
65149
|
+
var sourceId = getTypeReferenceId(source, 0);
|
|
65150
|
+
var targetId = getTypeReferenceId(target, 0);
|
|
65151
|
+
return "" + constraintMarker + sourceId + "," + targetId + postFix;
|
|
65152
|
+
// getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
|
|
65153
|
+
// where A.id=111 and number.id=12
|
|
65154
|
+
function getTypeReferenceId(type, depth) {
|
|
65155
|
+
if (depth === void 0) { depth = 0; }
|
|
65156
|
+
var result = "" + type.target.id;
|
|
65157
|
+
for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
|
|
65158
|
+
var t = _a[_i];
|
|
65159
|
+
if (t.flags & 262144 /* TypeParameter */) {
|
|
65160
|
+
if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
|
|
65161
|
+
var index = typeParameters.indexOf(t);
|
|
65162
|
+
if (index < 0) {
|
|
65163
|
+
index = typeParameters.length;
|
|
65164
|
+
typeParameters.push(t);
|
|
65165
|
+
}
|
|
65166
|
+
result += "=" + index;
|
|
65167
|
+
continue;
|
|
65168
|
+
}
|
|
65169
|
+
// We mark type references that reference constrained type parameters such that we know to obtain
|
|
65170
|
+
// and look for a "broadest equivalent key" in the cache.
|
|
65171
|
+
constraintMarker = "*";
|
|
65172
|
+
}
|
|
65173
|
+
else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
|
|
65174
|
+
result += "<" + getTypeReferenceId(t, depth + 1) + ">";
|
|
65175
|
+
continue;
|
|
65152
65176
|
}
|
|
65153
|
-
result += "=" + index;
|
|
65154
|
-
}
|
|
65155
|
-
else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
|
|
65156
|
-
result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
|
|
65157
|
-
}
|
|
65158
|
-
else {
|
|
65159
65177
|
result += "-" + t.id;
|
|
65160
65178
|
}
|
|
65179
|
+
return result;
|
|
65161
65180
|
}
|
|
65162
|
-
return result;
|
|
65163
65181
|
}
|
|
65164
65182
|
/**
|
|
65165
65183
|
* To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
|
|
65166
65184
|
* For other cases, the types ids are used.
|
|
65167
65185
|
*/
|
|
65168
|
-
function getRelationKey(source, target, intersectionState, relation) {
|
|
65186
|
+
function getRelationKey(source, target, intersectionState, relation, ignoreConstraints) {
|
|
65169
65187
|
if (relation === identityRelation && source.id > target.id) {
|
|
65170
65188
|
var temp = source;
|
|
65171
65189
|
source = target;
|
|
65172
65190
|
target = temp;
|
|
65173
65191
|
}
|
|
65174
65192
|
var postFix = intersectionState ? ":" + intersectionState : "";
|
|
65175
|
-
|
|
65176
|
-
|
|
65177
|
-
|
|
65178
|
-
}
|
|
65179
|
-
return source.id + "," + target.id + postFix;
|
|
65193
|
+
return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ?
|
|
65194
|
+
getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) :
|
|
65195
|
+
source.id + "," + target.id + postFix;
|
|
65180
65196
|
}
|
|
65181
65197
|
// Invoke the callback for each underlying property symbol of the given symbol and return the first
|
|
65182
65198
|
// value that isn't undefined.
|
|
@@ -65224,28 +65240,35 @@ var ts;
|
|
|
65224
65240
|
!hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
|
|
65225
65241
|
}
|
|
65226
65242
|
// Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
|
|
65227
|
-
// for
|
|
65243
|
+
// for maxDepth or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
|
|
65228
65244
|
// though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
|
|
65229
|
-
// expanding. Effectively, we will generate a false positive when two types are structurally equal to at least
|
|
65245
|
+
// expanding. Effectively, we will generate a false positive when two types are structurally equal to at least maxDepth
|
|
65230
65246
|
// levels, but unequal at some level beyond that.
|
|
65231
|
-
// In addition, this will also detect when an indexed access has been chained off of
|
|
65232
|
-
// the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
|
|
65233
|
-
// for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
|
|
65234
|
-
// It also detects when a recursive type reference has expanded
|
|
65247
|
+
// In addition, this will also detect when an indexed access has been chained off of maxDepth more times (which is
|
|
65248
|
+
// essentially the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
|
|
65249
|
+
// false positives for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
|
|
65250
|
+
// It also detects when a recursive type reference has expanded maxDepth or more times, e.g. if the true branch of
|
|
65235
65251
|
// `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
|
|
65236
|
-
// has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]
|
|
65237
|
-
//
|
|
65252
|
+
// has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`. In such cases we need
|
|
65253
|
+
// to terminate the expansion, and we do so here.
|
|
65238
65254
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
65239
|
-
if (maxDepth === void 0) { maxDepth =
|
|
65255
|
+
if (maxDepth === void 0) { maxDepth = 3; }
|
|
65240
65256
|
if (depth >= maxDepth) {
|
|
65241
65257
|
var identity_1 = getRecursionIdentity(type);
|
|
65242
65258
|
var count = 0;
|
|
65259
|
+
var lastTypeId = 0;
|
|
65243
65260
|
for (var i = 0; i < depth; i++) {
|
|
65244
|
-
|
|
65245
|
-
|
|
65246
|
-
|
|
65247
|
-
|
|
65261
|
+
var t = stack[i];
|
|
65262
|
+
if (getRecursionIdentity(t) === identity_1) {
|
|
65263
|
+
// We only count occurrences with a higher type id than the previous occurrence, since higher
|
|
65264
|
+
// type ids are an indicator of newer instantiations caused by recursion.
|
|
65265
|
+
if (t.id >= lastTypeId) {
|
|
65266
|
+
count++;
|
|
65267
|
+
if (count >= maxDepth) {
|
|
65268
|
+
return true;
|
|
65269
|
+
}
|
|
65248
65270
|
}
|
|
65271
|
+
lastTypeId = t.id;
|
|
65249
65272
|
}
|
|
65250
65273
|
}
|
|
65251
65274
|
}
|
|
@@ -65984,7 +66007,8 @@ var ts;
|
|
|
65984
66007
|
(resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) ||
|
|
65985
66008
|
param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
|
|
65986
66009
|
var newName = "arg" + param.parent.parameters.indexOf(param);
|
|
65987
|
-
|
|
66010
|
+
var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
|
|
66011
|
+
errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
|
|
65988
66012
|
return;
|
|
65989
66013
|
}
|
|
65990
66014
|
diagnostic = declaration.dotDotDotToken ?
|
|
@@ -67350,29 +67374,6 @@ var ts;
|
|
|
67350
67374
|
}
|
|
67351
67375
|
return false;
|
|
67352
67376
|
}
|
|
67353
|
-
function getPropertyAccess(expr) {
|
|
67354
|
-
if (ts.isAccessExpression(expr)) {
|
|
67355
|
-
return expr;
|
|
67356
|
-
}
|
|
67357
|
-
if (ts.isIdentifier(expr)) {
|
|
67358
|
-
var symbol = getResolvedSymbol(expr);
|
|
67359
|
-
if (isConstVariable(symbol)) {
|
|
67360
|
-
var declaration = symbol.valueDeclaration;
|
|
67361
|
-
// Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
|
|
67362
|
-
if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer)) {
|
|
67363
|
-
return declaration.initializer;
|
|
67364
|
-
}
|
|
67365
|
-
// Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
|
|
67366
|
-
if (ts.isBindingElement(declaration) && !declaration.initializer) {
|
|
67367
|
-
var parent = declaration.parent.parent;
|
|
67368
|
-
if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer))) {
|
|
67369
|
-
return declaration;
|
|
67370
|
-
}
|
|
67371
|
-
}
|
|
67372
|
-
}
|
|
67373
|
-
}
|
|
67374
|
-
return undefined;
|
|
67375
|
-
}
|
|
67376
67377
|
function getAccessedPropertyName(access) {
|
|
67377
67378
|
var propertyName;
|
|
67378
67379
|
return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
|
|
@@ -68271,20 +68272,21 @@ var ts;
|
|
|
68271
68272
|
}
|
|
68272
68273
|
return false;
|
|
68273
68274
|
}
|
|
68274
|
-
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer) {
|
|
68275
|
+
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, flowNode) {
|
|
68275
68276
|
if (initialType === void 0) { initialType = declaredType; }
|
|
68277
|
+
if (flowNode === void 0) { flowNode = reference.flowNode; }
|
|
68276
68278
|
var key;
|
|
68277
68279
|
var isKeySet = false;
|
|
68278
68280
|
var flowDepth = 0;
|
|
68279
68281
|
if (flowAnalysisDisabled) {
|
|
68280
68282
|
return errorType;
|
|
68281
68283
|
}
|
|
68282
|
-
if (!
|
|
68284
|
+
if (!flowNode) {
|
|
68283
68285
|
return declaredType;
|
|
68284
68286
|
}
|
|
68285
68287
|
flowInvocationCount++;
|
|
68286
68288
|
var sharedFlowStart = sharedFlowCount;
|
|
68287
|
-
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(
|
|
68289
|
+
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(flowNode));
|
|
68288
68290
|
sharedFlowCount = sharedFlowStart;
|
|
68289
68291
|
// When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation,
|
|
68290
68292
|
// we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations
|
|
@@ -68716,13 +68718,57 @@ var ts;
|
|
|
68716
68718
|
}
|
|
68717
68719
|
return result;
|
|
68718
68720
|
}
|
|
68721
|
+
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
68722
|
+
if (ts.isBindingPattern(reference)) {
|
|
68723
|
+
// When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
|
|
68724
|
+
// An identifier for a destructuring variable declared in the same binding pattern is a candidate.
|
|
68725
|
+
if (ts.isIdentifier(expr)) {
|
|
68726
|
+
var symbol = getResolvedSymbol(expr);
|
|
68727
|
+
var declaration = symbol.valueDeclaration;
|
|
68728
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
|
|
68729
|
+
return declaration;
|
|
68730
|
+
}
|
|
68731
|
+
}
|
|
68732
|
+
}
|
|
68733
|
+
else if (ts.isAccessExpression(expr)) {
|
|
68734
|
+
// An access expression is a candidate if the reference matches the left hand expression.
|
|
68735
|
+
if (isMatchingReference(reference, expr.expression)) {
|
|
68736
|
+
return expr;
|
|
68737
|
+
}
|
|
68738
|
+
}
|
|
68739
|
+
else if (ts.isIdentifier(expr)) {
|
|
68740
|
+
var symbol = getResolvedSymbol(expr);
|
|
68741
|
+
if (isConstVariable(symbol)) {
|
|
68742
|
+
var declaration = symbol.valueDeclaration;
|
|
68743
|
+
// Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
|
|
68744
|
+
if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer) &&
|
|
68745
|
+
isMatchingReference(reference, declaration.initializer.expression)) {
|
|
68746
|
+
return declaration.initializer;
|
|
68747
|
+
}
|
|
68748
|
+
// Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
|
|
68749
|
+
if (ts.isBindingElement(declaration) && !declaration.initializer) {
|
|
68750
|
+
var parent = declaration.parent.parent;
|
|
68751
|
+
if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer)) &&
|
|
68752
|
+
isMatchingReference(reference, parent.initializer)) {
|
|
68753
|
+
return declaration;
|
|
68754
|
+
}
|
|
68755
|
+
}
|
|
68756
|
+
}
|
|
68757
|
+
}
|
|
68758
|
+
return undefined;
|
|
68759
|
+
}
|
|
68719
68760
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
68720
|
-
var access, name;
|
|
68721
68761
|
var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
68722
|
-
|
|
68723
|
-
|
|
68724
|
-
|
|
68725
|
-
|
|
68762
|
+
if (type.flags & 1048576 /* Union */) {
|
|
68763
|
+
var access = getCandidateDiscriminantPropertyAccess(expr);
|
|
68764
|
+
if (access) {
|
|
68765
|
+
var name = getAccessedPropertyName(access);
|
|
68766
|
+
if (name && isDiscriminantProperty(type, name)) {
|
|
68767
|
+
return access;
|
|
68768
|
+
}
|
|
68769
|
+
}
|
|
68770
|
+
}
|
|
68771
|
+
return undefined;
|
|
68726
68772
|
}
|
|
68727
68773
|
function narrowTypeByDiscriminant(type, access, narrowType) {
|
|
68728
68774
|
var propName = getAccessedPropertyName(access);
|
|
@@ -69480,6 +69526,49 @@ var ts;
|
|
|
69480
69526
|
}
|
|
69481
69527
|
}
|
|
69482
69528
|
}
|
|
69529
|
+
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
69530
|
+
// If we have a non-rest binding element with no initializer declared as a const variable or a const-like
|
|
69531
|
+
// parameter (a parameter for which there are no assignments in the function body), and if the parent type
|
|
69532
|
+
// for the destructuring is a union type, one or more of the binding elements may represent discriminant
|
|
69533
|
+
// properties, and we want the effects of conditional checks on such discriminants to affect the types of
|
|
69534
|
+
// other binding elements from the same destructuring. Consider:
|
|
69535
|
+
//
|
|
69536
|
+
// type Action =
|
|
69537
|
+
// | { kind: 'A', payload: number }
|
|
69538
|
+
// | { kind: 'B', payload: string };
|
|
69539
|
+
//
|
|
69540
|
+
// function f1({ kind, payload }: Action) {
|
|
69541
|
+
// if (kind === 'A') {
|
|
69542
|
+
// payload.toFixed();
|
|
69543
|
+
// }
|
|
69544
|
+
// if (kind === 'B') {
|
|
69545
|
+
// payload.toUpperCase();
|
|
69546
|
+
// }
|
|
69547
|
+
// }
|
|
69548
|
+
//
|
|
69549
|
+
// Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
|
|
69550
|
+
// the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
|
|
69551
|
+
// as if it occurred in the specified location. We then recompute the narrowed binding element type by
|
|
69552
|
+
// destructuring from the narrowed parent type.
|
|
69553
|
+
var declaration = symbol.valueDeclaration;
|
|
69554
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
69555
|
+
var parent = declaration.parent.parent;
|
|
69556
|
+
if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
|
|
69557
|
+
var links = getNodeLinks(location);
|
|
69558
|
+
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69559
|
+
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69560
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
69561
|
+
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69562
|
+
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69563
|
+
var pattern = declaration.parent;
|
|
69564
|
+
var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
|
|
69565
|
+
return getBindingElementTypeFromParentType(declaration, narrowedType);
|
|
69566
|
+
}
|
|
69567
|
+
}
|
|
69568
|
+
}
|
|
69569
|
+
}
|
|
69570
|
+
return getTypeOfSymbol(symbol);
|
|
69571
|
+
}
|
|
69483
69572
|
function checkIdentifier(node, checkMode) {
|
|
69484
69573
|
var symbol = getResolvedSymbol(node);
|
|
69485
69574
|
if (symbol === unknownSymbol) {
|
|
@@ -69553,7 +69642,7 @@ var ts;
|
|
|
69553
69642
|
}
|
|
69554
69643
|
}
|
|
69555
69644
|
checkNestedBlockScopedBinding(node, symbol);
|
|
69556
|
-
var type =
|
|
69645
|
+
var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
69557
69646
|
var assignmentKind = ts.getAssignmentTargetKind(node);
|
|
69558
69647
|
if (assignmentKind) {
|
|
69559
69648
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) &&
|
|
@@ -70596,13 +70685,13 @@ var ts;
|
|
|
70596
70685
|
function isCircularMappedProperty(symbol) {
|
|
70597
70686
|
return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
|
|
70598
70687
|
}
|
|
70599
|
-
function getTypeOfPropertyOfContextualType(type, name) {
|
|
70688
|
+
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
70600
70689
|
return mapType(type, function (t) {
|
|
70601
70690
|
var _a;
|
|
70602
70691
|
if (isGenericMappedType(t)) {
|
|
70603
70692
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
70604
70693
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
70605
|
-
var propertyNameType = getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
70694
|
+
var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
70606
70695
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
70607
70696
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
70608
70697
|
}
|
|
@@ -70618,7 +70707,7 @@ var ts;
|
|
|
70618
70707
|
return restType;
|
|
70619
70708
|
}
|
|
70620
70709
|
}
|
|
70621
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
70710
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
70622
70711
|
}
|
|
70623
70712
|
return undefined;
|
|
70624
70713
|
}, /*noReductions*/ true);
|
|
@@ -70646,7 +70735,8 @@ var ts;
|
|
|
70646
70735
|
// For a (non-symbol) computed property, there is no reason to look up the name
|
|
70647
70736
|
// in the type. It will just be "__computed", which does not appear in any
|
|
70648
70737
|
// SymbolTable.
|
|
70649
|
-
|
|
70738
|
+
var symbol = getSymbolOfNode(element);
|
|
70739
|
+
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
70650
70740
|
}
|
|
70651
70741
|
if (element.name) {
|
|
70652
70742
|
var nameType_2 = getLiteralTypeFromPropertyName(element.name);
|
|
@@ -78357,7 +78447,9 @@ var ts;
|
|
|
78357
78447
|
var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
|
|
78358
78448
|
if (!typeReferenceNode)
|
|
78359
78449
|
return undefined;
|
|
78360
|
-
var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
|
|
78450
|
+
var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
|
|
78451
|
+
if (!typeParameters)
|
|
78452
|
+
return undefined;
|
|
78361
78453
|
var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
|
|
78362
78454
|
return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
|
|
78363
78455
|
}
|
|
@@ -82767,8 +82859,11 @@ var ts;
|
|
|
82767
82859
|
function checkAssertClause(declaration) {
|
|
82768
82860
|
var _a;
|
|
82769
82861
|
if (declaration.assertClause) {
|
|
82770
|
-
|
|
82771
|
-
|
|
82862
|
+
var mode = (moduleKind === ts.ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
82863
|
+
if (mode !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.ESNext) {
|
|
82864
|
+
return grammarErrorOnNode(declaration.assertClause, moduleKind === ts.ModuleKind.NodeNext
|
|
82865
|
+
? ts.Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls
|
|
82866
|
+
: ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
82772
82867
|
}
|
|
82773
82868
|
if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
|
|
82774
82869
|
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports);
|
|
@@ -86615,12 +86710,12 @@ var ts;
|
|
|
86615
86710
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
86616
86711
|
}
|
|
86617
86712
|
var nodeArguments = node.arguments;
|
|
86618
|
-
if (moduleKind !== ts.ModuleKind.ESNext) {
|
|
86713
|
+
if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
|
|
86619
86714
|
// We are allowed trailing comma after proposal-import-assertions.
|
|
86620
86715
|
checkGrammarForDisallowedTrailingComma(nodeArguments);
|
|
86621
86716
|
if (nodeArguments.length > 1) {
|
|
86622
86717
|
var assertionArgument = nodeArguments[1];
|
|
86623
|
-
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.
|
|
86718
|
+
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
86624
86719
|
}
|
|
86625
86720
|
}
|
|
86626
86721
|
if (nodeArguments.length === 0 || nodeArguments.length > 2) {
|
|
@@ -119353,13 +119448,15 @@ var ts;
|
|
|
119353
119448
|
if (host.fileExists(packageJsonPath)) {
|
|
119354
119449
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119355
119450
|
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119356
|
-
|
|
119357
|
-
|
|
119358
|
-
|
|
119359
|
-
|
|
119360
|
-
|
|
119361
|
-
|
|
119362
|
-
|
|
119451
|
+
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
119452
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119453
|
+
if (fromExports) {
|
|
119454
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119455
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119456
|
+
}
|
|
119457
|
+
if (packageJsonContent.exports) {
|
|
119458
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119459
|
+
}
|
|
119363
119460
|
}
|
|
119364
119461
|
var versionPaths = packageJsonContent.typesVersions
|
|
119365
119462
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
@@ -128747,7 +128844,7 @@ var ts;
|
|
|
128747
128844
|
}
|
|
128748
128845
|
node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
|
|
128749
128846
|
completionNodes.push(node);
|
|
128750
|
-
}, body, isAbstract);
|
|
128847
|
+
}, body, 2 /* Property */, isAbstract);
|
|
128751
128848
|
if (completionNodes.length) {
|
|
128752
128849
|
insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
128753
128850
|
}
|
|
@@ -134289,7 +134386,8 @@ var ts;
|
|
|
134289
134386
|
}
|
|
134290
134387
|
}
|
|
134291
134388
|
else {
|
|
134292
|
-
return
|
|
134389
|
+
return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined :
|
|
134390
|
+
nodeEntry(ref, 2 /* StringLiteral */);
|
|
134293
134391
|
}
|
|
134294
134392
|
}
|
|
134295
134393
|
});
|
|
@@ -146113,9 +146211,6 @@ var ts;
|
|
|
146113
146211
|
});
|
|
146114
146212
|
function makeChange(changeTracker, sourceFile, pos) {
|
|
146115
146213
|
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
146116
|
-
if (!ts.isIdentifier(token)) {
|
|
146117
|
-
return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.Debug.formatSyntaxKind(token.kind));
|
|
146118
|
-
}
|
|
146119
146214
|
var param = token.parent;
|
|
146120
146215
|
if (!ts.isParameter(param)) {
|
|
146121
146216
|
return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.Debug.formatSyntaxKind(token.kind));
|
|
@@ -146123,9 +146218,10 @@ var ts;
|
|
|
146123
146218
|
var i = param.parent.parameters.indexOf(param);
|
|
146124
146219
|
ts.Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one.");
|
|
146125
146220
|
ts.Debug.assert(i > -1, "Parameter not found in parent parameter list.");
|
|
146221
|
+
var typeNode = ts.factory.createTypeReferenceNode(param.name, /*typeArguments*/ undefined);
|
|
146126
146222
|
var replacement = ts.factory.createParameterDeclaration(
|
|
146127
|
-
/*decorators*/ undefined, param.modifiers, param.dotDotDotToken, "arg" + i, param.questionToken, ts.factory.
|
|
146128
|
-
changeTracker.replaceNode(sourceFile,
|
|
146223
|
+
/*decorators*/ undefined, param.modifiers, param.dotDotDotToken, "arg" + i, param.questionToken, param.dotDotDotToken ? ts.factory.createArrayTypeNode(typeNode) : typeNode, param.initializer);
|
|
146224
|
+
changeTracker.replaceNode(sourceFile, param, replacement);
|
|
146129
146225
|
}
|
|
146130
146226
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
146131
146227
|
})(ts || (ts = {}));
|
|
@@ -152579,11 +152675,18 @@ var ts;
|
|
|
152579
152675
|
};
|
|
152580
152676
|
}
|
|
152581
152677
|
codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
|
|
152678
|
+
var PreserveOptionalFlags;
|
|
152679
|
+
(function (PreserveOptionalFlags) {
|
|
152680
|
+
PreserveOptionalFlags[PreserveOptionalFlags["Method"] = 1] = "Method";
|
|
152681
|
+
PreserveOptionalFlags[PreserveOptionalFlags["Property"] = 2] = "Property";
|
|
152682
|
+
PreserveOptionalFlags[PreserveOptionalFlags["All"] = 3] = "All";
|
|
152683
|
+
})(PreserveOptionalFlags = codefix.PreserveOptionalFlags || (codefix.PreserveOptionalFlags = {}));
|
|
152582
152684
|
/**
|
|
152583
152685
|
* `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
|
|
152584
152686
|
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
|
|
152585
152687
|
*/
|
|
152586
|
-
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
|
|
152688
|
+
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) {
|
|
152689
|
+
if (preserveOptional === void 0) { preserveOptional = 3 /* All */; }
|
|
152587
152690
|
if (isAmbient === void 0) { isAmbient = false; }
|
|
152588
152691
|
var declarations = symbol.getDeclarations();
|
|
152589
152692
|
if (!(declarations && declarations.length)) {
|
|
@@ -152612,7 +152715,7 @@ var ts;
|
|
|
152612
152715
|
}
|
|
152613
152716
|
}
|
|
152614
152717
|
addClassElement(ts.factory.createPropertyDeclaration(
|
|
152615
|
-
/*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
|
|
152718
|
+
/*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
|
|
152616
152719
|
/*initializer*/ undefined));
|
|
152617
152720
|
break;
|
|
152618
152721
|
case 171 /* GetAccessor */:
|
|
@@ -152676,13 +152779,13 @@ var ts;
|
|
|
152676
152779
|
}
|
|
152677
152780
|
else {
|
|
152678
152781
|
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
|
|
152679
|
-
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
|
|
152782
|
+
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body));
|
|
152680
152783
|
}
|
|
152681
152784
|
}
|
|
152682
152785
|
break;
|
|
152683
152786
|
}
|
|
152684
152787
|
function outputMethod(quotePreference, signature, modifiers, name, body) {
|
|
152685
|
-
var method = createSignatureDeclarationFromSignature(168 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder);
|
|
152788
|
+
var method = createSignatureDeclarationFromSignature(168 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder);
|
|
152686
152789
|
if (method)
|
|
152687
152790
|
addClassElement(method);
|
|
152688
152791
|
}
|