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/typingsInstaller.js
CHANGED
|
@@ -85,11 +85,11 @@ var ts;
|
|
|
85
85
|
(function (ts) {
|
|
86
86
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
87
87
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
88
|
-
ts.versionMajorMinor = "4.
|
|
88
|
+
ts.versionMajorMinor = "4.6";
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211104";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -4789,6 +4789,7 @@ var ts;
|
|
|
4789
4789
|
NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 33554432] = "ConstructorReferenceInClass";
|
|
4790
4790
|
NodeCheckFlags[NodeCheckFlags["ContainsClassWithPrivateIdentifiers"] = 67108864] = "ContainsClassWithPrivateIdentifiers";
|
|
4791
4791
|
NodeCheckFlags[NodeCheckFlags["ContainsSuperPropertyInStaticInitializer"] = 134217728] = "ContainsSuperPropertyInStaticInitializer";
|
|
4792
|
+
NodeCheckFlags[NodeCheckFlags["InCheckIdentifier"] = 268435456] = "InCheckIdentifier";
|
|
4792
4793
|
})(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {}));
|
|
4793
4794
|
var TypeFlags;
|
|
4794
4795
|
(function (TypeFlags) {
|
|
@@ -4862,8 +4863,6 @@ var ts;
|
|
|
4862
4863
|
// 'Narrowable' types are types where narrowing actually narrows.
|
|
4863
4864
|
// This *should* be every type other than null, undefined, void, and never
|
|
4864
4865
|
TypeFlags[TypeFlags["Narrowable"] = 536624127] = "Narrowable";
|
|
4865
|
-
/* @internal */
|
|
4866
|
-
TypeFlags[TypeFlags["NotPrimitiveUnion"] = 468598819] = "NotPrimitiveUnion";
|
|
4867
4866
|
// The following flags are aggregated during union and intersection type construction
|
|
4868
4867
|
/* @internal */
|
|
4869
4868
|
TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask";
|
|
@@ -4876,6 +4875,10 @@ var ts;
|
|
|
4876
4875
|
TypeFlags[TypeFlags["IncludesWildcard"] = 8388608] = "IncludesWildcard";
|
|
4877
4876
|
/* @internal */
|
|
4878
4877
|
TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject";
|
|
4878
|
+
/* @internal */
|
|
4879
|
+
TypeFlags[TypeFlags["IncludesInstantiable"] = 33554432] = "IncludesInstantiable";
|
|
4880
|
+
/* @internal */
|
|
4881
|
+
TypeFlags[TypeFlags["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
|
|
4879
4882
|
})(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {}));
|
|
4880
4883
|
// Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags
|
|
4881
4884
|
// are specific to certain types and reuse the same bit position. Those ObjectFlags require a check
|
|
@@ -8090,7 +8093,7 @@ var ts;
|
|
|
8090
8093
|
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."),
|
|
8091
8094
|
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."),
|
|
8092
8095
|
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'."),
|
|
8093
|
-
|
|
8096
|
+
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'."),
|
|
8094
8097
|
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."),
|
|
8095
8098
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
8096
8099
|
String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
|
|
@@ -8690,11 +8693,12 @@ var ts;
|
|
|
8690
8693
|
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."),
|
|
8691
8694
|
Namespace_name_cannot_be_0: diag(2819, ts.DiagnosticCategory.Error, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."),
|
|
8692
8695
|
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}'?"),
|
|
8693
|
-
|
|
8696
|
+
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'."),
|
|
8694
8697
|
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."),
|
|
8695
8698
|
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}'?"),
|
|
8696
8699
|
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."),
|
|
8697
8700
|
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}'?"),
|
|
8701
|
+
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."),
|
|
8698
8702
|
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}'."),
|
|
8699
8703
|
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}'."),
|
|
8700
8704
|
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}'."),
|
|
@@ -11721,6 +11725,7 @@ var ts;
|
|
|
11721
11725
|
tokenValue = tokenValue.slice(0, -1);
|
|
11722
11726
|
pos--;
|
|
11723
11727
|
}
|
|
11728
|
+
return getIdentifierToken();
|
|
11724
11729
|
}
|
|
11725
11730
|
return token;
|
|
11726
11731
|
}
|
|
@@ -54107,12 +54112,15 @@ var ts;
|
|
|
54107
54112
|
}
|
|
54108
54113
|
/** Return the inferred type for a binding element */
|
|
54109
54114
|
function getTypeForBindingElement(declaration) {
|
|
54110
|
-
var
|
|
54111
|
-
|
|
54112
|
-
|
|
54113
|
-
|
|
54115
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent);
|
|
54116
|
+
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54117
|
+
}
|
|
54118
|
+
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
54119
|
+
// If an any type was inferred for parent, infer that for the binding element
|
|
54120
|
+
if (isTypeAny(parentType)) {
|
|
54114
54121
|
return parentType;
|
|
54115
54122
|
}
|
|
54123
|
+
var pattern = declaration.parent;
|
|
54116
54124
|
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
|
|
54117
54125
|
if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
|
|
54118
54126
|
parentType = getNonNullableType(parentType);
|
|
@@ -59324,6 +59332,8 @@ var ts;
|
|
|
59324
59332
|
// We ignore 'never' types in unions
|
|
59325
59333
|
if (!(flags & 131072 /* Never */)) {
|
|
59326
59334
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
59335
|
+
if (flags & 465829888 /* Instantiable */)
|
|
59336
|
+
includes |= 33554432 /* IncludesInstantiable */;
|
|
59327
59337
|
if (type === wildcardType)
|
|
59328
59338
|
includes |= 8388608 /* IncludesWildcard */;
|
|
59329
59339
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -59537,7 +59547,7 @@ var ts;
|
|
|
59537
59547
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
59538
59548
|
}
|
|
59539
59549
|
}
|
|
59540
|
-
var objectFlags = (includes &
|
|
59550
|
+
var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
|
|
59541
59551
|
(includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
|
|
59542
59552
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
59543
59553
|
}
|
|
@@ -62732,7 +62742,7 @@ var ts;
|
|
|
62732
62742
|
return true;
|
|
62733
62743
|
}
|
|
62734
62744
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
62735
|
-
var related = relation.get(getRelationKey(source, target, 0 /* None */, relation));
|
|
62745
|
+
var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false));
|
|
62736
62746
|
if (related !== undefined) {
|
|
62737
62747
|
return !!(related & 1 /* Succeeded */);
|
|
62738
62748
|
}
|
|
@@ -63581,7 +63591,8 @@ var ts;
|
|
|
63581
63591
|
if (overflow) {
|
|
63582
63592
|
return 0 /* False */;
|
|
63583
63593
|
}
|
|
63584
|
-
var
|
|
63594
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
|
|
63595
|
+
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
63585
63596
|
var entry = relation.get(id);
|
|
63586
63597
|
if (entry !== undefined) {
|
|
63587
63598
|
if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
|
|
@@ -63608,16 +63619,13 @@ var ts;
|
|
|
63608
63619
|
targetStack = [];
|
|
63609
63620
|
}
|
|
63610
63621
|
else {
|
|
63611
|
-
//
|
|
63612
|
-
//
|
|
63613
|
-
//
|
|
63614
|
-
var broadestEquivalentId = id.
|
|
63615
|
-
var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined);
|
|
63616
|
-
return "=" + index;
|
|
63617
|
-
}); }).join(",");
|
|
63622
|
+
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
63623
|
+
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
63624
|
+
// were unconstrained.
|
|
63625
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
63618
63626
|
for (var i = 0; i < maybeCount; i++) {
|
|
63619
63627
|
// If source and target are already being compared, consider them related with assumptions
|
|
63620
|
-
if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
|
|
63628
|
+
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
63621
63629
|
return 3 /* Maybe */;
|
|
63622
63630
|
}
|
|
63623
63631
|
}
|
|
@@ -63912,7 +63920,7 @@ var ts;
|
|
|
63912
63920
|
originalErrorInfo = undefined;
|
|
63913
63921
|
}
|
|
63914
63922
|
}
|
|
63915
|
-
else if (isGenericMappedType(target)) {
|
|
63923
|
+
else if (isGenericMappedType(target) && relation !== identityRelation) {
|
|
63916
63924
|
// Check if source type `S` is related to target type `{ [P in Q]: T }` or `{ [P in Q as R]: T}`.
|
|
63917
63925
|
var keysRemapped = !!target.declaration.nameType;
|
|
63918
63926
|
var templateType = getTemplateTypeFromMappedType(target);
|
|
@@ -65124,48 +65132,56 @@ var ts;
|
|
|
65124
65132
|
function isTypeReferenceWithGenericArguments(type) {
|
|
65125
65133
|
return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
|
|
65126
65134
|
}
|
|
65127
|
-
|
|
65128
|
-
|
|
65129
|
-
|
|
65130
|
-
|
|
65131
|
-
|
|
65132
|
-
|
|
65133
|
-
|
|
65134
|
-
|
|
65135
|
-
|
|
65136
|
-
if (
|
|
65137
|
-
|
|
65138
|
-
|
|
65139
|
-
|
|
65140
|
-
|
|
65135
|
+
function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
|
|
65136
|
+
var typeParameters = [];
|
|
65137
|
+
var constraintMarker = "";
|
|
65138
|
+
var sourceId = getTypeReferenceId(source, 0);
|
|
65139
|
+
var targetId = getTypeReferenceId(target, 0);
|
|
65140
|
+
return "" + constraintMarker + sourceId + "," + targetId + postFix;
|
|
65141
|
+
// getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
|
|
65142
|
+
// where A.id=111 and number.id=12
|
|
65143
|
+
function getTypeReferenceId(type, depth) {
|
|
65144
|
+
if (depth === void 0) { depth = 0; }
|
|
65145
|
+
var result = "" + type.target.id;
|
|
65146
|
+
for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
|
|
65147
|
+
var t = _a[_i];
|
|
65148
|
+
if (t.flags & 262144 /* TypeParameter */) {
|
|
65149
|
+
if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
|
|
65150
|
+
var index = typeParameters.indexOf(t);
|
|
65151
|
+
if (index < 0) {
|
|
65152
|
+
index = typeParameters.length;
|
|
65153
|
+
typeParameters.push(t);
|
|
65154
|
+
}
|
|
65155
|
+
result += "=" + index;
|
|
65156
|
+
continue;
|
|
65157
|
+
}
|
|
65158
|
+
// We mark type references that reference constrained type parameters such that we know to obtain
|
|
65159
|
+
// and look for a "broadest equivalent key" in the cache.
|
|
65160
|
+
constraintMarker = "*";
|
|
65161
|
+
}
|
|
65162
|
+
else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
|
|
65163
|
+
result += "<" + getTypeReferenceId(t, depth + 1) + ">";
|
|
65164
|
+
continue;
|
|
65141
65165
|
}
|
|
65142
|
-
result += "=" + index;
|
|
65143
|
-
}
|
|
65144
|
-
else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
|
|
65145
|
-
result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
|
|
65146
|
-
}
|
|
65147
|
-
else {
|
|
65148
65166
|
result += "-" + t.id;
|
|
65149
65167
|
}
|
|
65168
|
+
return result;
|
|
65150
65169
|
}
|
|
65151
|
-
return result;
|
|
65152
65170
|
}
|
|
65153
65171
|
/**
|
|
65154
65172
|
* To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
|
|
65155
65173
|
* For other cases, the types ids are used.
|
|
65156
65174
|
*/
|
|
65157
|
-
function getRelationKey(source, target, intersectionState, relation) {
|
|
65175
|
+
function getRelationKey(source, target, intersectionState, relation, ignoreConstraints) {
|
|
65158
65176
|
if (relation === identityRelation && source.id > target.id) {
|
|
65159
65177
|
var temp = source;
|
|
65160
65178
|
source = target;
|
|
65161
65179
|
target = temp;
|
|
65162
65180
|
}
|
|
65163
65181
|
var postFix = intersectionState ? ":" + intersectionState : "";
|
|
65164
|
-
|
|
65165
|
-
|
|
65166
|
-
|
|
65167
|
-
}
|
|
65168
|
-
return source.id + "," + target.id + postFix;
|
|
65182
|
+
return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ?
|
|
65183
|
+
getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) :
|
|
65184
|
+
source.id + "," + target.id + postFix;
|
|
65169
65185
|
}
|
|
65170
65186
|
// Invoke the callback for each underlying property symbol of the given symbol and return the first
|
|
65171
65187
|
// value that isn't undefined.
|
|
@@ -65213,28 +65229,35 @@ var ts;
|
|
|
65213
65229
|
!hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
|
|
65214
65230
|
}
|
|
65215
65231
|
// Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
|
|
65216
|
-
// for
|
|
65232
|
+
// for maxDepth or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
|
|
65217
65233
|
// though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
|
|
65218
|
-
// expanding. Effectively, we will generate a false positive when two types are structurally equal to at least
|
|
65234
|
+
// expanding. Effectively, we will generate a false positive when two types are structurally equal to at least maxDepth
|
|
65219
65235
|
// levels, but unequal at some level beyond that.
|
|
65220
|
-
// In addition, this will also detect when an indexed access has been chained off of
|
|
65221
|
-
// the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
|
|
65222
|
-
// for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
|
|
65223
|
-
// It also detects when a recursive type reference has expanded
|
|
65236
|
+
// In addition, this will also detect when an indexed access has been chained off of maxDepth more times (which is
|
|
65237
|
+
// essentially the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
|
|
65238
|
+
// false positives for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
|
|
65239
|
+
// It also detects when a recursive type reference has expanded maxDepth or more times, e.g. if the true branch of
|
|
65224
65240
|
// `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
|
|
65225
|
-
// has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]
|
|
65226
|
-
//
|
|
65241
|
+
// has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`. In such cases we need
|
|
65242
|
+
// to terminate the expansion, and we do so here.
|
|
65227
65243
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
65228
|
-
if (maxDepth === void 0) { maxDepth =
|
|
65244
|
+
if (maxDepth === void 0) { maxDepth = 3; }
|
|
65229
65245
|
if (depth >= maxDepth) {
|
|
65230
65246
|
var identity_1 = getRecursionIdentity(type);
|
|
65231
65247
|
var count = 0;
|
|
65248
|
+
var lastTypeId = 0;
|
|
65232
65249
|
for (var i = 0; i < depth; i++) {
|
|
65233
|
-
|
|
65234
|
-
|
|
65235
|
-
|
|
65236
|
-
|
|
65250
|
+
var t = stack[i];
|
|
65251
|
+
if (getRecursionIdentity(t) === identity_1) {
|
|
65252
|
+
// We only count occurrences with a higher type id than the previous occurrence, since higher
|
|
65253
|
+
// type ids are an indicator of newer instantiations caused by recursion.
|
|
65254
|
+
if (t.id >= lastTypeId) {
|
|
65255
|
+
count++;
|
|
65256
|
+
if (count >= maxDepth) {
|
|
65257
|
+
return true;
|
|
65258
|
+
}
|
|
65237
65259
|
}
|
|
65260
|
+
lastTypeId = t.id;
|
|
65238
65261
|
}
|
|
65239
65262
|
}
|
|
65240
65263
|
}
|
|
@@ -65973,7 +65996,8 @@ var ts;
|
|
|
65973
65996
|
(resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) ||
|
|
65974
65997
|
param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
|
|
65975
65998
|
var newName = "arg" + param.parent.parameters.indexOf(param);
|
|
65976
|
-
|
|
65999
|
+
var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
|
|
66000
|
+
errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
|
|
65977
66001
|
return;
|
|
65978
66002
|
}
|
|
65979
66003
|
diagnostic = declaration.dotDotDotToken ?
|
|
@@ -67339,29 +67363,6 @@ var ts;
|
|
|
67339
67363
|
}
|
|
67340
67364
|
return false;
|
|
67341
67365
|
}
|
|
67342
|
-
function getPropertyAccess(expr) {
|
|
67343
|
-
if (ts.isAccessExpression(expr)) {
|
|
67344
|
-
return expr;
|
|
67345
|
-
}
|
|
67346
|
-
if (ts.isIdentifier(expr)) {
|
|
67347
|
-
var symbol = getResolvedSymbol(expr);
|
|
67348
|
-
if (isConstVariable(symbol)) {
|
|
67349
|
-
var declaration = symbol.valueDeclaration;
|
|
67350
|
-
// Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
|
|
67351
|
-
if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer)) {
|
|
67352
|
-
return declaration.initializer;
|
|
67353
|
-
}
|
|
67354
|
-
// Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
|
|
67355
|
-
if (ts.isBindingElement(declaration) && !declaration.initializer) {
|
|
67356
|
-
var parent = declaration.parent.parent;
|
|
67357
|
-
if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer))) {
|
|
67358
|
-
return declaration;
|
|
67359
|
-
}
|
|
67360
|
-
}
|
|
67361
|
-
}
|
|
67362
|
-
}
|
|
67363
|
-
return undefined;
|
|
67364
|
-
}
|
|
67365
67366
|
function getAccessedPropertyName(access) {
|
|
67366
67367
|
var propertyName;
|
|
67367
67368
|
return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
|
|
@@ -68260,20 +68261,21 @@ var ts;
|
|
|
68260
68261
|
}
|
|
68261
68262
|
return false;
|
|
68262
68263
|
}
|
|
68263
|
-
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer) {
|
|
68264
|
+
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, flowNode) {
|
|
68264
68265
|
if (initialType === void 0) { initialType = declaredType; }
|
|
68266
|
+
if (flowNode === void 0) { flowNode = reference.flowNode; }
|
|
68265
68267
|
var key;
|
|
68266
68268
|
var isKeySet = false;
|
|
68267
68269
|
var flowDepth = 0;
|
|
68268
68270
|
if (flowAnalysisDisabled) {
|
|
68269
68271
|
return errorType;
|
|
68270
68272
|
}
|
|
68271
|
-
if (!
|
|
68273
|
+
if (!flowNode) {
|
|
68272
68274
|
return declaredType;
|
|
68273
68275
|
}
|
|
68274
68276
|
flowInvocationCount++;
|
|
68275
68277
|
var sharedFlowStart = sharedFlowCount;
|
|
68276
|
-
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(
|
|
68278
|
+
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(flowNode));
|
|
68277
68279
|
sharedFlowCount = sharedFlowStart;
|
|
68278
68280
|
// When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation,
|
|
68279
68281
|
// we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations
|
|
@@ -68705,13 +68707,57 @@ var ts;
|
|
|
68705
68707
|
}
|
|
68706
68708
|
return result;
|
|
68707
68709
|
}
|
|
68710
|
+
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
68711
|
+
if (ts.isBindingPattern(reference)) {
|
|
68712
|
+
// When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
|
|
68713
|
+
// An identifier for a destructuring variable declared in the same binding pattern is a candidate.
|
|
68714
|
+
if (ts.isIdentifier(expr)) {
|
|
68715
|
+
var symbol = getResolvedSymbol(expr);
|
|
68716
|
+
var declaration = symbol.valueDeclaration;
|
|
68717
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
|
|
68718
|
+
return declaration;
|
|
68719
|
+
}
|
|
68720
|
+
}
|
|
68721
|
+
}
|
|
68722
|
+
else if (ts.isAccessExpression(expr)) {
|
|
68723
|
+
// An access expression is a candidate if the reference matches the left hand expression.
|
|
68724
|
+
if (isMatchingReference(reference, expr.expression)) {
|
|
68725
|
+
return expr;
|
|
68726
|
+
}
|
|
68727
|
+
}
|
|
68728
|
+
else if (ts.isIdentifier(expr)) {
|
|
68729
|
+
var symbol = getResolvedSymbol(expr);
|
|
68730
|
+
if (isConstVariable(symbol)) {
|
|
68731
|
+
var declaration = symbol.valueDeclaration;
|
|
68732
|
+
// Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
|
|
68733
|
+
if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer) &&
|
|
68734
|
+
isMatchingReference(reference, declaration.initializer.expression)) {
|
|
68735
|
+
return declaration.initializer;
|
|
68736
|
+
}
|
|
68737
|
+
// Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
|
|
68738
|
+
if (ts.isBindingElement(declaration) && !declaration.initializer) {
|
|
68739
|
+
var parent = declaration.parent.parent;
|
|
68740
|
+
if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer)) &&
|
|
68741
|
+
isMatchingReference(reference, parent.initializer)) {
|
|
68742
|
+
return declaration;
|
|
68743
|
+
}
|
|
68744
|
+
}
|
|
68745
|
+
}
|
|
68746
|
+
}
|
|
68747
|
+
return undefined;
|
|
68748
|
+
}
|
|
68708
68749
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
68709
|
-
var access, name;
|
|
68710
68750
|
var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
68711
|
-
|
|
68712
|
-
|
|
68713
|
-
|
|
68714
|
-
|
|
68751
|
+
if (type.flags & 1048576 /* Union */) {
|
|
68752
|
+
var access = getCandidateDiscriminantPropertyAccess(expr);
|
|
68753
|
+
if (access) {
|
|
68754
|
+
var name = getAccessedPropertyName(access);
|
|
68755
|
+
if (name && isDiscriminantProperty(type, name)) {
|
|
68756
|
+
return access;
|
|
68757
|
+
}
|
|
68758
|
+
}
|
|
68759
|
+
}
|
|
68760
|
+
return undefined;
|
|
68715
68761
|
}
|
|
68716
68762
|
function narrowTypeByDiscriminant(type, access, narrowType) {
|
|
68717
68763
|
var propName = getAccessedPropertyName(access);
|
|
@@ -69469,6 +69515,49 @@ var ts;
|
|
|
69469
69515
|
}
|
|
69470
69516
|
}
|
|
69471
69517
|
}
|
|
69518
|
+
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
69519
|
+
// If we have a non-rest binding element with no initializer declared as a const variable or a const-like
|
|
69520
|
+
// parameter (a parameter for which there are no assignments in the function body), and if the parent type
|
|
69521
|
+
// for the destructuring is a union type, one or more of the binding elements may represent discriminant
|
|
69522
|
+
// properties, and we want the effects of conditional checks on such discriminants to affect the types of
|
|
69523
|
+
// other binding elements from the same destructuring. Consider:
|
|
69524
|
+
//
|
|
69525
|
+
// type Action =
|
|
69526
|
+
// | { kind: 'A', payload: number }
|
|
69527
|
+
// | { kind: 'B', payload: string };
|
|
69528
|
+
//
|
|
69529
|
+
// function f1({ kind, payload }: Action) {
|
|
69530
|
+
// if (kind === 'A') {
|
|
69531
|
+
// payload.toFixed();
|
|
69532
|
+
// }
|
|
69533
|
+
// if (kind === 'B') {
|
|
69534
|
+
// payload.toUpperCase();
|
|
69535
|
+
// }
|
|
69536
|
+
// }
|
|
69537
|
+
//
|
|
69538
|
+
// Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
|
|
69539
|
+
// the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
|
|
69540
|
+
// as if it occurred in the specified location. We then recompute the narrowed binding element type by
|
|
69541
|
+
// destructuring from the narrowed parent type.
|
|
69542
|
+
var declaration = symbol.valueDeclaration;
|
|
69543
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
69544
|
+
var parent = declaration.parent.parent;
|
|
69545
|
+
if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
|
|
69546
|
+
var links = getNodeLinks(location);
|
|
69547
|
+
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69548
|
+
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69549
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
69550
|
+
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69551
|
+
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69552
|
+
var pattern = declaration.parent;
|
|
69553
|
+
var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
|
|
69554
|
+
return getBindingElementTypeFromParentType(declaration, narrowedType);
|
|
69555
|
+
}
|
|
69556
|
+
}
|
|
69557
|
+
}
|
|
69558
|
+
}
|
|
69559
|
+
return getTypeOfSymbol(symbol);
|
|
69560
|
+
}
|
|
69472
69561
|
function checkIdentifier(node, checkMode) {
|
|
69473
69562
|
var symbol = getResolvedSymbol(node);
|
|
69474
69563
|
if (symbol === unknownSymbol) {
|
|
@@ -69542,7 +69631,7 @@ var ts;
|
|
|
69542
69631
|
}
|
|
69543
69632
|
}
|
|
69544
69633
|
checkNestedBlockScopedBinding(node, symbol);
|
|
69545
|
-
var type =
|
|
69634
|
+
var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
69546
69635
|
var assignmentKind = ts.getAssignmentTargetKind(node);
|
|
69547
69636
|
if (assignmentKind) {
|
|
69548
69637
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) &&
|
|
@@ -70585,13 +70674,13 @@ var ts;
|
|
|
70585
70674
|
function isCircularMappedProperty(symbol) {
|
|
70586
70675
|
return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
|
|
70587
70676
|
}
|
|
70588
|
-
function getTypeOfPropertyOfContextualType(type, name) {
|
|
70677
|
+
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
70589
70678
|
return mapType(type, function (t) {
|
|
70590
70679
|
var _a;
|
|
70591
70680
|
if (isGenericMappedType(t)) {
|
|
70592
70681
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
70593
70682
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
70594
|
-
var propertyNameType = getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
70683
|
+
var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
70595
70684
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
70596
70685
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
70597
70686
|
}
|
|
@@ -70607,7 +70696,7 @@ var ts;
|
|
|
70607
70696
|
return restType;
|
|
70608
70697
|
}
|
|
70609
70698
|
}
|
|
70610
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
70699
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
70611
70700
|
}
|
|
70612
70701
|
return undefined;
|
|
70613
70702
|
}, /*noReductions*/ true);
|
|
@@ -70635,7 +70724,8 @@ var ts;
|
|
|
70635
70724
|
// For a (non-symbol) computed property, there is no reason to look up the name
|
|
70636
70725
|
// in the type. It will just be "__computed", which does not appear in any
|
|
70637
70726
|
// SymbolTable.
|
|
70638
|
-
|
|
70727
|
+
var symbol = getSymbolOfNode(element);
|
|
70728
|
+
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
70639
70729
|
}
|
|
70640
70730
|
if (element.name) {
|
|
70641
70731
|
var nameType_2 = getLiteralTypeFromPropertyName(element.name);
|
|
@@ -78346,7 +78436,9 @@ var ts;
|
|
|
78346
78436
|
var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
|
|
78347
78437
|
if (!typeReferenceNode)
|
|
78348
78438
|
return undefined;
|
|
78349
|
-
var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
|
|
78439
|
+
var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
|
|
78440
|
+
if (!typeParameters)
|
|
78441
|
+
return undefined;
|
|
78350
78442
|
var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
|
|
78351
78443
|
return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
|
|
78352
78444
|
}
|
|
@@ -82756,8 +82848,11 @@ var ts;
|
|
|
82756
82848
|
function checkAssertClause(declaration) {
|
|
82757
82849
|
var _a;
|
|
82758
82850
|
if (declaration.assertClause) {
|
|
82759
|
-
|
|
82760
|
-
|
|
82851
|
+
var mode = (moduleKind === ts.ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
82852
|
+
if (mode !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.ESNext) {
|
|
82853
|
+
return grammarErrorOnNode(declaration.assertClause, moduleKind === ts.ModuleKind.NodeNext
|
|
82854
|
+
? ts.Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls
|
|
82855
|
+
: ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
82761
82856
|
}
|
|
82762
82857
|
if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
|
|
82763
82858
|
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports);
|
|
@@ -86604,12 +86699,12 @@ var ts;
|
|
|
86604
86699
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
86605
86700
|
}
|
|
86606
86701
|
var nodeArguments = node.arguments;
|
|
86607
|
-
if (moduleKind !== ts.ModuleKind.ESNext) {
|
|
86702
|
+
if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
|
|
86608
86703
|
// We are allowed trailing comma after proposal-import-assertions.
|
|
86609
86704
|
checkGrammarForDisallowedTrailingComma(nodeArguments);
|
|
86610
86705
|
if (nodeArguments.length > 1) {
|
|
86611
86706
|
var assertionArgument = nodeArguments[1];
|
|
86612
|
-
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.
|
|
86707
|
+
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
86613
86708
|
}
|
|
86614
86709
|
}
|
|
86615
86710
|
if (nodeArguments.length === 0 || nodeArguments.length > 2) {
|
|
@@ -119342,13 +119437,15 @@ var ts;
|
|
|
119342
119437
|
if (host.fileExists(packageJsonPath)) {
|
|
119343
119438
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119344
119439
|
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119345
|
-
|
|
119346
|
-
|
|
119347
|
-
|
|
119348
|
-
|
|
119349
|
-
|
|
119350
|
-
|
|
119351
|
-
|
|
119440
|
+
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
119441
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119442
|
+
if (fromExports) {
|
|
119443
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119444
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119445
|
+
}
|
|
119446
|
+
if (packageJsonContent.exports) {
|
|
119447
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119448
|
+
}
|
|
119352
119449
|
}
|
|
119353
119450
|
var versionPaths = packageJsonContent.typesVersions
|
|
119354
119451
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.6.0-dev.20211104",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|