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/lib.es5.d.ts
CHANGED
package/lib/tsc.js
CHANGED
|
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
68
68
|
};
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
|
-
ts.versionMajorMinor = "4.
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
71
|
+
ts.versionMajorMinor = "4.6";
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211104";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
function tryGetNativeMap() {
|
|
@@ -5307,7 +5307,7 @@ var ts;
|
|
|
5307
5307
|
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."),
|
|
5308
5308
|
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."),
|
|
5309
5309
|
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'."),
|
|
5310
|
-
|
|
5310
|
+
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'."),
|
|
5311
5311
|
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."),
|
|
5312
5312
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
5313
5313
|
String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
|
|
@@ -5907,11 +5907,12 @@ var ts;
|
|
|
5907
5907
|
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."),
|
|
5908
5908
|
Namespace_name_cannot_be_0: diag(2819, ts.DiagnosticCategory.Error, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."),
|
|
5909
5909
|
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}'?"),
|
|
5910
|
-
|
|
5910
|
+
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'."),
|
|
5911
5911
|
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."),
|
|
5912
5912
|
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}'?"),
|
|
5913
5913
|
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."),
|
|
5914
5914
|
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}'?"),
|
|
5915
|
+
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."),
|
|
5915
5916
|
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}'."),
|
|
5916
5917
|
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}'."),
|
|
5917
5918
|
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}'."),
|
|
@@ -8720,6 +8721,7 @@ var ts;
|
|
|
8720
8721
|
tokenValue = tokenValue.slice(0, -1);
|
|
8721
8722
|
pos--;
|
|
8722
8723
|
}
|
|
8724
|
+
return getIdentifierToken();
|
|
8723
8725
|
}
|
|
8724
8726
|
return token;
|
|
8725
8727
|
}
|
|
@@ -44623,11 +44625,14 @@ var ts;
|
|
|
44623
44625
|
return type.flags & (128 | 256) ? "" + type.value : undefined;
|
|
44624
44626
|
}
|
|
44625
44627
|
function getTypeForBindingElement(declaration) {
|
|
44626
|
-
var
|
|
44627
|
-
|
|
44628
|
-
|
|
44628
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent);
|
|
44629
|
+
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
44630
|
+
}
|
|
44631
|
+
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
44632
|
+
if (isTypeAny(parentType)) {
|
|
44629
44633
|
return parentType;
|
|
44630
44634
|
}
|
|
44635
|
+
var pattern = declaration.parent;
|
|
44631
44636
|
if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) {
|
|
44632
44637
|
parentType = getNonNullableType(parentType);
|
|
44633
44638
|
}
|
|
@@ -49208,6 +49213,8 @@ var ts;
|
|
|
49208
49213
|
}
|
|
49209
49214
|
if (!(flags & 131072)) {
|
|
49210
49215
|
includes |= flags & 205258751;
|
|
49216
|
+
if (flags & 465829888)
|
|
49217
|
+
includes |= 33554432;
|
|
49211
49218
|
if (type === wildcardType)
|
|
49212
49219
|
includes |= 8388608;
|
|
49213
49220
|
if (!strictNullChecks && flags & 98304) {
|
|
@@ -49400,7 +49407,7 @@ var ts;
|
|
|
49400
49407
|
origin = createOriginUnionOrIntersectionType(1048576, reducedTypes);
|
|
49401
49408
|
}
|
|
49402
49409
|
}
|
|
49403
|
-
var objectFlags = (includes &
|
|
49410
|
+
var objectFlags = (includes & 36323363 ? 0 : 65536) |
|
|
49404
49411
|
(includes & 2097152 ? 33554432 : 0);
|
|
49405
49412
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
49406
49413
|
}
|
|
@@ -52260,7 +52267,7 @@ var ts;
|
|
|
52260
52267
|
return true;
|
|
52261
52268
|
}
|
|
52262
52269
|
if (source.flags & 524288 && target.flags & 524288) {
|
|
52263
|
-
var related = relation.get(getRelationKey(source, target, 0, relation));
|
|
52270
|
+
var related = relation.get(getRelationKey(source, target, 0, relation, false));
|
|
52264
52271
|
if (related !== undefined) {
|
|
52265
52272
|
return !!(related & 1);
|
|
52266
52273
|
}
|
|
@@ -52974,7 +52981,8 @@ var ts;
|
|
|
52974
52981
|
if (overflow) {
|
|
52975
52982
|
return 0;
|
|
52976
52983
|
}
|
|
52977
|
-
var
|
|
52984
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 : 0);
|
|
52985
|
+
var id = getRelationKey(source, target, keyIntersectionState, relation, false);
|
|
52978
52986
|
var entry = relation.get(id);
|
|
52979
52987
|
if (entry !== undefined) {
|
|
52980
52988
|
if (reportErrors && entry & 2 && !(entry & 4)) {
|
|
@@ -52998,12 +53006,9 @@ var ts;
|
|
|
52998
53006
|
targetStack = [];
|
|
52999
53007
|
}
|
|
53000
53008
|
else {
|
|
53001
|
-
var broadestEquivalentId = id.
|
|
53002
|
-
var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined);
|
|
53003
|
-
return "=" + index;
|
|
53004
|
-
}); }).join(",");
|
|
53009
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, true) : undefined;
|
|
53005
53010
|
for (var i = 0; i < maybeCount; i++) {
|
|
53006
|
-
if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
|
|
53011
|
+
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
53007
53012
|
return 3;
|
|
53008
53013
|
}
|
|
53009
53014
|
}
|
|
@@ -53245,7 +53250,7 @@ var ts;
|
|
|
53245
53250
|
originalErrorInfo = undefined;
|
|
53246
53251
|
}
|
|
53247
53252
|
}
|
|
53248
|
-
else if (isGenericMappedType(target)) {
|
|
53253
|
+
else if (isGenericMappedType(target) && relation !== identityRelation) {
|
|
53249
53254
|
var keysRemapped = !!target.declaration.nameType;
|
|
53250
53255
|
var templateType = getTemplateTypeFromMappedType(target);
|
|
53251
53256
|
var modifiers = getMappedTypeModifiers(target);
|
|
@@ -54277,40 +54282,48 @@ var ts;
|
|
|
54277
54282
|
function isTypeReferenceWithGenericArguments(type) {
|
|
54278
54283
|
return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144) || isTypeReferenceWithGenericArguments(t); });
|
|
54279
54284
|
}
|
|
54280
|
-
function
|
|
54281
|
-
|
|
54282
|
-
var
|
|
54283
|
-
|
|
54284
|
-
|
|
54285
|
-
|
|
54286
|
-
|
|
54287
|
-
|
|
54288
|
-
|
|
54289
|
-
|
|
54285
|
+
function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
|
|
54286
|
+
var typeParameters = [];
|
|
54287
|
+
var constraintMarker = "";
|
|
54288
|
+
var sourceId = getTypeReferenceId(source, 0);
|
|
54289
|
+
var targetId = getTypeReferenceId(target, 0);
|
|
54290
|
+
return "" + constraintMarker + sourceId + "," + targetId + postFix;
|
|
54291
|
+
function getTypeReferenceId(type, depth) {
|
|
54292
|
+
if (depth === void 0) { depth = 0; }
|
|
54293
|
+
var result = "" + type.target.id;
|
|
54294
|
+
for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
|
|
54295
|
+
var t = _a[_i];
|
|
54296
|
+
if (t.flags & 262144) {
|
|
54297
|
+
if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
|
|
54298
|
+
var index = typeParameters.indexOf(t);
|
|
54299
|
+
if (index < 0) {
|
|
54300
|
+
index = typeParameters.length;
|
|
54301
|
+
typeParameters.push(t);
|
|
54302
|
+
}
|
|
54303
|
+
result += "=" + index;
|
|
54304
|
+
continue;
|
|
54305
|
+
}
|
|
54306
|
+
constraintMarker = "*";
|
|
54307
|
+
}
|
|
54308
|
+
else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
|
|
54309
|
+
result += "<" + getTypeReferenceId(t, depth + 1) + ">";
|
|
54310
|
+
continue;
|
|
54290
54311
|
}
|
|
54291
|
-
result += "=" + index;
|
|
54292
|
-
}
|
|
54293
|
-
else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
|
|
54294
|
-
result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
|
|
54295
|
-
}
|
|
54296
|
-
else {
|
|
54297
54312
|
result += "-" + t.id;
|
|
54298
54313
|
}
|
|
54314
|
+
return result;
|
|
54299
54315
|
}
|
|
54300
|
-
return result;
|
|
54301
54316
|
}
|
|
54302
|
-
function getRelationKey(source, target, intersectionState, relation) {
|
|
54317
|
+
function getRelationKey(source, target, intersectionState, relation, ignoreConstraints) {
|
|
54303
54318
|
if (relation === identityRelation && source.id > target.id) {
|
|
54304
54319
|
var temp = source;
|
|
54305
54320
|
source = target;
|
|
54306
54321
|
target = temp;
|
|
54307
54322
|
}
|
|
54308
54323
|
var postFix = intersectionState ? ":" + intersectionState : "";
|
|
54309
|
-
|
|
54310
|
-
|
|
54311
|
-
|
|
54312
|
-
}
|
|
54313
|
-
return source.id + "," + target.id + postFix;
|
|
54324
|
+
return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ?
|
|
54325
|
+
getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) :
|
|
54326
|
+
source.id + "," + target.id + postFix;
|
|
54314
54327
|
}
|
|
54315
54328
|
function forEachProperty(prop, callback) {
|
|
54316
54329
|
if (ts.getCheckFlags(prop) & 6) {
|
|
@@ -54349,16 +54362,21 @@ var ts;
|
|
|
54349
54362
|
!hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
|
|
54350
54363
|
}
|
|
54351
54364
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
54352
|
-
if (maxDepth === void 0) { maxDepth =
|
|
54365
|
+
if (maxDepth === void 0) { maxDepth = 3; }
|
|
54353
54366
|
if (depth >= maxDepth) {
|
|
54354
54367
|
var identity_1 = getRecursionIdentity(type);
|
|
54355
54368
|
var count = 0;
|
|
54369
|
+
var lastTypeId = 0;
|
|
54356
54370
|
for (var i = 0; i < depth; i++) {
|
|
54357
|
-
|
|
54358
|
-
|
|
54359
|
-
if (
|
|
54360
|
-
|
|
54371
|
+
var t = stack[i];
|
|
54372
|
+
if (getRecursionIdentity(t) === identity_1) {
|
|
54373
|
+
if (t.id >= lastTypeId) {
|
|
54374
|
+
count++;
|
|
54375
|
+
if (count >= maxDepth) {
|
|
54376
|
+
return true;
|
|
54377
|
+
}
|
|
54361
54378
|
}
|
|
54379
|
+
lastTypeId = t.id;
|
|
54362
54380
|
}
|
|
54363
54381
|
}
|
|
54364
54382
|
}
|
|
@@ -54998,7 +55016,8 @@ var ts;
|
|
|
54998
55016
|
(resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) ||
|
|
54999
55017
|
param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
|
|
55000
55018
|
var newName = "arg" + param.parent.parameters.indexOf(param);
|
|
55001
|
-
|
|
55019
|
+
var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
|
|
55020
|
+
errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
|
|
55002
55021
|
return;
|
|
55003
55022
|
}
|
|
55004
55023
|
diagnostic = declaration.dotDotDotToken ?
|
|
@@ -56182,27 +56201,6 @@ var ts;
|
|
|
56182
56201
|
}
|
|
56183
56202
|
return false;
|
|
56184
56203
|
}
|
|
56185
|
-
function getPropertyAccess(expr) {
|
|
56186
|
-
if (ts.isAccessExpression(expr)) {
|
|
56187
|
-
return expr;
|
|
56188
|
-
}
|
|
56189
|
-
if (ts.isIdentifier(expr)) {
|
|
56190
|
-
var symbol = getResolvedSymbol(expr);
|
|
56191
|
-
if (isConstVariable(symbol)) {
|
|
56192
|
-
var declaration = symbol.valueDeclaration;
|
|
56193
|
-
if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer)) {
|
|
56194
|
-
return declaration.initializer;
|
|
56195
|
-
}
|
|
56196
|
-
if (ts.isBindingElement(declaration) && !declaration.initializer) {
|
|
56197
|
-
var parent = declaration.parent.parent;
|
|
56198
|
-
if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer))) {
|
|
56199
|
-
return declaration;
|
|
56200
|
-
}
|
|
56201
|
-
}
|
|
56202
|
-
}
|
|
56203
|
-
}
|
|
56204
|
-
return undefined;
|
|
56205
|
-
}
|
|
56206
56204
|
function getAccessedPropertyName(access) {
|
|
56207
56205
|
var propertyName;
|
|
56208
56206
|
return access.kind === 205 ? access.name.escapedText :
|
|
@@ -57037,20 +57035,21 @@ var ts;
|
|
|
57037
57035
|
}
|
|
57038
57036
|
return false;
|
|
57039
57037
|
}
|
|
57040
|
-
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer) {
|
|
57038
|
+
function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, flowNode) {
|
|
57041
57039
|
if (initialType === void 0) { initialType = declaredType; }
|
|
57040
|
+
if (flowNode === void 0) { flowNode = reference.flowNode; }
|
|
57042
57041
|
var key;
|
|
57043
57042
|
var isKeySet = false;
|
|
57044
57043
|
var flowDepth = 0;
|
|
57045
57044
|
if (flowAnalysisDisabled) {
|
|
57046
57045
|
return errorType;
|
|
57047
57046
|
}
|
|
57048
|
-
if (!
|
|
57047
|
+
if (!flowNode) {
|
|
57049
57048
|
return declaredType;
|
|
57050
57049
|
}
|
|
57051
57050
|
flowInvocationCount++;
|
|
57052
57051
|
var sharedFlowStart = sharedFlowCount;
|
|
57053
|
-
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(
|
|
57052
|
+
var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(flowNode));
|
|
57054
57053
|
sharedFlowCount = sharedFlowStart;
|
|
57055
57054
|
var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
|
|
57056
57055
|
if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 229 && !(resultType.flags & 131072) && getTypeWithFacts(resultType, 2097152).flags & 131072) {
|
|
@@ -57407,13 +57406,52 @@ var ts;
|
|
|
57407
57406
|
}
|
|
57408
57407
|
return result;
|
|
57409
57408
|
}
|
|
57409
|
+
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
57410
|
+
if (ts.isBindingPattern(reference)) {
|
|
57411
|
+
if (ts.isIdentifier(expr)) {
|
|
57412
|
+
var symbol = getResolvedSymbol(expr);
|
|
57413
|
+
var declaration = symbol.valueDeclaration;
|
|
57414
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
|
|
57415
|
+
return declaration;
|
|
57416
|
+
}
|
|
57417
|
+
}
|
|
57418
|
+
}
|
|
57419
|
+
else if (ts.isAccessExpression(expr)) {
|
|
57420
|
+
if (isMatchingReference(reference, expr.expression)) {
|
|
57421
|
+
return expr;
|
|
57422
|
+
}
|
|
57423
|
+
}
|
|
57424
|
+
else if (ts.isIdentifier(expr)) {
|
|
57425
|
+
var symbol = getResolvedSymbol(expr);
|
|
57426
|
+
if (isConstVariable(symbol)) {
|
|
57427
|
+
var declaration = symbol.valueDeclaration;
|
|
57428
|
+
if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer) &&
|
|
57429
|
+
isMatchingReference(reference, declaration.initializer.expression)) {
|
|
57430
|
+
return declaration.initializer;
|
|
57431
|
+
}
|
|
57432
|
+
if (ts.isBindingElement(declaration) && !declaration.initializer) {
|
|
57433
|
+
var parent = declaration.parent.parent;
|
|
57434
|
+
if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer)) &&
|
|
57435
|
+
isMatchingReference(reference, parent.initializer)) {
|
|
57436
|
+
return declaration;
|
|
57437
|
+
}
|
|
57438
|
+
}
|
|
57439
|
+
}
|
|
57440
|
+
}
|
|
57441
|
+
return undefined;
|
|
57442
|
+
}
|
|
57410
57443
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
57411
|
-
var access, name;
|
|
57412
57444
|
var type = declaredType.flags & 1048576 ? declaredType : computedType;
|
|
57413
|
-
|
|
57414
|
-
|
|
57415
|
-
|
|
57416
|
-
|
|
57445
|
+
if (type.flags & 1048576) {
|
|
57446
|
+
var access = getCandidateDiscriminantPropertyAccess(expr);
|
|
57447
|
+
if (access) {
|
|
57448
|
+
var name = getAccessedPropertyName(access);
|
|
57449
|
+
if (name && isDiscriminantProperty(type, name)) {
|
|
57450
|
+
return access;
|
|
57451
|
+
}
|
|
57452
|
+
}
|
|
57453
|
+
}
|
|
57454
|
+
return undefined;
|
|
57417
57455
|
}
|
|
57418
57456
|
function narrowTypeByDiscriminant(type, access, narrowType) {
|
|
57419
57457
|
var propName = getAccessedPropertyName(access);
|
|
@@ -58056,6 +58094,26 @@ var ts;
|
|
|
58056
58094
|
}
|
|
58057
58095
|
}
|
|
58058
58096
|
}
|
|
58097
|
+
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
58098
|
+
var declaration = symbol.valueDeclaration;
|
|
58099
|
+
if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
58100
|
+
var parent = declaration.parent.parent;
|
|
58101
|
+
if (parent.kind === 253 && ts.getCombinedNodeFlags(declaration) & 2 || parent.kind === 163) {
|
|
58102
|
+
var links = getNodeLinks(location);
|
|
58103
|
+
if (!(links.flags & 268435456)) {
|
|
58104
|
+
links.flags |= 268435456;
|
|
58105
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
58106
|
+
links.flags &= ~268435456;
|
|
58107
|
+
if (parentType && parentType.flags & 1048576 && !(parent.kind === 163 && isSymbolAssigned(symbol))) {
|
|
58108
|
+
var pattern = declaration.parent;
|
|
58109
|
+
var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, undefined, location.flowNode);
|
|
58110
|
+
return getBindingElementTypeFromParentType(declaration, narrowedType);
|
|
58111
|
+
}
|
|
58112
|
+
}
|
|
58113
|
+
}
|
|
58114
|
+
}
|
|
58115
|
+
return getTypeOfSymbol(symbol);
|
|
58116
|
+
}
|
|
58059
58117
|
function checkIdentifier(node, checkMode) {
|
|
58060
58118
|
var symbol = getResolvedSymbol(node);
|
|
58061
58119
|
if (symbol === unknownSymbol) {
|
|
@@ -58115,7 +58173,7 @@ var ts;
|
|
|
58115
58173
|
}
|
|
58116
58174
|
}
|
|
58117
58175
|
checkNestedBlockScopedBinding(node, symbol);
|
|
58118
|
-
var type =
|
|
58176
|
+
var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
58119
58177
|
var assignmentKind = ts.getAssignmentTargetKind(node);
|
|
58120
58178
|
if (assignmentKind) {
|
|
58121
58179
|
if (!(localOrExportSymbol.flags & 3) &&
|
|
@@ -58977,13 +59035,13 @@ var ts;
|
|
|
58977
59035
|
function isCircularMappedProperty(symbol) {
|
|
58978
59036
|
return !!(ts.getCheckFlags(symbol) & 262144 && !symbol.type && findResolutionCycleStartIndex(symbol, 0) >= 0);
|
|
58979
59037
|
}
|
|
58980
|
-
function getTypeOfPropertyOfContextualType(type, name) {
|
|
59038
|
+
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
58981
59039
|
return mapType(type, function (t) {
|
|
58982
59040
|
var _a;
|
|
58983
59041
|
if (isGenericMappedType(t)) {
|
|
58984
59042
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
58985
59043
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
58986
|
-
var propertyNameType = getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
59044
|
+
var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
58987
59045
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
58988
59046
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
58989
59047
|
}
|
|
@@ -58999,7 +59057,7 @@ var ts;
|
|
|
58999
59057
|
return restType;
|
|
59000
59058
|
}
|
|
59001
59059
|
}
|
|
59002
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
59060
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
59003
59061
|
}
|
|
59004
59062
|
return undefined;
|
|
59005
59063
|
}, true);
|
|
@@ -59020,7 +59078,8 @@ var ts;
|
|
|
59020
59078
|
var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
|
|
59021
59079
|
if (type) {
|
|
59022
59080
|
if (hasBindableName(element)) {
|
|
59023
|
-
|
|
59081
|
+
var symbol = getSymbolOfNode(element);
|
|
59082
|
+
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
59024
59083
|
}
|
|
59025
59084
|
if (element.name) {
|
|
59026
59085
|
var nameType_2 = getLiteralTypeFromPropertyName(element.name);
|
|
@@ -65693,6 +65752,8 @@ var ts;
|
|
|
65693
65752
|
if (!typeReferenceNode)
|
|
65694
65753
|
return undefined;
|
|
65695
65754
|
var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
|
|
65755
|
+
if (!typeParameters)
|
|
65756
|
+
return undefined;
|
|
65696
65757
|
var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
|
|
65697
65758
|
return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
|
|
65698
65759
|
}
|
|
@@ -69343,8 +69404,11 @@ var ts;
|
|
|
69343
69404
|
function checkAssertClause(declaration) {
|
|
69344
69405
|
var _a;
|
|
69345
69406
|
if (declaration.assertClause) {
|
|
69346
|
-
|
|
69347
|
-
|
|
69407
|
+
var mode = (moduleKind === ts.ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
69408
|
+
if (mode !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.ESNext) {
|
|
69409
|
+
return grammarErrorOnNode(declaration.assertClause, moduleKind === ts.ModuleKind.NodeNext
|
|
69410
|
+
? ts.Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls
|
|
69411
|
+
: ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
69348
69412
|
}
|
|
69349
69413
|
if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
|
|
69350
69414
|
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports);
|
|
@@ -72847,11 +72911,11 @@ var ts;
|
|
|
72847
72911
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
72848
72912
|
}
|
|
72849
72913
|
var nodeArguments = node.arguments;
|
|
72850
|
-
if (moduleKind !== ts.ModuleKind.ESNext) {
|
|
72914
|
+
if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
|
|
72851
72915
|
checkGrammarForDisallowedTrailingComma(nodeArguments);
|
|
72852
72916
|
if (nodeArguments.length > 1) {
|
|
72853
72917
|
var assertionArgument = nodeArguments[1];
|
|
72854
|
-
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.
|
|
72918
|
+
return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext);
|
|
72855
72919
|
}
|
|
72856
72920
|
}
|
|
72857
72921
|
if (nodeArguments.length === 0 || nodeArguments.length > 2) {
|
|
@@ -98616,13 +98680,15 @@ var ts;
|
|
|
98616
98680
|
var moduleFileToTry = path;
|
|
98617
98681
|
if (host.fileExists(packageJsonPath)) {
|
|
98618
98682
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
98619
|
-
|
|
98620
|
-
|
|
98621
|
-
|
|
98622
|
-
|
|
98623
|
-
|
|
98624
|
-
|
|
98625
|
-
|
|
98683
|
+
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
98684
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
98685
|
+
if (fromExports) {
|
|
98686
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
98687
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
98688
|
+
}
|
|
98689
|
+
if (packageJsonContent.exports) {
|
|
98690
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
98691
|
+
}
|
|
98626
98692
|
}
|
|
98627
98693
|
var versionPaths = packageJsonContent.typesVersions
|
|
98628
98694
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|