typescript 4.6.0-dev.20211102 → 4.6.0-dev.20211103
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 +142 -81
- package/lib/tsserver.js +193 -101
- package/lib/tsserverlibrary.js +193 -101
- package/lib/typescript.js +193 -101
- package/lib/typescriptServices.js +193 -101
- package/lib/typingsInstaller.js +193 -101
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
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.20211103";
|
|
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
|
}
|
|
@@ -67339,29 +67362,6 @@ var ts;
|
|
|
67339
67362
|
}
|
|
67340
67363
|
return false;
|
|
67341
67364
|
}
|
|
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
67365
|
function getAccessedPropertyName(access) {
|
|
67366
67366
|
var propertyName;
|
|
67367
67367
|
return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
|
|
@@ -68260,20 +68260,21 @@ var ts;
|
|
|
68260
68260
|
}
|
|
68261
68261
|
return false;
|
|
68262
68262
|
}
|
|
68263
|
-
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer) {
|
|
68263
|
+
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, flowNode) {
|
|
68264
68264
|
if (initialType === void 0) { initialType = declaredType; }
|
|
68265
|
+
if (flowNode === void 0) { flowNode = reference.flowNode; }
|
|
68265
68266
|
var key;
|
|
68266
68267
|
var isKeySet = false;
|
|
68267
68268
|
var flowDepth = 0;
|
|
68268
68269
|
if (flowAnalysisDisabled) {
|
|
68269
68270
|
return errorType;
|
|
68270
68271
|
}
|
|
68271
|
-
if (!
|
|
68272
|
+
if (!flowNode) {
|
|
68272
68273
|
return declaredType;
|
|
68273
68274
|
}
|
|
68274
68275
|
flowInvocationCount++;
|
|
68275
68276
|
var sharedFlowStart = sharedFlowCount;
|
|
68276
|
-
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(
|
|
68277
|
+
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(flowNode));
|
|
68277
68278
|
sharedFlowCount = sharedFlowStart;
|
|
68278
68279
|
// When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation,
|
|
68279
68280
|
// we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations
|
|
@@ -68705,13 +68706,57 @@ var ts;
|
|
|
68705
68706
|
}
|
|
68706
68707
|
return result;
|
|
68707
68708
|
}
|
|
68709
|
+
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
68710
|
+
if (ts.isBindingPattern(reference)) {
|
|
68711
|
+
// When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
|
|
68712
|
+
// An identifier for a destructuring variable declared in the same binding pattern is a candidate.
|
|
68713
|
+
if (ts.isIdentifier(expr)) {
|
|
68714
|
+
var symbol = getResolvedSymbol(expr);
|
|
68715
|
+
var declaration = symbol.valueDeclaration;
|
|
68716
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
|
|
68717
|
+
return declaration;
|
|
68718
|
+
}
|
|
68719
|
+
}
|
|
68720
|
+
}
|
|
68721
|
+
else if (ts.isAccessExpression(expr)) {
|
|
68722
|
+
// An access expression is a candidate if the reference matches the left hand expression.
|
|
68723
|
+
if (isMatchingReference(reference, expr.expression)) {
|
|
68724
|
+
return expr;
|
|
68725
|
+
}
|
|
68726
|
+
}
|
|
68727
|
+
else if (ts.isIdentifier(expr)) {
|
|
68728
|
+
var symbol = getResolvedSymbol(expr);
|
|
68729
|
+
if (isConstVariable(symbol)) {
|
|
68730
|
+
var declaration = symbol.valueDeclaration;
|
|
68731
|
+
// Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
|
|
68732
|
+
if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer) &&
|
|
68733
|
+
isMatchingReference(reference, declaration.initializer.expression)) {
|
|
68734
|
+
return declaration.initializer;
|
|
68735
|
+
}
|
|
68736
|
+
// Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
|
|
68737
|
+
if (ts.isBindingElement(declaration) && !declaration.initializer) {
|
|
68738
|
+
var parent = declaration.parent.parent;
|
|
68739
|
+
if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer)) &&
|
|
68740
|
+
isMatchingReference(reference, parent.initializer)) {
|
|
68741
|
+
return declaration;
|
|
68742
|
+
}
|
|
68743
|
+
}
|
|
68744
|
+
}
|
|
68745
|
+
}
|
|
68746
|
+
return undefined;
|
|
68747
|
+
}
|
|
68708
68748
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
68709
|
-
var access, name;
|
|
68710
68749
|
var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
68711
|
-
|
|
68712
|
-
|
|
68713
|
-
|
|
68714
|
-
|
|
68750
|
+
if (type.flags & 1048576 /* Union */) {
|
|
68751
|
+
var access = getCandidateDiscriminantPropertyAccess(expr);
|
|
68752
|
+
if (access) {
|
|
68753
|
+
var name = getAccessedPropertyName(access);
|
|
68754
|
+
if (name && isDiscriminantProperty(type, name)) {
|
|
68755
|
+
return access;
|
|
68756
|
+
}
|
|
68757
|
+
}
|
|
68758
|
+
}
|
|
68759
|
+
return undefined;
|
|
68715
68760
|
}
|
|
68716
68761
|
function narrowTypeByDiscriminant(type, access, narrowType) {
|
|
68717
68762
|
var propName = getAccessedPropertyName(access);
|
|
@@ -69469,6 +69514,49 @@ var ts;
|
|
|
69469
69514
|
}
|
|
69470
69515
|
}
|
|
69471
69516
|
}
|
|
69517
|
+
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
69518
|
+
// If we have a non-rest binding element with no initializer declared as a const variable or a const-like
|
|
69519
|
+
// parameter (a parameter for which there are no assignments in the function body), and if the parent type
|
|
69520
|
+
// for the destructuring is a union type, one or more of the binding elements may represent discriminant
|
|
69521
|
+
// properties, and we want the effects of conditional checks on such discriminants to affect the types of
|
|
69522
|
+
// other binding elements from the same destructuring. Consider:
|
|
69523
|
+
//
|
|
69524
|
+
// type Action =
|
|
69525
|
+
// | { kind: 'A', payload: number }
|
|
69526
|
+
// | { kind: 'B', payload: string };
|
|
69527
|
+
//
|
|
69528
|
+
// function f1({ kind, payload }: Action) {
|
|
69529
|
+
// if (kind === 'A') {
|
|
69530
|
+
// payload.toFixed();
|
|
69531
|
+
// }
|
|
69532
|
+
// if (kind === 'B') {
|
|
69533
|
+
// payload.toUpperCase();
|
|
69534
|
+
// }
|
|
69535
|
+
// }
|
|
69536
|
+
//
|
|
69537
|
+
// Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
|
|
69538
|
+
// the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
|
|
69539
|
+
// as if it occurred in the specified location. We then recompute the narrowed binding element type by
|
|
69540
|
+
// destructuring from the narrowed parent type.
|
|
69541
|
+
var declaration = symbol.valueDeclaration;
|
|
69542
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
69543
|
+
var parent = declaration.parent.parent;
|
|
69544
|
+
if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
|
|
69545
|
+
var links = getNodeLinks(location);
|
|
69546
|
+
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69547
|
+
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69548
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
69549
|
+
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69550
|
+
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69551
|
+
var pattern = declaration.parent;
|
|
69552
|
+
var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
|
|
69553
|
+
return getBindingElementTypeFromParentType(declaration, narrowedType);
|
|
69554
|
+
}
|
|
69555
|
+
}
|
|
69556
|
+
}
|
|
69557
|
+
}
|
|
69558
|
+
return getTypeOfSymbol(symbol);
|
|
69559
|
+
}
|
|
69472
69560
|
function checkIdentifier(node, checkMode) {
|
|
69473
69561
|
var symbol = getResolvedSymbol(node);
|
|
69474
69562
|
if (symbol === unknownSymbol) {
|
|
@@ -69542,7 +69630,7 @@ var ts;
|
|
|
69542
69630
|
}
|
|
69543
69631
|
}
|
|
69544
69632
|
checkNestedBlockScopedBinding(node, symbol);
|
|
69545
|
-
var type =
|
|
69633
|
+
var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
69546
69634
|
var assignmentKind = ts.getAssignmentTargetKind(node);
|
|
69547
69635
|
if (assignmentKind) {
|
|
69548
69636
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) &&
|
|
@@ -70585,13 +70673,13 @@ var ts;
|
|
|
70585
70673
|
function isCircularMappedProperty(symbol) {
|
|
70586
70674
|
return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
|
|
70587
70675
|
}
|
|
70588
|
-
function getTypeOfPropertyOfContextualType(type, name) {
|
|
70676
|
+
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
70589
70677
|
return mapType(type, function (t) {
|
|
70590
70678
|
var _a;
|
|
70591
70679
|
if (isGenericMappedType(t)) {
|
|
70592
70680
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
70593
70681
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
70594
|
-
var propertyNameType = getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
70682
|
+
var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
70595
70683
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
70596
70684
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
70597
70685
|
}
|
|
@@ -70607,7 +70695,7 @@ var ts;
|
|
|
70607
70695
|
return restType;
|
|
70608
70696
|
}
|
|
70609
70697
|
}
|
|
70610
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
70698
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
70611
70699
|
}
|
|
70612
70700
|
return undefined;
|
|
70613
70701
|
}, /*noReductions*/ true);
|
|
@@ -70635,7 +70723,8 @@ var ts;
|
|
|
70635
70723
|
// For a (non-symbol) computed property, there is no reason to look up the name
|
|
70636
70724
|
// in the type. It will just be "__computed", which does not appear in any
|
|
70637
70725
|
// SymbolTable.
|
|
70638
|
-
|
|
70726
|
+
var symbol = getSymbolOfNode(element);
|
|
70727
|
+
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
70639
70728
|
}
|
|
70640
70729
|
if (element.name) {
|
|
70641
70730
|
var nameType_2 = getLiteralTypeFromPropertyName(element.name);
|
|
@@ -82758,8 +82847,11 @@ var ts;
|
|
|
82758
82847
|
function checkAssertClause(declaration) {
|
|
82759
82848
|
var _a;
|
|
82760
82849
|
if (declaration.assertClause) {
|
|
82761
|
-
|
|
82762
|
-
|
|
82850
|
+
var mode = (moduleKind === ts.ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
82851
|
+
if (mode !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.ESNext) {
|
|
82852
|
+
return grammarErrorOnNode(declaration.assertClause, moduleKind === ts.ModuleKind.NodeNext
|
|
82853
|
+
? ts.Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls
|
|
82854
|
+
: ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
82763
82855
|
}
|
|
82764
82856
|
if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
|
|
82765
82857
|
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports);
|
|
@@ -86606,12 +86698,12 @@ var ts;
|
|
|
86606
86698
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
86607
86699
|
}
|
|
86608
86700
|
var nodeArguments = node.arguments;
|
|
86609
|
-
if (moduleKind !== ts.ModuleKind.ESNext) {
|
|
86701
|
+
if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
|
|
86610
86702
|
// We are allowed trailing comma after proposal-import-assertions.
|
|
86611
86703
|
checkGrammarForDisallowedTrailingComma(nodeArguments);
|
|
86612
86704
|
if (nodeArguments.length > 1) {
|
|
86613
86705
|
var assertionArgument = nodeArguments[1];
|
|
86614
|
-
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.
|
|
86706
|
+
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
86615
86707
|
}
|
|
86616
86708
|
}
|
|
86617
86709
|
if (nodeArguments.length === 0 || nodeArguments.length > 2) {
|
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.6.0-dev.
|
|
5
|
+
"version": "4.6.0-dev.20211103",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|