typescript 4.8.0-dev.20220527 → 4.8.0-dev.20220530
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/cs/diagnosticMessages.generated.json +1 -0
- package/lib/de/diagnosticMessages.generated.json +1 -0
- package/lib/es/diagnosticMessages.generated.json +1 -0
- package/lib/fr/diagnosticMessages.generated.json +1 -0
- package/lib/it/diagnosticMessages.generated.json +1 -0
- package/lib/ja/diagnosticMessages.generated.json +1 -0
- package/lib/ko/diagnosticMessages.generated.json +1 -0
- package/lib/lib.es5.d.ts +1 -1
- package/lib/pl/diagnosticMessages.generated.json +1 -0
- package/lib/pt-br/diagnosticMessages.generated.json +1 -0
- package/lib/ru/diagnosticMessages.generated.json +1 -0
- package/lib/tr/diagnosticMessages.generated.json +1 -0
- 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/lib/zh-cn/diagnosticMessages.generated.json +1 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +1 -0
- package/package.json +1 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220530";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -5295,6 +5295,11 @@ var ts;
|
|
|
5295
5295
|
// Flags that require TypeFlags.Union
|
|
5296
5296
|
/* @internal */
|
|
5297
5297
|
ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
5298
|
+
/* @internal */
|
|
5299
|
+
ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
5300
|
+
/* @internal */
|
|
5301
|
+
ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
5302
|
+
/* @internal */
|
|
5298
5303
|
// Flags that require TypeFlags.Intersection
|
|
5299
5304
|
/* @internal */
|
|
5300
5305
|
ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
@@ -8608,6 +8613,7 @@ var ts;
|
|
|
8608
8613
|
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),
|
|
8609
8614
|
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."),
|
|
8610
8615
|
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."),
|
|
8616
|
+
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."),
|
|
8611
8617
|
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."),
|
|
8612
8618
|
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."),
|
|
8613
8619
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
@@ -48741,6 +48747,7 @@ var ts;
|
|
|
48741
48747
|
var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
48742
48748
|
emptyTypeLiteralSymbol.members = ts.createSymbolTable();
|
|
48743
48749
|
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
48750
|
+
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
|
|
48744
48751
|
var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
48745
48752
|
emptyGenericType.instantiations = new ts.Map();
|
|
48746
48753
|
var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
@@ -58911,7 +58918,7 @@ var ts;
|
|
|
58911
58918
|
}
|
|
58912
58919
|
}
|
|
58913
58920
|
}
|
|
58914
|
-
else if (t.flags & 469892092 /* DisjointDomains */) {
|
|
58921
|
+
else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
58915
58922
|
hasDisjointDomainType = true;
|
|
58916
58923
|
}
|
|
58917
58924
|
}
|
|
@@ -58923,7 +58930,7 @@ var ts;
|
|
|
58923
58930
|
// intersection operation to reduce the union constraints.
|
|
58924
58931
|
for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
|
|
58925
58932
|
var t = types_6[_a];
|
|
58926
|
-
if (t.flags & 469892092 /* DisjointDomains */) {
|
|
58933
|
+
if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
58927
58934
|
constraints = ts.append(constraints, t);
|
|
58928
58935
|
}
|
|
58929
58936
|
}
|
|
@@ -61472,7 +61479,7 @@ var ts;
|
|
|
61472
61479
|
}
|
|
61473
61480
|
return includes;
|
|
61474
61481
|
}
|
|
61475
|
-
function
|
|
61482
|
+
function removeRedundantSupertypes(types, includes) {
|
|
61476
61483
|
var i = types.length;
|
|
61477
61484
|
while (i > 0) {
|
|
61478
61485
|
i--;
|
|
@@ -61480,7 +61487,9 @@ var ts;
|
|
|
61480
61487
|
var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
|
|
61481
61488
|
t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
|
|
61482
61489
|
t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
|
|
61483
|
-
t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol
|
|
61490
|
+
t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
|
|
61491
|
+
t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
|
|
61492
|
+
isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
|
|
61484
61493
|
if (remove) {
|
|
61485
61494
|
ts.orderedRemoveItemAt(types, i);
|
|
61486
61495
|
}
|
|
@@ -61602,7 +61611,7 @@ var ts;
|
|
|
61602
61611
|
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
|
61603
61612
|
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
|
61604
61613
|
// for intersections of types with signatures can be deterministic.
|
|
61605
|
-
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
61614
|
+
function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
|
|
61606
61615
|
var typeMembershipMap = new ts.Map();
|
|
61607
61616
|
var includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
61608
61617
|
var typeSet = ts.arrayFrom(typeMembershipMap.values());
|
|
@@ -61639,11 +61648,11 @@ var ts;
|
|
|
61639
61648
|
if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
|
|
61640
61649
|
includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
|
|
61641
61650
|
includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
|
|
61642
|
-
includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */
|
|
61643
|
-
|
|
61644
|
-
|
|
61645
|
-
|
|
61646
|
-
|
|
61651
|
+
includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
|
|
61652
|
+
includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
|
|
61653
|
+
includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
|
|
61654
|
+
if (!noSupertypeReduction)
|
|
61655
|
+
removeRedundantSupertypes(typeSet, includes);
|
|
61647
61656
|
}
|
|
61648
61657
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
61649
61658
|
typeSet[typeSet.indexOf(undefinedType)] = missingType;
|
|
@@ -61682,8 +61691,9 @@ var ts;
|
|
|
61682
61691
|
}
|
|
61683
61692
|
var constituents = getCrossProductIntersections(typeSet);
|
|
61684
61693
|
// We attach a denormalized origin type when at least one constituent of the cross-product union is an
|
|
61685
|
-
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions)
|
|
61686
|
-
|
|
61694
|
+
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
|
|
61695
|
+
// the denormalized origin has fewer constituents than the union itself.
|
|
61696
|
+
var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
|
|
61687
61697
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
61688
61698
|
}
|
|
61689
61699
|
}
|
|
@@ -61726,11 +61736,21 @@ var ts;
|
|
|
61726
61736
|
}
|
|
61727
61737
|
return intersections;
|
|
61728
61738
|
}
|
|
61739
|
+
function getConstituentCount(type) {
|
|
61740
|
+
return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
|
|
61741
|
+
type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
|
|
61742
|
+
getConstituentCountOfTypes(type.types);
|
|
61743
|
+
}
|
|
61744
|
+
function getConstituentCountOfTypes(types) {
|
|
61745
|
+
return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
|
|
61746
|
+
}
|
|
61729
61747
|
function getTypeFromIntersectionTypeNode(node) {
|
|
61730
61748
|
var links = getNodeLinks(node);
|
|
61731
61749
|
if (!links.resolvedType) {
|
|
61732
61750
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
61733
|
-
|
|
61751
|
+
var types = ts.map(node.types, getTypeFromTypeNode);
|
|
61752
|
+
var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
|
|
61753
|
+
links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
|
|
61734
61754
|
}
|
|
61735
61755
|
return links.resolvedType;
|
|
61736
61756
|
}
|
|
@@ -64516,6 +64536,17 @@ var ts;
|
|
|
64516
64536
|
return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
|
|
64517
64537
|
type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
|
|
64518
64538
|
}
|
|
64539
|
+
function isUnknownLikeUnionType(type) {
|
|
64540
|
+
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
64541
|
+
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
64542
|
+
var types = type.types;
|
|
64543
|
+
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
|
|
64544
|
+
types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
64545
|
+
}
|
|
64546
|
+
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
64547
|
+
}
|
|
64548
|
+
return false;
|
|
64549
|
+
}
|
|
64519
64550
|
function isStringIndexSignatureOnlyType(type) {
|
|
64520
64551
|
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
|
|
64521
64552
|
type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
|
|
@@ -64595,7 +64626,7 @@ var ts;
|
|
|
64595
64626
|
return true;
|
|
64596
64627
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
64597
64628
|
return true;
|
|
64598
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
|
|
64629
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
64599
64630
|
return true;
|
|
64600
64631
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
64601
64632
|
if (s & 1 /* Any */)
|
|
@@ -64605,6 +64636,9 @@ var ts;
|
|
|
64605
64636
|
// bit-flag enum types sometimes look like literal enum types with numeric literal values.
|
|
64606
64637
|
if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
|
|
64607
64638
|
return true;
|
|
64639
|
+
// Anything is assignable to a union containing undefined, null, and {}
|
|
64640
|
+
if (isUnknownLikeUnionType(target))
|
|
64641
|
+
return true;
|
|
64608
64642
|
}
|
|
64609
64643
|
return false;
|
|
64610
64644
|
}
|
|
@@ -64647,16 +64681,27 @@ var ts;
|
|
|
64647
64681
|
function getNormalizedType(type, writing) {
|
|
64648
64682
|
while (true) {
|
|
64649
64683
|
var t = isFreshLiteralType(type) ? type.regularType :
|
|
64650
|
-
ts.getObjectFlags(type) & 4 /* Reference */
|
|
64651
|
-
type.flags & 3145728 /* UnionOrIntersection */ ?
|
|
64684
|
+
ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
|
|
64685
|
+
type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
|
|
64652
64686
|
type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
|
|
64653
64687
|
type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
|
|
64654
64688
|
type;
|
|
64655
|
-
t = getSingleBaseForNonAugmentingSubtype(t) || t;
|
|
64656
64689
|
if (t === type)
|
|
64657
|
-
|
|
64690
|
+
return t;
|
|
64658
64691
|
type = t;
|
|
64659
64692
|
}
|
|
64693
|
+
}
|
|
64694
|
+
function getNormalizedUnionOrIntersectionType(type, writing) {
|
|
64695
|
+
var reduced = getReducedType(type);
|
|
64696
|
+
if (reduced !== type) {
|
|
64697
|
+
return reduced;
|
|
64698
|
+
}
|
|
64699
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
64700
|
+
var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
|
|
64701
|
+
if (normalizedTypes !== type.types) {
|
|
64702
|
+
return getIntersectionType(normalizedTypes);
|
|
64703
|
+
}
|
|
64704
|
+
}
|
|
64660
64705
|
return type;
|
|
64661
64706
|
}
|
|
64662
64707
|
/**
|
|
@@ -65103,6 +65148,7 @@ var ts;
|
|
|
65103
65148
|
return 0 /* False */;
|
|
65104
65149
|
}
|
|
65105
65150
|
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
65151
|
+
var _a, _b;
|
|
65106
65152
|
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
65107
65153
|
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
65108
65154
|
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
@@ -65143,6 +65189,9 @@ var ts;
|
|
|
65143
65189
|
return;
|
|
65144
65190
|
}
|
|
65145
65191
|
reportRelationError(headMessage, source, target);
|
|
65192
|
+
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 */))) {
|
|
65193
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
|
|
65194
|
+
}
|
|
65146
65195
|
}
|
|
65147
65196
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
65148
65197
|
if (!ts.tracing) {
|
|
@@ -65929,13 +65978,6 @@ var ts;
|
|
|
65929
65978
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
65930
65979
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
65931
65980
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
65932
|
-
if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
65933
|
-
// A type variable with no constraint is not related to the non-primitive object type.
|
|
65934
|
-
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
65935
|
-
resetErrorInfo(saveErrorInfo);
|
|
65936
|
-
return result;
|
|
65937
|
-
}
|
|
65938
|
-
}
|
|
65939
65981
|
// 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
|
|
65940
65982
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
65941
65983
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -67409,9 +67451,11 @@ var ts;
|
|
|
67409
67451
|
return getSupertypeOrUnion(types);
|
|
67410
67452
|
}
|
|
67411
67453
|
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
67412
|
-
|
|
67413
|
-
|
|
67414
|
-
getUnionType(types,
|
|
67454
|
+
if (primaryTypes.length) {
|
|
67455
|
+
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
67456
|
+
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
67457
|
+
}
|
|
67458
|
+
return getUnionType(types, 2 /* Subtype */);
|
|
67415
67459
|
}
|
|
67416
67460
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
67417
67461
|
function getCommonSubtype(types) {
|
|
@@ -67610,12 +67654,13 @@ var ts;
|
|
|
67610
67654
|
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
|
|
67611
67655
|
// no flags for all other types (including non-falsy literal types).
|
|
67612
67656
|
function getFalsyFlags(type) {
|
|
67613
|
-
|
|
67614
|
-
|
|
67615
|
-
|
|
67616
|
-
|
|
67617
|
-
|
|
67618
|
-
|
|
67657
|
+
var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
|
|
67658
|
+
return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
|
|
67659
|
+
t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
|
|
67660
|
+
t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
|
|
67661
|
+
t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
|
|
67662
|
+
t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
|
|
67663
|
+
t.flags & 117724 /* PossiblyFalsy */;
|
|
67619
67664
|
}
|
|
67620
67665
|
function removeDefinitelyFalsyTypes(type) {
|
|
67621
67666
|
return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
|
|
@@ -67655,20 +67700,22 @@ var ts;
|
|
|
67655
67700
|
return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
|
|
67656
67701
|
}
|
|
67657
67702
|
function getGlobalNonNullableTypeInstantiation(type) {
|
|
67658
|
-
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
|
|
67659
|
-
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
|
|
67660
|
-
// that isn't eliminated by a NonNullable<T> instantiation.
|
|
67661
|
-
var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
67662
67703
|
if (!deferredGlobalNonNullableTypeAlias) {
|
|
67663
67704
|
deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
|
|
67664
67705
|
}
|
|
67665
|
-
// If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
|
|
67666
67706
|
return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
|
|
67667
|
-
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [
|
|
67668
|
-
|
|
67707
|
+
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
|
|
67708
|
+
getIntersectionType([type, emptyObjectType]);
|
|
67669
67709
|
}
|
|
67670
67710
|
function getNonNullableType(type) {
|
|
67671
|
-
|
|
67711
|
+
if (strictNullChecks) {
|
|
67712
|
+
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
|
|
67713
|
+
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
|
|
67714
|
+
// that isn't eliminated by a NonNullable<T> instantiation.
|
|
67715
|
+
var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
67716
|
+
return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
|
|
67717
|
+
}
|
|
67718
|
+
return type;
|
|
67672
67719
|
}
|
|
67673
67720
|
function addOptionalTypeMarker(type) {
|
|
67674
67721
|
return strictNullChecks ? getUnionType([type, optionalType]) : type;
|
|
@@ -68349,13 +68396,40 @@ var ts;
|
|
|
68349
68396
|
return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
|
|
68350
68397
|
sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
|
|
68351
68398
|
}
|
|
68352
|
-
|
|
68399
|
+
/**
|
|
68400
|
+
* Tests whether the provided string can be parsed as a number.
|
|
68401
|
+
* @param s The string to test.
|
|
68402
|
+
* @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
|
|
68403
|
+
*/
|
|
68404
|
+
function isValidNumberString(s, roundTripOnly) {
|
|
68405
|
+
if (s === "")
|
|
68406
|
+
return false;
|
|
68407
|
+
var n = +s;
|
|
68408
|
+
return isFinite(n) && (!roundTripOnly || "" + n === s);
|
|
68409
|
+
}
|
|
68410
|
+
/**
|
|
68411
|
+
* @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
|
|
68412
|
+
*/
|
|
68413
|
+
function parseBigIntLiteralType(text) {
|
|
68414
|
+
var negative = text.startsWith("-");
|
|
68415
|
+
var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
|
|
68416
|
+
return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
|
|
68417
|
+
}
|
|
68418
|
+
/**
|
|
68419
|
+
* Tests whether the provided string can be parsed as a bigint.
|
|
68420
|
+
* @param s The string to test.
|
|
68421
|
+
* @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
|
|
68422
|
+
*/
|
|
68423
|
+
function isValidBigIntString(s, roundTripOnly) {
|
|
68424
|
+
if (s === "")
|
|
68425
|
+
return false;
|
|
68353
68426
|
var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
|
|
68354
68427
|
var success = true;
|
|
68355
68428
|
scanner.setOnError(function () { return success = false; });
|
|
68356
68429
|
scanner.setText(s + "n");
|
|
68357
68430
|
var result = scanner.scan();
|
|
68358
|
-
|
|
68431
|
+
var negative = result === 40 /* MinusToken */;
|
|
68432
|
+
if (negative) {
|
|
68359
68433
|
result = scanner.scan();
|
|
68360
68434
|
}
|
|
68361
68435
|
var flags = scanner.getTokenFlags();
|
|
@@ -68364,7 +68438,8 @@ var ts;
|
|
|
68364
68438
|
// * a bigint can be scanned, and that when it is scanned, it is
|
|
68365
68439
|
// * the full length of the input string (so the scanner is one character beyond the augmented input length)
|
|
68366
68440
|
// * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
|
|
68367
|
-
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68441
|
+
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68442
|
+
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68368
68443
|
}
|
|
68369
68444
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68370
68445
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
@@ -68372,8 +68447,8 @@ var ts;
|
|
|
68372
68447
|
}
|
|
68373
68448
|
if (source.flags & 128 /* StringLiteral */) {
|
|
68374
68449
|
var value = source.value;
|
|
68375
|
-
return !!(target.flags & 8 /* Number */ && value
|
|
68376
|
-
target.flags & 64 /* BigInt */ && value
|
|
68450
|
+
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68451
|
+
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68377
68452
|
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
|
|
68378
68453
|
}
|
|
68379
68454
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -68946,8 +69021,57 @@ var ts;
|
|
|
68946
69021
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
68947
69022
|
// succeed. That would be a pointless and confusing outcome.
|
|
68948
69023
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
69024
|
+
var _loop_23 = function (i) {
|
|
69025
|
+
var source_1 = matches ? matches[i] : neverType;
|
|
69026
|
+
var target_3 = types[i];
|
|
69027
|
+
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
69028
|
+
// allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
|
|
69029
|
+
if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
|
|
69030
|
+
var inferenceContext = getInferenceInfoForType(target_3);
|
|
69031
|
+
var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
|
|
69032
|
+
if (constraint && !isTypeAny(constraint)) {
|
|
69033
|
+
var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
69034
|
+
var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
|
|
69035
|
+
// If the constraint contains `string`, we don't need to look for a more preferred type
|
|
69036
|
+
if (!(allTypeFlags_1 & 4 /* String */)) {
|
|
69037
|
+
var str_1 = source_1.value;
|
|
69038
|
+
// If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
|
|
69039
|
+
if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
|
|
69040
|
+
allTypeFlags_1 &= ~296 /* NumberLike */;
|
|
69041
|
+
}
|
|
69042
|
+
// If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
|
|
69043
|
+
if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
|
|
69044
|
+
allTypeFlags_1 &= ~2112 /* BigIntLike */;
|
|
69045
|
+
}
|
|
69046
|
+
// for each type in the constraint, find the highest priority matching type
|
|
69047
|
+
var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
|
|
69048
|
+
return !(right.flags & allTypeFlags_1) ? left :
|
|
69049
|
+
left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
|
|
69050
|
+
left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
|
|
69051
|
+
left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
|
|
69052
|
+
left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
|
|
69053
|
+
left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
|
|
69054
|
+
left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
|
|
69055
|
+
left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
|
|
69056
|
+
left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
|
|
69057
|
+
left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
|
|
69058
|
+
left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
|
|
69059
|
+
left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
|
|
69060
|
+
left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
|
|
69061
|
+
left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
|
|
69062
|
+
left;
|
|
69063
|
+
}, neverType);
|
|
69064
|
+
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
69065
|
+
inferFromTypes(matchingType, target_3);
|
|
69066
|
+
return "continue";
|
|
69067
|
+
}
|
|
69068
|
+
}
|
|
69069
|
+
}
|
|
69070
|
+
}
|
|
69071
|
+
inferFromTypes(source_1, target_3);
|
|
69072
|
+
};
|
|
68949
69073
|
for (var i = 0; i < types.length; i++) {
|
|
68950
|
-
|
|
69074
|
+
_loop_23(i);
|
|
68951
69075
|
}
|
|
68952
69076
|
}
|
|
68953
69077
|
}
|
|
@@ -69465,7 +69589,7 @@ var ts;
|
|
|
69465
69589
|
function mapTypesByKeyProperty(types, name) {
|
|
69466
69590
|
var map = new ts.Map();
|
|
69467
69591
|
var count = 0;
|
|
69468
|
-
var
|
|
69592
|
+
var _loop_24 = function (type) {
|
|
69469
69593
|
if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
|
|
69470
69594
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
69471
69595
|
if (discriminant) {
|
|
@@ -69491,7 +69615,7 @@ var ts;
|
|
|
69491
69615
|
};
|
|
69492
69616
|
for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
|
|
69493
69617
|
var type = types_16[_i];
|
|
69494
|
-
var state_9 =
|
|
69618
|
+
var state_9 = _loop_24(type);
|
|
69495
69619
|
if (typeof state_9 === "object")
|
|
69496
69620
|
return state_9.value;
|
|
69497
69621
|
}
|
|
@@ -69699,6 +69823,24 @@ var ts;
|
|
|
69699
69823
|
function getTypeWithFacts(type, include) {
|
|
69700
69824
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
69701
69825
|
}
|
|
69826
|
+
function getIntersectionWithFacts(type, facts) {
|
|
69827
|
+
var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
69828
|
+
if (strictNullChecks) {
|
|
69829
|
+
switch (facts) {
|
|
69830
|
+
case 524288 /* NEUndefined */:
|
|
69831
|
+
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; });
|
|
69832
|
+
case 1048576 /* NENull */:
|
|
69833
|
+
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; });
|
|
69834
|
+
case 2097152 /* NEUndefinedOrNull */:
|
|
69835
|
+
case 4194304 /* Truthy */:
|
|
69836
|
+
return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
|
|
69837
|
+
}
|
|
69838
|
+
}
|
|
69839
|
+
return reduced;
|
|
69840
|
+
}
|
|
69841
|
+
function recombineUnknownType(type) {
|
|
69842
|
+
return type === unknownUnionType ? unknownType : type;
|
|
69843
|
+
}
|
|
69702
69844
|
function getTypeWithDefault(type, defaultExpression) {
|
|
69703
69845
|
return defaultExpression ?
|
|
69704
69846
|
getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
|
|
@@ -70756,7 +70898,7 @@ var ts;
|
|
|
70756
70898
|
if (isEvolvingArrayTypeList(types)) {
|
|
70757
70899
|
return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
|
|
70758
70900
|
}
|
|
70759
|
-
var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
|
|
70901
|
+
var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
|
|
70760
70902
|
if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
|
|
70761
70903
|
return declaredType;
|
|
70762
70904
|
}
|
|
@@ -70858,8 +71000,7 @@ var ts;
|
|
|
70858
71000
|
}
|
|
70859
71001
|
function narrowTypeByTruthiness(type, expr, assumeTrue) {
|
|
70860
71002
|
if (isMatchingReference(reference, expr)) {
|
|
70861
|
-
return type
|
|
70862
|
-
getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
|
|
71003
|
+
return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
|
|
70863
71004
|
}
|
|
70864
71005
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
|
|
70865
71006
|
type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
@@ -71012,9 +71153,6 @@ var ts;
|
|
|
71012
71153
|
assumeTrue = !assumeTrue;
|
|
71013
71154
|
}
|
|
71014
71155
|
var valueType = getTypeOfExpression(value);
|
|
71015
|
-
if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
|
|
71016
|
-
return getUnionType([nullType, undefinedType]);
|
|
71017
|
-
}
|
|
71018
71156
|
if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
|
|
71019
71157
|
if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
|
|
71020
71158
|
return valueType;
|
|
@@ -71034,7 +71172,7 @@ var ts;
|
|
|
71034
71172
|
valueType.flags & 65536 /* Null */ ?
|
|
71035
71173
|
assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
|
|
71036
71174
|
assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
71037
|
-
return
|
|
71175
|
+
return getIntersectionWithFacts(type, facts);
|
|
71038
71176
|
}
|
|
71039
71177
|
if (assumeTrue) {
|
|
71040
71178
|
var filterFn = operator === 34 /* EqualsEqualsToken */ ?
|
|
@@ -71062,17 +71200,11 @@ var ts;
|
|
|
71062
71200
|
if (type.flags & 1 /* Any */ && literal.text === "function") {
|
|
71063
71201
|
return type;
|
|
71064
71202
|
}
|
|
71065
|
-
if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
|
|
71066
|
-
// The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
|
|
71067
|
-
// from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
|
|
71068
|
-
// unknown type, and then narrows that to the non-primitive type.
|
|
71069
|
-
return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
|
|
71070
|
-
}
|
|
71071
71203
|
var facts = assumeTrue ?
|
|
71072
71204
|
typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
|
|
71073
71205
|
typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
|
|
71074
71206
|
var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
|
|
71075
|
-
return getTypeWithFacts(assumeTrue && impliedType ?
|
|
71207
|
+
return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
|
|
71076
71208
|
}
|
|
71077
71209
|
function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
|
|
71078
71210
|
var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
|
|
@@ -71121,10 +71253,10 @@ var ts;
|
|
|
71121
71253
|
}
|
|
71122
71254
|
function getImpliedTypeFromTypeofGuard(type, text) {
|
|
71123
71255
|
switch (text) {
|
|
71256
|
+
case "object":
|
|
71257
|
+
return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
|
|
71124
71258
|
case "function":
|
|
71125
71259
|
return type.flags & 1 /* Any */ ? type : globalFunctionType;
|
|
71126
|
-
case "object":
|
|
71127
|
-
return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
|
|
71128
71260
|
default:
|
|
71129
71261
|
return typeofTypesByName.get(text);
|
|
71130
71262
|
}
|
|
@@ -71135,22 +71267,27 @@ var ts;
|
|
|
71135
71267
|
// the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
|
|
71136
71268
|
// the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
|
|
71137
71269
|
// filtering by type-facts.
|
|
71138
|
-
function
|
|
71139
|
-
|
|
71140
|
-
|
|
71141
|
-
|
|
71142
|
-
|
|
71143
|
-
if (
|
|
71144
|
-
return
|
|
71270
|
+
function narrowTypeByImpliedType(type, candidate) {
|
|
71271
|
+
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
71272
|
+
return candidate;
|
|
71273
|
+
}
|
|
71274
|
+
return mapType(type, function (t) {
|
|
71275
|
+
if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
|
|
71276
|
+
return t;
|
|
71145
71277
|
}
|
|
71146
|
-
|
|
71147
|
-
|
|
71148
|
-
|
|
71149
|
-
return getIntersectionType([type, candidate]);
|
|
71278
|
+
return mapType(candidate, function (c) {
|
|
71279
|
+
if (!areTypesComparable(t, c)) {
|
|
71280
|
+
return neverType;
|
|
71150
71281
|
}
|
|
71151
|
-
|
|
71152
|
-
|
|
71153
|
-
|
|
71282
|
+
if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
|
|
71283
|
+
return isTypeSubtypeOf(c, t) ? c : neverType;
|
|
71284
|
+
}
|
|
71285
|
+
if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
|
|
71286
|
+
return c;
|
|
71287
|
+
}
|
|
71288
|
+
return getIntersectionType([t, c]);
|
|
71289
|
+
});
|
|
71290
|
+
});
|
|
71154
71291
|
}
|
|
71155
71292
|
function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
|
|
71156
71293
|
var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
|
|
@@ -71209,7 +71346,7 @@ var ts;
|
|
|
71209
71346
|
because it is caught in the first clause.
|
|
71210
71347
|
*/
|
|
71211
71348
|
var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
|
|
71212
|
-
return getTypeWithFacts(
|
|
71349
|
+
return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
|
|
71213
71350
|
}
|
|
71214
71351
|
function isMatchingConstructorReference(expr) {
|
|
71215
71352
|
return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
|
|
@@ -71513,7 +71650,9 @@ var ts;
|
|
|
71513
71650
|
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
71514
71651
|
}
|
|
71515
71652
|
function isGenericTypeWithUnionConstraint(type) {
|
|
71516
|
-
return
|
|
71653
|
+
return type.flags & 2097152 /* Intersection */ ?
|
|
71654
|
+
ts.some(type.types, isGenericTypeWithUnionConstraint) :
|
|
71655
|
+
!!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
71517
71656
|
}
|
|
71518
71657
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
71519
71658
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
@@ -71541,7 +71680,7 @@ var ts;
|
|
|
71541
71680
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
71542
71681
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
71543
71682
|
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
71544
|
-
return substituteConstraints ? mapType(type,
|
|
71683
|
+
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
71545
71684
|
}
|
|
71546
71685
|
function isExportOrExportExpression(location) {
|
|
71547
71686
|
return !!ts.findAncestor(location, function (n) {
|
|
@@ -75879,7 +76018,7 @@ var ts;
|
|
|
75879
76018
|
if (spreadIndex >= 0) {
|
|
75880
76019
|
// Create synthetic arguments from spreads of tuple types.
|
|
75881
76020
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
75882
|
-
var
|
|
76021
|
+
var _loop_25 = function (i) {
|
|
75883
76022
|
var arg = args[i];
|
|
75884
76023
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
75885
76024
|
var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -75896,7 +76035,7 @@ var ts;
|
|
|
75896
76035
|
}
|
|
75897
76036
|
};
|
|
75898
76037
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
75899
|
-
|
|
76038
|
+
_loop_25(i);
|
|
75900
76039
|
}
|
|
75901
76040
|
return effectiveArgs_1;
|
|
75902
76041
|
}
|
|
@@ -76216,7 +76355,7 @@ var ts;
|
|
|
76216
76355
|
var min_3 = Number.MAX_VALUE;
|
|
76217
76356
|
var minIndex = 0;
|
|
76218
76357
|
var i_1 = 0;
|
|
76219
|
-
var
|
|
76358
|
+
var _loop_26 = function (c) {
|
|
76220
76359
|
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)); };
|
|
76221
76360
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
|
76222
76361
|
if (diags_2) {
|
|
@@ -76234,7 +76373,7 @@ var ts;
|
|
|
76234
76373
|
};
|
|
76235
76374
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
76236
76375
|
var c = candidatesForArgumentError_1[_a];
|
|
76237
|
-
|
|
76376
|
+
_loop_26(c);
|
|
76238
76377
|
}
|
|
76239
76378
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
76240
76379
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -76392,7 +76531,7 @@ var ts;
|
|
|
76392
76531
|
}
|
|
76393
76532
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
76394
76533
|
var parameters = [];
|
|
76395
|
-
var
|
|
76534
|
+
var _loop_27 = function (i) {
|
|
76396
76535
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
76397
76536
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
76398
76537
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -76400,7 +76539,7 @@ var ts;
|
|
|
76400
76539
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
76401
76540
|
};
|
|
76402
76541
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
76403
|
-
|
|
76542
|
+
_loop_27(i);
|
|
76404
76543
|
}
|
|
76405
76544
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
76406
76545
|
var flags = 0 /* None */;
|
|
@@ -80457,7 +80596,7 @@ var ts;
|
|
|
80457
80596
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
80458
80597
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
80459
80598
|
var indexSignatureMap_1 = new ts.Map();
|
|
80460
|
-
var
|
|
80599
|
+
var _loop_28 = function (declaration) {
|
|
80461
80600
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
80462
80601
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
80463
80602
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -80472,7 +80611,7 @@ var ts;
|
|
|
80472
80611
|
};
|
|
80473
80612
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
80474
80613
|
var declaration = _a[_i];
|
|
80475
|
-
|
|
80614
|
+
_loop_28(declaration);
|
|
80476
80615
|
}
|
|
80477
80616
|
indexSignatureMap_1.forEach(function (entry) {
|
|
80478
80617
|
if (entry.declarations.length > 1) {
|
|
@@ -83933,7 +84072,7 @@ var ts;
|
|
|
83933
84072
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
|
|
83934
84073
|
var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
|
|
83935
84074
|
name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
83936
|
-
var
|
|
84075
|
+
var _loop_29 = function (info) {
|
|
83937
84076
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
83938
84077
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
83939
84078
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -83946,7 +84085,7 @@ var ts;
|
|
|
83946
84085
|
};
|
|
83947
84086
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
83948
84087
|
var info = indexInfos_9[_i];
|
|
83949
|
-
|
|
84088
|
+
_loop_29(info);
|
|
83950
84089
|
}
|
|
83951
84090
|
}
|
|
83952
84091
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -83954,7 +84093,7 @@ var ts;
|
|
|
83954
84093
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
83955
84094
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
|
|
83956
84095
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
83957
|
-
var
|
|
84096
|
+
var _loop_30 = function (info) {
|
|
83958
84097
|
if (info === checkInfo)
|
|
83959
84098
|
return "continue";
|
|
83960
84099
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -83969,7 +84108,7 @@ var ts;
|
|
|
83969
84108
|
};
|
|
83970
84109
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
83971
84110
|
var info = indexInfos_10[_i];
|
|
83972
|
-
|
|
84111
|
+
_loop_30(info);
|
|
83973
84112
|
}
|
|
83974
84113
|
}
|
|
83975
84114
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -84288,7 +84427,7 @@ var ts;
|
|
|
84288
84427
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
84289
84428
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
84290
84429
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
84291
|
-
var
|
|
84430
|
+
var _loop_31 = function (member) {
|
|
84292
84431
|
if (ts.hasAmbientModifier(member)) {
|
|
84293
84432
|
return "continue";
|
|
84294
84433
|
}
|
|
@@ -84305,7 +84444,7 @@ var ts;
|
|
|
84305
84444
|
};
|
|
84306
84445
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
84307
84446
|
var member = _a[_i];
|
|
84308
|
-
|
|
84447
|
+
_loop_31(member);
|
|
84309
84448
|
}
|
|
84310
84449
|
}
|
|
84311
84450
|
/**
|
|
@@ -84393,7 +84532,7 @@ var ts;
|
|
|
84393
84532
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
84394
84533
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
84395
84534
|
var issuedMemberError = false;
|
|
84396
|
-
var
|
|
84535
|
+
var _loop_32 = function (member) {
|
|
84397
84536
|
if (ts.isStatic(member)) {
|
|
84398
84537
|
return "continue";
|
|
84399
84538
|
}
|
|
@@ -84412,7 +84551,7 @@ var ts;
|
|
|
84412
84551
|
};
|
|
84413
84552
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
84414
84553
|
var member = _a[_i];
|
|
84415
|
-
|
|
84554
|
+
_loop_32(member);
|
|
84416
84555
|
}
|
|
84417
84556
|
if (!issuedMemberError) {
|
|
84418
84557
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -122380,7 +122519,7 @@ var ts;
|
|
|
122380
122519
|
});
|
|
122381
122520
|
// Sort by paths closest to importing file Name directory
|
|
122382
122521
|
var sortedPaths = [];
|
|
122383
|
-
var
|
|
122522
|
+
var _loop_33 = function (directory) {
|
|
122384
122523
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
122385
122524
|
var pathsInDirectory;
|
|
122386
122525
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -122404,7 +122543,7 @@ var ts;
|
|
|
122404
122543
|
};
|
|
122405
122544
|
var out_directory_1;
|
|
122406
122545
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
122407
|
-
var state_10 =
|
|
122546
|
+
var state_10 = _loop_33(directory);
|
|
122408
122547
|
directory = out_directory_1;
|
|
122409
122548
|
if (state_10 === "break")
|
|
122410
122549
|
break;
|
|
@@ -147791,11 +147930,9 @@ var ts;
|
|
|
147791
147930
|
if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
|
|
147792
147931
|
var tokenInfo = formattingScanner.readTokenInfo(parent);
|
|
147793
147932
|
if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
|
|
147794
|
-
|
|
147795
|
-
|
|
147796
|
-
|
|
147797
|
-
tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
|
|
147798
|
-
}
|
|
147933
|
+
// consume the comma
|
|
147934
|
+
consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
|
|
147935
|
+
tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
|
|
147799
147936
|
}
|
|
147800
147937
|
// consume the list end token only if it is still belong to the parent
|
|
147801
147938
|
// there might be the case when current token matches end token but does not considered as one
|