typescript 4.8.0-dev.20220527 → 4.8.0-dev.20220528
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 +211 -93
- package/lib/tsserver.js +248 -111
- package/lib/tsserverlibrary.js +248 -111
- package/lib/typescript.js +244 -107
- package/lib/typescriptServices.js +244 -107
- package/lib/typingsInstaller.js +241 -102
- 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.20220528";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -5090,6 +5090,11 @@ var ts;
|
|
|
5090
5090
|
// Flags that require TypeFlags.Union
|
|
5091
5091
|
/* @internal */
|
|
5092
5092
|
ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
5093
|
+
/* @internal */
|
|
5094
|
+
ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
5095
|
+
/* @internal */
|
|
5096
|
+
ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
5097
|
+
/* @internal */
|
|
5093
5098
|
// Flags that require TypeFlags.Intersection
|
|
5094
5099
|
/* @internal */
|
|
5095
5100
|
ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
@@ -8403,6 +8408,7 @@ var ts;
|
|
|
8403
8408
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8404
8409
|
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8405
8410
|
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8411
|
+
This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
|
|
8406
8412
|
The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8407
8413
|
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8408
8414
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
@@ -48536,6 +48542,7 @@ var ts;
|
|
|
48536
48542
|
var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
48537
48543
|
emptyTypeLiteralSymbol.members = ts.createSymbolTable();
|
|
48538
48544
|
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
48545
|
+
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
|
|
48539
48546
|
var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
48540
48547
|
emptyGenericType.instantiations = new ts.Map();
|
|
48541
48548
|
var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
@@ -58706,7 +58713,7 @@ var ts;
|
|
|
58706
58713
|
}
|
|
58707
58714
|
}
|
|
58708
58715
|
}
|
|
58709
|
-
else if (t.flags & 469892092 /* DisjointDomains */) {
|
|
58716
|
+
else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
58710
58717
|
hasDisjointDomainType = true;
|
|
58711
58718
|
}
|
|
58712
58719
|
}
|
|
@@ -58718,7 +58725,7 @@ var ts;
|
|
|
58718
58725
|
// intersection operation to reduce the union constraints.
|
|
58719
58726
|
for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
|
|
58720
58727
|
var t = types_6[_a];
|
|
58721
|
-
if (t.flags & 469892092 /* DisjointDomains */) {
|
|
58728
|
+
if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
58722
58729
|
constraints = ts.append(constraints, t);
|
|
58723
58730
|
}
|
|
58724
58731
|
}
|
|
@@ -61267,7 +61274,7 @@ var ts;
|
|
|
61267
61274
|
}
|
|
61268
61275
|
return includes;
|
|
61269
61276
|
}
|
|
61270
|
-
function
|
|
61277
|
+
function removeRedundantSupertypes(types, includes) {
|
|
61271
61278
|
var i = types.length;
|
|
61272
61279
|
while (i > 0) {
|
|
61273
61280
|
i--;
|
|
@@ -61275,7 +61282,9 @@ var ts;
|
|
|
61275
61282
|
var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
|
|
61276
61283
|
t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
|
|
61277
61284
|
t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
|
|
61278
|
-
t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol
|
|
61285
|
+
t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
|
|
61286
|
+
t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
|
|
61287
|
+
isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
|
|
61279
61288
|
if (remove) {
|
|
61280
61289
|
ts.orderedRemoveItemAt(types, i);
|
|
61281
61290
|
}
|
|
@@ -61397,7 +61406,7 @@ var ts;
|
|
|
61397
61406
|
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
|
61398
61407
|
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
|
61399
61408
|
// for intersections of types with signatures can be deterministic.
|
|
61400
|
-
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
61409
|
+
function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
|
|
61401
61410
|
var typeMembershipMap = new ts.Map();
|
|
61402
61411
|
var includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
61403
61412
|
var typeSet = ts.arrayFrom(typeMembershipMap.values());
|
|
@@ -61434,11 +61443,11 @@ var ts;
|
|
|
61434
61443
|
if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
|
|
61435
61444
|
includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
|
|
61436
61445
|
includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
|
|
61437
|
-
includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */
|
|
61438
|
-
|
|
61439
|
-
|
|
61440
|
-
|
|
61441
|
-
|
|
61446
|
+
includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
|
|
61447
|
+
includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
|
|
61448
|
+
includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
|
|
61449
|
+
if (!noSupertypeReduction)
|
|
61450
|
+
removeRedundantSupertypes(typeSet, includes);
|
|
61442
61451
|
}
|
|
61443
61452
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
61444
61453
|
typeSet[typeSet.indexOf(undefinedType)] = missingType;
|
|
@@ -61477,8 +61486,9 @@ var ts;
|
|
|
61477
61486
|
}
|
|
61478
61487
|
var constituents = getCrossProductIntersections(typeSet);
|
|
61479
61488
|
// We attach a denormalized origin type when at least one constituent of the cross-product union is an
|
|
61480
|
-
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions)
|
|
61481
|
-
|
|
61489
|
+
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
|
|
61490
|
+
// the denormalized origin has fewer constituents than the union itself.
|
|
61491
|
+
var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
|
|
61482
61492
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
61483
61493
|
}
|
|
61484
61494
|
}
|
|
@@ -61521,11 +61531,21 @@ var ts;
|
|
|
61521
61531
|
}
|
|
61522
61532
|
return intersections;
|
|
61523
61533
|
}
|
|
61534
|
+
function getConstituentCount(type) {
|
|
61535
|
+
return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
|
|
61536
|
+
type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
|
|
61537
|
+
getConstituentCountOfTypes(type.types);
|
|
61538
|
+
}
|
|
61539
|
+
function getConstituentCountOfTypes(types) {
|
|
61540
|
+
return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
|
|
61541
|
+
}
|
|
61524
61542
|
function getTypeFromIntersectionTypeNode(node) {
|
|
61525
61543
|
var links = getNodeLinks(node);
|
|
61526
61544
|
if (!links.resolvedType) {
|
|
61527
61545
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
61528
|
-
|
|
61546
|
+
var types = ts.map(node.types, getTypeFromTypeNode);
|
|
61547
|
+
var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
|
|
61548
|
+
links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
|
|
61529
61549
|
}
|
|
61530
61550
|
return links.resolvedType;
|
|
61531
61551
|
}
|
|
@@ -64311,6 +64331,17 @@ var ts;
|
|
|
64311
64331
|
return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
|
|
64312
64332
|
type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
|
|
64313
64333
|
}
|
|
64334
|
+
function isUnknownLikeUnionType(type) {
|
|
64335
|
+
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
64336
|
+
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
64337
|
+
var types = type.types;
|
|
64338
|
+
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
|
|
64339
|
+
types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
64340
|
+
}
|
|
64341
|
+
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
64342
|
+
}
|
|
64343
|
+
return false;
|
|
64344
|
+
}
|
|
64314
64345
|
function isStringIndexSignatureOnlyType(type) {
|
|
64315
64346
|
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
|
|
64316
64347
|
type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
|
|
@@ -64390,7 +64421,7 @@ var ts;
|
|
|
64390
64421
|
return true;
|
|
64391
64422
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
64392
64423
|
return true;
|
|
64393
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
|
|
64424
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
64394
64425
|
return true;
|
|
64395
64426
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
64396
64427
|
if (s & 1 /* Any */)
|
|
@@ -64400,6 +64431,9 @@ var ts;
|
|
|
64400
64431
|
// bit-flag enum types sometimes look like literal enum types with numeric literal values.
|
|
64401
64432
|
if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
|
|
64402
64433
|
return true;
|
|
64434
|
+
// Anything is assignable to a union containing undefined, null, and {}
|
|
64435
|
+
if (isUnknownLikeUnionType(target))
|
|
64436
|
+
return true;
|
|
64403
64437
|
}
|
|
64404
64438
|
return false;
|
|
64405
64439
|
}
|
|
@@ -64442,16 +64476,27 @@ var ts;
|
|
|
64442
64476
|
function getNormalizedType(type, writing) {
|
|
64443
64477
|
while (true) {
|
|
64444
64478
|
var t = isFreshLiteralType(type) ? type.regularType :
|
|
64445
|
-
ts.getObjectFlags(type) & 4 /* Reference */
|
|
64446
|
-
type.flags & 3145728 /* UnionOrIntersection */ ?
|
|
64479
|
+
ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
|
|
64480
|
+
type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
|
|
64447
64481
|
type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
|
|
64448
64482
|
type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
|
|
64449
64483
|
type;
|
|
64450
|
-
t = getSingleBaseForNonAugmentingSubtype(t) || t;
|
|
64451
64484
|
if (t === type)
|
|
64452
|
-
|
|
64485
|
+
return t;
|
|
64453
64486
|
type = t;
|
|
64454
64487
|
}
|
|
64488
|
+
}
|
|
64489
|
+
function getNormalizedUnionOrIntersectionType(type, writing) {
|
|
64490
|
+
var reduced = getReducedType(type);
|
|
64491
|
+
if (reduced !== type) {
|
|
64492
|
+
return reduced;
|
|
64493
|
+
}
|
|
64494
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
64495
|
+
var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
|
|
64496
|
+
if (normalizedTypes !== type.types) {
|
|
64497
|
+
return getIntersectionType(normalizedTypes);
|
|
64498
|
+
}
|
|
64499
|
+
}
|
|
64455
64500
|
return type;
|
|
64456
64501
|
}
|
|
64457
64502
|
/**
|
|
@@ -64898,6 +64943,7 @@ var ts;
|
|
|
64898
64943
|
return 0 /* False */;
|
|
64899
64944
|
}
|
|
64900
64945
|
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
64946
|
+
var _a, _b;
|
|
64901
64947
|
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
64902
64948
|
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
64903
64949
|
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
@@ -64938,6 +64984,9 @@ var ts;
|
|
|
64938
64984
|
return;
|
|
64939
64985
|
}
|
|
64940
64986
|
reportRelationError(headMessage, source, target);
|
|
64987
|
+
if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
|
|
64988
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
|
|
64989
|
+
}
|
|
64941
64990
|
}
|
|
64942
64991
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
64943
64992
|
if (!ts.tracing) {
|
|
@@ -65724,13 +65773,6 @@ var ts;
|
|
|
65724
65773
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
65725
65774
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
65726
65775
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
65727
|
-
if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
65728
|
-
// A type variable with no constraint is not related to the non-primitive object type.
|
|
65729
|
-
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
65730
|
-
resetErrorInfo(saveErrorInfo);
|
|
65731
|
-
return result;
|
|
65732
|
-
}
|
|
65733
|
-
}
|
|
65734
65776
|
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
|
|
65735
65777
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
65736
65778
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -67204,9 +67246,11 @@ var ts;
|
|
|
67204
67246
|
return getSupertypeOrUnion(types);
|
|
67205
67247
|
}
|
|
67206
67248
|
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
67207
|
-
|
|
67208
|
-
|
|
67209
|
-
getUnionType(types,
|
|
67249
|
+
if (primaryTypes.length) {
|
|
67250
|
+
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
67251
|
+
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
67252
|
+
}
|
|
67253
|
+
return getUnionType(types, 2 /* Subtype */);
|
|
67210
67254
|
}
|
|
67211
67255
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
67212
67256
|
function getCommonSubtype(types) {
|
|
@@ -67405,12 +67449,13 @@ var ts;
|
|
|
67405
67449
|
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
|
|
67406
67450
|
// no flags for all other types (including non-falsy literal types).
|
|
67407
67451
|
function getFalsyFlags(type) {
|
|
67408
|
-
|
|
67409
|
-
|
|
67410
|
-
|
|
67411
|
-
|
|
67412
|
-
|
|
67413
|
-
|
|
67452
|
+
var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
|
|
67453
|
+
return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
|
|
67454
|
+
t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
|
|
67455
|
+
t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
|
|
67456
|
+
t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
|
|
67457
|
+
t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
|
|
67458
|
+
t.flags & 117724 /* PossiblyFalsy */;
|
|
67414
67459
|
}
|
|
67415
67460
|
function removeDefinitelyFalsyTypes(type) {
|
|
67416
67461
|
return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
|
|
@@ -67450,20 +67495,22 @@ var ts;
|
|
|
67450
67495
|
return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
|
|
67451
67496
|
}
|
|
67452
67497
|
function getGlobalNonNullableTypeInstantiation(type) {
|
|
67453
|
-
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
|
|
67454
|
-
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
|
|
67455
|
-
// that isn't eliminated by a NonNullable<T> instantiation.
|
|
67456
|
-
var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
67457
67498
|
if (!deferredGlobalNonNullableTypeAlias) {
|
|
67458
67499
|
deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
|
|
67459
67500
|
}
|
|
67460
|
-
// If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
|
|
67461
67501
|
return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
|
|
67462
|
-
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [
|
|
67463
|
-
|
|
67502
|
+
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
|
|
67503
|
+
getIntersectionType([type, emptyObjectType]);
|
|
67464
67504
|
}
|
|
67465
67505
|
function getNonNullableType(type) {
|
|
67466
|
-
|
|
67506
|
+
if (strictNullChecks) {
|
|
67507
|
+
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
|
|
67508
|
+
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
|
|
67509
|
+
// that isn't eliminated by a NonNullable<T> instantiation.
|
|
67510
|
+
var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
67511
|
+
return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
|
|
67512
|
+
}
|
|
67513
|
+
return type;
|
|
67467
67514
|
}
|
|
67468
67515
|
function addOptionalTypeMarker(type) {
|
|
67469
67516
|
return strictNullChecks ? getUnionType([type, optionalType]) : type;
|
|
@@ -68144,13 +68191,40 @@ var ts;
|
|
|
68144
68191
|
return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
|
|
68145
68192
|
sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
|
|
68146
68193
|
}
|
|
68147
|
-
|
|
68194
|
+
/**
|
|
68195
|
+
* Tests whether the provided string can be parsed as a number.
|
|
68196
|
+
* @param s The string to test.
|
|
68197
|
+
* @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
|
|
68198
|
+
*/
|
|
68199
|
+
function isValidNumberString(s, roundTripOnly) {
|
|
68200
|
+
if (s === "")
|
|
68201
|
+
return false;
|
|
68202
|
+
var n = +s;
|
|
68203
|
+
return isFinite(n) && (!roundTripOnly || "" + n === s);
|
|
68204
|
+
}
|
|
68205
|
+
/**
|
|
68206
|
+
* @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
|
|
68207
|
+
*/
|
|
68208
|
+
function parseBigIntLiteralType(text) {
|
|
68209
|
+
var negative = text.startsWith("-");
|
|
68210
|
+
var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
|
|
68211
|
+
return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
|
|
68212
|
+
}
|
|
68213
|
+
/**
|
|
68214
|
+
* Tests whether the provided string can be parsed as a bigint.
|
|
68215
|
+
* @param s The string to test.
|
|
68216
|
+
* @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
|
|
68217
|
+
*/
|
|
68218
|
+
function isValidBigIntString(s, roundTripOnly) {
|
|
68219
|
+
if (s === "")
|
|
68220
|
+
return false;
|
|
68148
68221
|
var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
|
|
68149
68222
|
var success = true;
|
|
68150
68223
|
scanner.setOnError(function () { return success = false; });
|
|
68151
68224
|
scanner.setText(s + "n");
|
|
68152
68225
|
var result = scanner.scan();
|
|
68153
|
-
|
|
68226
|
+
var negative = result === 40 /* MinusToken */;
|
|
68227
|
+
if (negative) {
|
|
68154
68228
|
result = scanner.scan();
|
|
68155
68229
|
}
|
|
68156
68230
|
var flags = scanner.getTokenFlags();
|
|
@@ -68159,7 +68233,8 @@ var ts;
|
|
|
68159
68233
|
// * a bigint can be scanned, and that when it is scanned, it is
|
|
68160
68234
|
// * the full length of the input string (so the scanner is one character beyond the augmented input length)
|
|
68161
68235
|
// * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
|
|
68162
|
-
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68236
|
+
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68237
|
+
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68163
68238
|
}
|
|
68164
68239
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68165
68240
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
@@ -68167,8 +68242,8 @@ var ts;
|
|
|
68167
68242
|
}
|
|
68168
68243
|
if (source.flags & 128 /* StringLiteral */) {
|
|
68169
68244
|
var value = source.value;
|
|
68170
|
-
return !!(target.flags & 8 /* Number */ && value
|
|
68171
|
-
target.flags & 64 /* BigInt */ && value
|
|
68245
|
+
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68246
|
+
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68172
68247
|
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
|
|
68173
68248
|
}
|
|
68174
68249
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -68741,8 +68816,57 @@ var ts;
|
|
|
68741
68816
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
68742
68817
|
// succeed. That would be a pointless and confusing outcome.
|
|
68743
68818
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
68819
|
+
var _loop_23 = function (i) {
|
|
68820
|
+
var source_1 = matches ? matches[i] : neverType;
|
|
68821
|
+
var target_3 = types[i];
|
|
68822
|
+
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
68823
|
+
// allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
|
|
68824
|
+
if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
|
|
68825
|
+
var inferenceContext = getInferenceInfoForType(target_3);
|
|
68826
|
+
var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
|
|
68827
|
+
if (constraint && !isTypeAny(constraint)) {
|
|
68828
|
+
var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
68829
|
+
var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
|
|
68830
|
+
// If the constraint contains `string`, we don't need to look for a more preferred type
|
|
68831
|
+
if (!(allTypeFlags_1 & 4 /* String */)) {
|
|
68832
|
+
var str_1 = source_1.value;
|
|
68833
|
+
// If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
|
|
68834
|
+
if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
|
|
68835
|
+
allTypeFlags_1 &= ~296 /* NumberLike */;
|
|
68836
|
+
}
|
|
68837
|
+
// If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
|
|
68838
|
+
if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
|
|
68839
|
+
allTypeFlags_1 &= ~2112 /* BigIntLike */;
|
|
68840
|
+
}
|
|
68841
|
+
// for each type in the constraint, find the highest priority matching type
|
|
68842
|
+
var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
|
|
68843
|
+
return !(right.flags & allTypeFlags_1) ? left :
|
|
68844
|
+
left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
|
|
68845
|
+
left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
|
|
68846
|
+
left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
|
|
68847
|
+
left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
|
|
68848
|
+
left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
|
|
68849
|
+
left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
|
|
68850
|
+
left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
|
|
68851
|
+
left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
|
|
68852
|
+
left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
|
|
68853
|
+
left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
|
|
68854
|
+
left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
|
|
68855
|
+
left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
|
|
68856
|
+
left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
|
|
68857
|
+
left;
|
|
68858
|
+
}, neverType);
|
|
68859
|
+
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
68860
|
+
inferFromTypes(matchingType, target_3);
|
|
68861
|
+
return "continue";
|
|
68862
|
+
}
|
|
68863
|
+
}
|
|
68864
|
+
}
|
|
68865
|
+
}
|
|
68866
|
+
inferFromTypes(source_1, target_3);
|
|
68867
|
+
};
|
|
68744
68868
|
for (var i = 0; i < types.length; i++) {
|
|
68745
|
-
|
|
68869
|
+
_loop_23(i);
|
|
68746
68870
|
}
|
|
68747
68871
|
}
|
|
68748
68872
|
}
|
|
@@ -69260,7 +69384,7 @@ var ts;
|
|
|
69260
69384
|
function mapTypesByKeyProperty(types, name) {
|
|
69261
69385
|
var map = new ts.Map();
|
|
69262
69386
|
var count = 0;
|
|
69263
|
-
var
|
|
69387
|
+
var _loop_24 = function (type) {
|
|
69264
69388
|
if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
|
|
69265
69389
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
69266
69390
|
if (discriminant) {
|
|
@@ -69286,7 +69410,7 @@ var ts;
|
|
|
69286
69410
|
};
|
|
69287
69411
|
for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
|
|
69288
69412
|
var type = types_16[_i];
|
|
69289
|
-
var state_9 =
|
|
69413
|
+
var state_9 = _loop_24(type);
|
|
69290
69414
|
if (typeof state_9 === "object")
|
|
69291
69415
|
return state_9.value;
|
|
69292
69416
|
}
|
|
@@ -69494,6 +69618,24 @@ var ts;
|
|
|
69494
69618
|
function getTypeWithFacts(type, include) {
|
|
69495
69619
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
69496
69620
|
}
|
|
69621
|
+
function getIntersectionWithFacts(type, facts) {
|
|
69622
|
+
var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
69623
|
+
if (strictNullChecks) {
|
|
69624
|
+
switch (facts) {
|
|
69625
|
+
case 524288 /* NEUndefined */:
|
|
69626
|
+
return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; });
|
|
69627
|
+
case 1048576 /* NENull */:
|
|
69628
|
+
return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; });
|
|
69629
|
+
case 2097152 /* NEUndefinedOrNull */:
|
|
69630
|
+
case 4194304 /* Truthy */:
|
|
69631
|
+
return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
|
|
69632
|
+
}
|
|
69633
|
+
}
|
|
69634
|
+
return reduced;
|
|
69635
|
+
}
|
|
69636
|
+
function recombineUnknownType(type) {
|
|
69637
|
+
return type === unknownUnionType ? unknownType : type;
|
|
69638
|
+
}
|
|
69497
69639
|
function getTypeWithDefault(type, defaultExpression) {
|
|
69498
69640
|
return defaultExpression ?
|
|
69499
69641
|
getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
|
|
@@ -70551,7 +70693,7 @@ var ts;
|
|
|
70551
70693
|
if (isEvolvingArrayTypeList(types)) {
|
|
70552
70694
|
return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
|
|
70553
70695
|
}
|
|
70554
|
-
var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
|
|
70696
|
+
var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
|
|
70555
70697
|
if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
|
|
70556
70698
|
return declaredType;
|
|
70557
70699
|
}
|
|
@@ -70653,8 +70795,7 @@ var ts;
|
|
|
70653
70795
|
}
|
|
70654
70796
|
function narrowTypeByTruthiness(type, expr, assumeTrue) {
|
|
70655
70797
|
if (isMatchingReference(reference, expr)) {
|
|
70656
|
-
return type
|
|
70657
|
-
getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
|
|
70798
|
+
return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
|
|
70658
70799
|
}
|
|
70659
70800
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
|
|
70660
70801
|
type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
@@ -70807,9 +70948,6 @@ var ts;
|
|
|
70807
70948
|
assumeTrue = !assumeTrue;
|
|
70808
70949
|
}
|
|
70809
70950
|
var valueType = getTypeOfExpression(value);
|
|
70810
|
-
if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
|
|
70811
|
-
return getUnionType([nullType, undefinedType]);
|
|
70812
|
-
}
|
|
70813
70951
|
if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
|
|
70814
70952
|
if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
|
|
70815
70953
|
return valueType;
|
|
@@ -70829,7 +70967,7 @@ var ts;
|
|
|
70829
70967
|
valueType.flags & 65536 /* Null */ ?
|
|
70830
70968
|
assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
|
|
70831
70969
|
assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
70832
|
-
return
|
|
70970
|
+
return getIntersectionWithFacts(type, facts);
|
|
70833
70971
|
}
|
|
70834
70972
|
if (assumeTrue) {
|
|
70835
70973
|
var filterFn = operator === 34 /* EqualsEqualsToken */ ?
|
|
@@ -70857,17 +70995,11 @@ var ts;
|
|
|
70857
70995
|
if (type.flags & 1 /* Any */ && literal.text === "function") {
|
|
70858
70996
|
return type;
|
|
70859
70997
|
}
|
|
70860
|
-
if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
|
|
70861
|
-
// The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
|
|
70862
|
-
// from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
|
|
70863
|
-
// unknown type, and then narrows that to the non-primitive type.
|
|
70864
|
-
return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
|
|
70865
|
-
}
|
|
70866
70998
|
var facts = assumeTrue ?
|
|
70867
70999
|
typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
|
|
70868
71000
|
typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
|
|
70869
71001
|
var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
|
|
70870
|
-
return getTypeWithFacts(assumeTrue && impliedType ?
|
|
71002
|
+
return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
|
|
70871
71003
|
}
|
|
70872
71004
|
function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
|
|
70873
71005
|
var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
|
|
@@ -70916,10 +71048,10 @@ var ts;
|
|
|
70916
71048
|
}
|
|
70917
71049
|
function getImpliedTypeFromTypeofGuard(type, text) {
|
|
70918
71050
|
switch (text) {
|
|
71051
|
+
case "object":
|
|
71052
|
+
return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
|
|
70919
71053
|
case "function":
|
|
70920
71054
|
return type.flags & 1 /* Any */ ? type : globalFunctionType;
|
|
70921
|
-
case "object":
|
|
70922
|
-
return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
|
|
70923
71055
|
default:
|
|
70924
71056
|
return typeofTypesByName.get(text);
|
|
70925
71057
|
}
|
|
@@ -70930,22 +71062,27 @@ var ts;
|
|
|
70930
71062
|
// the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
|
|
70931
71063
|
// the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
|
|
70932
71064
|
// filtering by type-facts.
|
|
70933
|
-
function
|
|
70934
|
-
|
|
70935
|
-
|
|
70936
|
-
|
|
70937
|
-
|
|
70938
|
-
if (
|
|
70939
|
-
return
|
|
71065
|
+
function narrowTypeByImpliedType(type, candidate) {
|
|
71066
|
+
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
71067
|
+
return candidate;
|
|
71068
|
+
}
|
|
71069
|
+
return mapType(type, function (t) {
|
|
71070
|
+
if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
|
|
71071
|
+
return t;
|
|
70940
71072
|
}
|
|
70941
|
-
|
|
70942
|
-
|
|
70943
|
-
|
|
70944
|
-
return getIntersectionType([type, candidate]);
|
|
71073
|
+
return mapType(candidate, function (c) {
|
|
71074
|
+
if (!areTypesComparable(t, c)) {
|
|
71075
|
+
return neverType;
|
|
70945
71076
|
}
|
|
70946
|
-
|
|
70947
|
-
|
|
70948
|
-
|
|
71077
|
+
if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
|
|
71078
|
+
return isTypeSubtypeOf(c, t) ? c : neverType;
|
|
71079
|
+
}
|
|
71080
|
+
if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
|
|
71081
|
+
return c;
|
|
71082
|
+
}
|
|
71083
|
+
return getIntersectionType([t, c]);
|
|
71084
|
+
});
|
|
71085
|
+
});
|
|
70949
71086
|
}
|
|
70950
71087
|
function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
|
|
70951
71088
|
var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
|
|
@@ -71004,7 +71141,7 @@ var ts;
|
|
|
71004
71141
|
because it is caught in the first clause.
|
|
71005
71142
|
*/
|
|
71006
71143
|
var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
|
|
71007
|
-
return getTypeWithFacts(
|
|
71144
|
+
return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
|
|
71008
71145
|
}
|
|
71009
71146
|
function isMatchingConstructorReference(expr) {
|
|
71010
71147
|
return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
|
|
@@ -71308,7 +71445,9 @@ var ts;
|
|
|
71308
71445
|
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
71309
71446
|
}
|
|
71310
71447
|
function isGenericTypeWithUnionConstraint(type) {
|
|
71311
|
-
return
|
|
71448
|
+
return type.flags & 2097152 /* Intersection */ ?
|
|
71449
|
+
ts.some(type.types, isGenericTypeWithUnionConstraint) :
|
|
71450
|
+
!!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
71312
71451
|
}
|
|
71313
71452
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
71314
71453
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
@@ -71336,7 +71475,7 @@ var ts;
|
|
|
71336
71475
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
71337
71476
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
71338
71477
|
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
71339
|
-
return substituteConstraints ? mapType(type,
|
|
71478
|
+
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
71340
71479
|
}
|
|
71341
71480
|
function isExportOrExportExpression(location) {
|
|
71342
71481
|
return !!ts.findAncestor(location, function (n) {
|
|
@@ -75674,7 +75813,7 @@ var ts;
|
|
|
75674
75813
|
if (spreadIndex >= 0) {
|
|
75675
75814
|
// Create synthetic arguments from spreads of tuple types.
|
|
75676
75815
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
75677
|
-
var
|
|
75816
|
+
var _loop_25 = function (i) {
|
|
75678
75817
|
var arg = args[i];
|
|
75679
75818
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
75680
75819
|
var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -75691,7 +75830,7 @@ var ts;
|
|
|
75691
75830
|
}
|
|
75692
75831
|
};
|
|
75693
75832
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
75694
|
-
|
|
75833
|
+
_loop_25(i);
|
|
75695
75834
|
}
|
|
75696
75835
|
return effectiveArgs_1;
|
|
75697
75836
|
}
|
|
@@ -76011,7 +76150,7 @@ var ts;
|
|
|
76011
76150
|
var min_3 = Number.MAX_VALUE;
|
|
76012
76151
|
var minIndex = 0;
|
|
76013
76152
|
var i_1 = 0;
|
|
76014
|
-
var
|
|
76153
|
+
var _loop_26 = function (c) {
|
|
76015
76154
|
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
|
76016
76155
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
|
76017
76156
|
if (diags_2) {
|
|
@@ -76029,7 +76168,7 @@ var ts;
|
|
|
76029
76168
|
};
|
|
76030
76169
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
76031
76170
|
var c = candidatesForArgumentError_1[_a];
|
|
76032
|
-
|
|
76171
|
+
_loop_26(c);
|
|
76033
76172
|
}
|
|
76034
76173
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
76035
76174
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -76187,7 +76326,7 @@ var ts;
|
|
|
76187
76326
|
}
|
|
76188
76327
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
76189
76328
|
var parameters = [];
|
|
76190
|
-
var
|
|
76329
|
+
var _loop_27 = function (i) {
|
|
76191
76330
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
76192
76331
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
76193
76332
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -76195,7 +76334,7 @@ var ts;
|
|
|
76195
76334
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
76196
76335
|
};
|
|
76197
76336
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
76198
|
-
|
|
76337
|
+
_loop_27(i);
|
|
76199
76338
|
}
|
|
76200
76339
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
76201
76340
|
var flags = 0 /* None */;
|
|
@@ -80252,7 +80391,7 @@ var ts;
|
|
|
80252
80391
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
80253
80392
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
80254
80393
|
var indexSignatureMap_1 = new ts.Map();
|
|
80255
|
-
var
|
|
80394
|
+
var _loop_28 = function (declaration) {
|
|
80256
80395
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
80257
80396
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
80258
80397
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -80267,7 +80406,7 @@ var ts;
|
|
|
80267
80406
|
};
|
|
80268
80407
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
80269
80408
|
var declaration = _a[_i];
|
|
80270
|
-
|
|
80409
|
+
_loop_28(declaration);
|
|
80271
80410
|
}
|
|
80272
80411
|
indexSignatureMap_1.forEach(function (entry) {
|
|
80273
80412
|
if (entry.declarations.length > 1) {
|
|
@@ -83728,7 +83867,7 @@ var ts;
|
|
|
83728
83867
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
|
|
83729
83868
|
var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
|
|
83730
83869
|
name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
83731
|
-
var
|
|
83870
|
+
var _loop_29 = function (info) {
|
|
83732
83871
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
83733
83872
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
83734
83873
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -83741,7 +83880,7 @@ var ts;
|
|
|
83741
83880
|
};
|
|
83742
83881
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
83743
83882
|
var info = indexInfos_9[_i];
|
|
83744
|
-
|
|
83883
|
+
_loop_29(info);
|
|
83745
83884
|
}
|
|
83746
83885
|
}
|
|
83747
83886
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -83749,7 +83888,7 @@ var ts;
|
|
|
83749
83888
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
83750
83889
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
|
|
83751
83890
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
83752
|
-
var
|
|
83891
|
+
var _loop_30 = function (info) {
|
|
83753
83892
|
if (info === checkInfo)
|
|
83754
83893
|
return "continue";
|
|
83755
83894
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -83764,7 +83903,7 @@ var ts;
|
|
|
83764
83903
|
};
|
|
83765
83904
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
83766
83905
|
var info = indexInfos_10[_i];
|
|
83767
|
-
|
|
83906
|
+
_loop_30(info);
|
|
83768
83907
|
}
|
|
83769
83908
|
}
|
|
83770
83909
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -84083,7 +84222,7 @@ var ts;
|
|
|
84083
84222
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
84084
84223
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
84085
84224
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
84086
|
-
var
|
|
84225
|
+
var _loop_31 = function (member) {
|
|
84087
84226
|
if (ts.hasAmbientModifier(member)) {
|
|
84088
84227
|
return "continue";
|
|
84089
84228
|
}
|
|
@@ -84100,7 +84239,7 @@ var ts;
|
|
|
84100
84239
|
};
|
|
84101
84240
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
84102
84241
|
var member = _a[_i];
|
|
84103
|
-
|
|
84242
|
+
_loop_31(member);
|
|
84104
84243
|
}
|
|
84105
84244
|
}
|
|
84106
84245
|
/**
|
|
@@ -84188,7 +84327,7 @@ var ts;
|
|
|
84188
84327
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
84189
84328
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
84190
84329
|
var issuedMemberError = false;
|
|
84191
|
-
var
|
|
84330
|
+
var _loop_32 = function (member) {
|
|
84192
84331
|
if (ts.isStatic(member)) {
|
|
84193
84332
|
return "continue";
|
|
84194
84333
|
}
|
|
@@ -84207,7 +84346,7 @@ var ts;
|
|
|
84207
84346
|
};
|
|
84208
84347
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
84209
84348
|
var member = _a[_i];
|
|
84210
|
-
|
|
84349
|
+
_loop_32(member);
|
|
84211
84350
|
}
|
|
84212
84351
|
if (!issuedMemberError) {
|
|
84213
84352
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -122175,7 +122314,7 @@ var ts;
|
|
|
122175
122314
|
});
|
|
122176
122315
|
// Sort by paths closest to importing file Name directory
|
|
122177
122316
|
var sortedPaths = [];
|
|
122178
|
-
var
|
|
122317
|
+
var _loop_33 = function (directory) {
|
|
122179
122318
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
122180
122319
|
var pathsInDirectory;
|
|
122181
122320
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -122199,7 +122338,7 @@ var ts;
|
|
|
122199
122338
|
};
|
|
122200
122339
|
var out_directory_1;
|
|
122201
122340
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
122202
|
-
var state_10 =
|
|
122341
|
+
var state_10 = _loop_33(directory);
|
|
122203
122342
|
directory = out_directory_1;
|
|
122204
122343
|
if (state_10 === "break")
|
|
122205
122344
|
break;
|