typescript 5.4.0-dev.20231129 → 5.4.0-dev.20231201
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.es2018.intl.d.ts +4 -3
- package/lib/lib.es2020.intl.d.ts +36 -16
- package/lib/lib.es2020.string.d.ts +15 -1
- package/lib/lib.es2021.intl.d.ts +2 -2
- package/lib/lib.es2022.intl.d.ts +2 -2
- package/lib/lib.es5.d.ts +15 -6
- package/lib/lib.esnext.d.ts +1 -0
- package/lib/lib.esnext.promise.d.ts +35 -0
- package/lib/tsc.js +185 -55
- package/lib/tsserver.js +197 -56
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +197 -56
- package/lib/typingsInstaller.js +4 -2
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -2332,7 +2332,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2332
2332
|
|
|
2333
2333
|
// src/compiler/corePublic.ts
|
|
2334
2334
|
var versionMajorMinor = "5.4";
|
|
2335
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2335
|
+
var version = `${versionMajorMinor}.0-dev.20231201`;
|
|
2336
2336
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2337
2337
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2338
2338
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6686,6 +6686,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6686
6686
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
6687
6687
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
6688
6688
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
6689
|
+
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable";
|
|
6689
6690
|
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
6690
6691
|
return TypeFlags2;
|
|
6691
6692
|
})(TypeFlags || {});
|
|
@@ -6732,6 +6733,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6732
6733
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
6733
6734
|
ObjectFlags3[ObjectFlags3["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
6734
6735
|
ObjectFlags3[ObjectFlags3["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
|
|
6736
|
+
ObjectFlags3[ObjectFlags3["IsConstrainedTypeVariable"] = 67108864] = "IsConstrainedTypeVariable";
|
|
6735
6737
|
return ObjectFlags3;
|
|
6736
6738
|
})(ObjectFlags || {});
|
|
6737
6739
|
var VarianceFlags = /* @__PURE__ */ ((VarianceFlags2) => {
|
|
@@ -38324,7 +38326,7 @@ var libEntries = [
|
|
|
38324
38326
|
["esnext.disposable", "lib.esnext.disposable.d.ts"],
|
|
38325
38327
|
["esnext.bigint", "lib.es2020.bigint.d.ts"],
|
|
38326
38328
|
["esnext.string", "lib.es2022.string.d.ts"],
|
|
38327
|
-
["esnext.promise", "lib.
|
|
38329
|
+
["esnext.promise", "lib.esnext.promise.d.ts"],
|
|
38328
38330
|
["esnext.weakref", "lib.es2021.weakref.d.ts"],
|
|
38329
38331
|
["esnext.decorators", "lib.esnext.decorators.d.ts"],
|
|
38330
38332
|
["decorators", "lib.decorators.d.ts"],
|
|
@@ -46467,7 +46469,7 @@ function createBinder() {
|
|
|
46467
46469
|
}
|
|
46468
46470
|
function bindSpecialPropertyAssignment(node) {
|
|
46469
46471
|
var _a;
|
|
46470
|
-
const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression,
|
|
46472
|
+
const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer) || lookupSymbolForPropertyAccess(node.left.expression, container);
|
|
46471
46473
|
if (!isInJSFile(node) && !isFunctionSymbol(parentSymbol)) {
|
|
46472
46474
|
return;
|
|
46473
46475
|
}
|
|
@@ -46565,7 +46567,7 @@ function createBinder() {
|
|
|
46565
46567
|
return isBinaryExpression(propertyAccess.parent) ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 312 /* SourceFile */ : propertyAccess.parent.parent.kind === 312 /* SourceFile */;
|
|
46566
46568
|
}
|
|
46567
46569
|
function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
|
|
46568
|
-
let namespaceSymbol = lookupSymbolForPropertyAccess(name,
|
|
46570
|
+
let namespaceSymbol = lookupSymbolForPropertyAccess(name, blockScopeContainer) || lookupSymbolForPropertyAccess(name, container);
|
|
46569
46571
|
const isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
|
|
46570
46572
|
namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
|
|
46571
46573
|
bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
|
|
@@ -51701,6 +51703,10 @@ function createTypeChecker(host) {
|
|
|
51701
51703
|
function getParentOfSymbol(symbol) {
|
|
51702
51704
|
return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
|
|
51703
51705
|
}
|
|
51706
|
+
function getFunctionExpressionParentSymbolOrSymbol(symbol) {
|
|
51707
|
+
var _a, _b;
|
|
51708
|
+
return ((_a = symbol.valueDeclaration) == null ? void 0 : _a.kind) === 219 /* ArrowFunction */ || ((_b = symbol.valueDeclaration) == null ? void 0 : _b.kind) === 218 /* FunctionExpression */ ? getSymbolOfNode(symbol.valueDeclaration.parent) || symbol : symbol;
|
|
51709
|
+
}
|
|
51704
51710
|
function getAlternativeContainingModules(symbol, enclosingDeclaration) {
|
|
51705
51711
|
const containingFile = getSourceFileOfNode(enclosingDeclaration);
|
|
51706
51712
|
const id = getNodeId(containingFile);
|
|
@@ -56924,11 +56930,14 @@ function createTypeChecker(host) {
|
|
|
56924
56930
|
}
|
|
56925
56931
|
}
|
|
56926
56932
|
if ((_a = symbol.parent) == null ? void 0 : _a.valueDeclaration) {
|
|
56927
|
-
const
|
|
56928
|
-
if (
|
|
56929
|
-
const
|
|
56930
|
-
if (
|
|
56931
|
-
|
|
56933
|
+
const possiblyAnnotatedSymbol = getFunctionExpressionParentSymbolOrSymbol(symbol.parent);
|
|
56934
|
+
if (possiblyAnnotatedSymbol.valueDeclaration) {
|
|
56935
|
+
const typeNode2 = getEffectiveTypeAnnotationNode(possiblyAnnotatedSymbol.valueDeclaration);
|
|
56936
|
+
if (typeNode2) {
|
|
56937
|
+
const annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode2), symbol.escapedName);
|
|
56938
|
+
if (annotationSymbol) {
|
|
56939
|
+
return getNonMissingTypeOfSymbol(annotationSymbol);
|
|
56940
|
+
}
|
|
56932
56941
|
}
|
|
56933
56942
|
}
|
|
56934
56943
|
}
|
|
@@ -58228,7 +58237,6 @@ function createTypeChecker(host) {
|
|
|
58228
58237
|
return links.resolvedSymbol;
|
|
58229
58238
|
}
|
|
58230
58239
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
58231
|
-
var _a, _b, _c;
|
|
58232
58240
|
const links = getSymbolLinks(symbol);
|
|
58233
58241
|
if (!links[resolutionKind]) {
|
|
58234
58242
|
const isStatic2 = resolutionKind === "resolvedExports" /* resolvedExports */;
|
|
@@ -58247,7 +58255,7 @@ function createTypeChecker(host) {
|
|
|
58247
58255
|
}
|
|
58248
58256
|
}
|
|
58249
58257
|
}
|
|
58250
|
-
const assignments = (
|
|
58258
|
+
const assignments = getFunctionExpressionParentSymbolOrSymbol(symbol).assignmentDeclarationMembers;
|
|
58251
58259
|
if (assignments) {
|
|
58252
58260
|
const decls = arrayFrom(assignments.values());
|
|
58253
58261
|
for (const member of decls) {
|
|
@@ -58544,6 +58552,15 @@ function createTypeChecker(host) {
|
|
|
58544
58552
|
let result;
|
|
58545
58553
|
for (let i = 0; i < signatureLists.length; i++) {
|
|
58546
58554
|
const match = i === listIndex ? signature : findMatchingSignature(
|
|
58555
|
+
signatureLists[i],
|
|
58556
|
+
signature,
|
|
58557
|
+
/*partialMatch*/
|
|
58558
|
+
false,
|
|
58559
|
+
/*ignoreThisTypes*/
|
|
58560
|
+
false,
|
|
58561
|
+
/*ignoreReturnTypes*/
|
|
58562
|
+
true
|
|
58563
|
+
) || findMatchingSignature(
|
|
58547
58564
|
signatureLists[i],
|
|
58548
58565
|
signature,
|
|
58549
58566
|
/*partialMatch*/
|
|
@@ -58917,6 +58934,18 @@ function createTypeChecker(host) {
|
|
|
58917
58934
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
58918
58935
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
58919
58936
|
}
|
|
58937
|
+
function getLimitedConstraint(type) {
|
|
58938
|
+
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
58939
|
+
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
58940
|
+
return;
|
|
58941
|
+
}
|
|
58942
|
+
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
58943
|
+
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
58944
|
+
return;
|
|
58945
|
+
}
|
|
58946
|
+
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
58947
|
+
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
58948
|
+
}
|
|
58920
58949
|
function resolveReverseMappedTypeMembers(type) {
|
|
58921
58950
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
58922
58951
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -58924,7 +58953,14 @@ function createTypeChecker(host) {
|
|
|
58924
58953
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
58925
58954
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
58926
58955
|
const members = createSymbolTable();
|
|
58956
|
+
const limitedConstraint = getLimitedConstraint(type);
|
|
58927
58957
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
58958
|
+
if (limitedConstraint) {
|
|
58959
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
58960
|
+
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
58961
|
+
continue;
|
|
58962
|
+
}
|
|
58963
|
+
}
|
|
58928
58964
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
58929
58965
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
58930
58966
|
inferredProp.declarations = prop.declarations;
|
|
@@ -59005,7 +59041,7 @@ function createTypeChecker(host) {
|
|
|
59005
59041
|
const constraintType = getConstraintTypeFromMappedType(type);
|
|
59006
59042
|
const mappedType = type.target || type;
|
|
59007
59043
|
const nameType = getNameTypeFromMappedType(mappedType);
|
|
59008
|
-
const shouldLinkPropDeclarations =
|
|
59044
|
+
const shouldLinkPropDeclarations = getMappedTypeNameTypeKind(mappedType) !== 2 /* Remapping */;
|
|
59009
59045
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
59010
59046
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
59011
59047
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
@@ -59147,9 +59183,12 @@ function createTypeChecker(host) {
|
|
|
59147
59183
|
}
|
|
59148
59184
|
return false;
|
|
59149
59185
|
}
|
|
59150
|
-
function
|
|
59186
|
+
function getMappedTypeNameTypeKind(type) {
|
|
59151
59187
|
const nameType = getNameTypeFromMappedType(type);
|
|
59152
|
-
|
|
59188
|
+
if (!nameType) {
|
|
59189
|
+
return 0 /* None */;
|
|
59190
|
+
}
|
|
59191
|
+
return isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)) ? 1 /* Filtering */ : 2 /* Remapping */;
|
|
59153
59192
|
}
|
|
59154
59193
|
function resolveStructuredTypeMembers(type) {
|
|
59155
59194
|
if (!type.members) {
|
|
@@ -59198,7 +59237,12 @@ function createTypeChecker(host) {
|
|
|
59198
59237
|
for (const current of type.types) {
|
|
59199
59238
|
for (const prop of getPropertiesOfType(current)) {
|
|
59200
59239
|
if (!members.has(prop.escapedName)) {
|
|
59201
|
-
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
59240
|
+
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
59241
|
+
type,
|
|
59242
|
+
prop.escapedName,
|
|
59243
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
59244
|
+
!!(type.flags & 2097152 /* Intersection */)
|
|
59245
|
+
);
|
|
59202
59246
|
if (combinedProp) {
|
|
59203
59247
|
members.set(prop.escapedName, combinedProp);
|
|
59204
59248
|
}
|
|
@@ -59688,13 +59732,17 @@ function createTypeChecker(host) {
|
|
|
59688
59732
|
return result;
|
|
59689
59733
|
}
|
|
59690
59734
|
function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
|
|
59691
|
-
var _a, _b;
|
|
59735
|
+
var _a, _b, _c;
|
|
59692
59736
|
let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
|
|
59693
59737
|
if (!property) {
|
|
59694
59738
|
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
59695
59739
|
if (property) {
|
|
59696
59740
|
const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
59697
59741
|
properties.set(name, property);
|
|
59742
|
+
if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
59743
|
+
const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
59744
|
+
properties2.set(name, property);
|
|
59745
|
+
}
|
|
59698
59746
|
}
|
|
59699
59747
|
}
|
|
59700
59748
|
return property;
|
|
@@ -59804,7 +59852,22 @@ function createTypeChecker(host) {
|
|
|
59804
59852
|
}
|
|
59805
59853
|
return getPropertyOfObjectType(globalObjectType, name);
|
|
59806
59854
|
}
|
|
59807
|
-
if (type.flags &
|
|
59855
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
59856
|
+
const prop = getPropertyOfUnionOrIntersectionType(
|
|
59857
|
+
type,
|
|
59858
|
+
name,
|
|
59859
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
59860
|
+
true
|
|
59861
|
+
);
|
|
59862
|
+
if (prop) {
|
|
59863
|
+
return prop;
|
|
59864
|
+
}
|
|
59865
|
+
if (!skipObjectFunctionPropertyAugment) {
|
|
59866
|
+
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
59867
|
+
}
|
|
59868
|
+
return void 0;
|
|
59869
|
+
}
|
|
59870
|
+
if (type.flags & 1048576 /* Union */) {
|
|
59808
59871
|
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
59809
59872
|
}
|
|
59810
59873
|
return void 0;
|
|
@@ -61661,6 +61724,8 @@ function createTypeChecker(host) {
|
|
|
61661
61724
|
includes |= flags & 473694207 /* IncludesMask */;
|
|
61662
61725
|
if (flags & 465829888 /* Instantiable */)
|
|
61663
61726
|
includes |= 33554432 /* IncludesInstantiable */;
|
|
61727
|
+
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
|
|
61728
|
+
includes |= 268435456 /* IncludesConstrainedTypeVariable */;
|
|
61664
61729
|
if (type === wildcardType)
|
|
61665
61730
|
includes |= 8388608 /* IncludesWildcard */;
|
|
61666
61731
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -61765,6 +61830,41 @@ function createTypeChecker(host) {
|
|
|
61765
61830
|
}
|
|
61766
61831
|
}
|
|
61767
61832
|
}
|
|
61833
|
+
function removeConstrainedTypeVariables(types) {
|
|
61834
|
+
const typeVariables = [];
|
|
61835
|
+
for (const type of types) {
|
|
61836
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
61837
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
61838
|
+
pushIfUnique(typeVariables, type.types[index]);
|
|
61839
|
+
}
|
|
61840
|
+
}
|
|
61841
|
+
for (const typeVariable of typeVariables) {
|
|
61842
|
+
const primitives = [];
|
|
61843
|
+
for (const type of types) {
|
|
61844
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
61845
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
61846
|
+
if (type.types[index] === typeVariable) {
|
|
61847
|
+
insertType(primitives, type.types[1 - index]);
|
|
61848
|
+
}
|
|
61849
|
+
}
|
|
61850
|
+
}
|
|
61851
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
61852
|
+
if (everyType(constraint, (t) => containsType(primitives, t))) {
|
|
61853
|
+
let i = types.length;
|
|
61854
|
+
while (i > 0) {
|
|
61855
|
+
i--;
|
|
61856
|
+
const type = types[i];
|
|
61857
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
61858
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
61859
|
+
if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
|
|
61860
|
+
orderedRemoveItemAt(types, i);
|
|
61861
|
+
}
|
|
61862
|
+
}
|
|
61863
|
+
}
|
|
61864
|
+
insertType(types, typeVariable);
|
|
61865
|
+
}
|
|
61866
|
+
}
|
|
61867
|
+
}
|
|
61768
61868
|
function isNamedUnionType(type) {
|
|
61769
61869
|
return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
|
|
61770
61870
|
}
|
|
@@ -61830,6 +61930,9 @@ function createTypeChecker(host) {
|
|
|
61830
61930
|
if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
|
|
61831
61931
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
61832
61932
|
}
|
|
61933
|
+
if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
|
|
61934
|
+
removeConstrainedTypeVariables(typeSet);
|
|
61935
|
+
}
|
|
61833
61936
|
if (unionReduction === 2 /* Subtype */) {
|
|
61834
61937
|
typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
|
|
61835
61938
|
if (!typeSet) {
|
|
@@ -62042,9 +62145,9 @@ function createTypeChecker(host) {
|
|
|
62042
62145
|
types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
|
|
62043
62146
|
return true;
|
|
62044
62147
|
}
|
|
62045
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
62148
|
+
function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
|
|
62046
62149
|
const result = createType(2097152 /* Intersection */);
|
|
62047
|
-
result.objectFlags = getPropagatingFlagsOfTypes(
|
|
62150
|
+
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
62048
62151
|
types,
|
|
62049
62152
|
/*excludeKinds*/
|
|
62050
62153
|
98304 /* Nullable */
|
|
@@ -62058,6 +62161,7 @@ function createTypeChecker(host) {
|
|
|
62058
62161
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
62059
62162
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
62060
62163
|
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
62164
|
+
let objectFlags = 0 /* None */;
|
|
62061
62165
|
if (includes & 131072 /* Never */) {
|
|
62062
62166
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
62063
62167
|
}
|
|
@@ -62086,6 +62190,25 @@ function createTypeChecker(host) {
|
|
|
62086
62190
|
if (typeSet.length === 1) {
|
|
62087
62191
|
return typeSet[0];
|
|
62088
62192
|
}
|
|
62193
|
+
if (typeSet.length === 2) {
|
|
62194
|
+
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
62195
|
+
const typeVariable = typeSet[typeVarIndex];
|
|
62196
|
+
const primitiveType = typeSet[1 - typeVarIndex];
|
|
62197
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62198
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
62199
|
+
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
62200
|
+
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
62201
|
+
return typeVariable;
|
|
62202
|
+
}
|
|
62203
|
+
if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
|
|
62204
|
+
if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
|
|
62205
|
+
return neverType;
|
|
62206
|
+
}
|
|
62207
|
+
}
|
|
62208
|
+
objectFlags = 67108864 /* IsConstrainedTypeVariable */;
|
|
62209
|
+
}
|
|
62210
|
+
}
|
|
62211
|
+
}
|
|
62089
62212
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
62090
62213
|
let result = intersectionTypes.get(id);
|
|
62091
62214
|
if (!result) {
|
|
@@ -62108,7 +62231,7 @@ function createTypeChecker(host) {
|
|
|
62108
62231
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
62109
62232
|
}
|
|
62110
62233
|
} else {
|
|
62111
|
-
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
62234
|
+
result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
|
|
62112
62235
|
}
|
|
62113
62236
|
intersectionTypes.set(id, result);
|
|
62114
62237
|
}
|
|
@@ -62265,7 +62388,7 @@ function createTypeChecker(host) {
|
|
|
62265
62388
|
);
|
|
62266
62389
|
}
|
|
62267
62390
|
function shouldDeferIndexType(type, indexFlags = 0 /* None */) {
|
|
62268
|
-
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
62391
|
+
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && (!hasDistributiveNameType(type) || getMappedTypeNameTypeKind(type) === 2 /* Remapping */) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
62269
62392
|
}
|
|
62270
62393
|
function getIndexType(type, indexFlags = defaultIndexFlags) {
|
|
62271
62394
|
type = getReducedType(type);
|
|
@@ -62749,7 +62872,7 @@ function createTypeChecker(host) {
|
|
|
62749
62872
|
}
|
|
62750
62873
|
}
|
|
62751
62874
|
if (isGenericMappedType(objectType)) {
|
|
62752
|
-
if (
|
|
62875
|
+
if (getMappedTypeNameTypeKind(objectType) !== 2 /* Remapping */) {
|
|
62753
62876
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
|
|
62754
62877
|
}
|
|
62755
62878
|
}
|
|
@@ -68657,12 +68780,12 @@ function createTypeChecker(host) {
|
|
|
68657
68780
|
return false;
|
|
68658
68781
|
}
|
|
68659
68782
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68660
|
-
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68661
|
-
return true;
|
|
68662
|
-
}
|
|
68663
68783
|
if (target.flags & 2097152 /* Intersection */) {
|
|
68664
68784
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
68665
68785
|
}
|
|
68786
|
+
if (target.flags & 4 /* String */ || isTypeAssignableTo(source, target)) {
|
|
68787
|
+
return true;
|
|
68788
|
+
}
|
|
68666
68789
|
if (source.flags & 128 /* StringLiteral */) {
|
|
68667
68790
|
const value = source.value;
|
|
68668
68791
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(
|
|
@@ -68679,7 +68802,7 @@ function createTypeChecker(host) {
|
|
|
68679
68802
|
const texts = source.texts;
|
|
68680
68803
|
return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target);
|
|
68681
68804
|
}
|
|
68682
|
-
return
|
|
68805
|
+
return false;
|
|
68683
68806
|
}
|
|
68684
68807
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
68685
68808
|
return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arraysEqual(source.texts, target.texts) ? map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
@@ -68801,7 +68924,8 @@ function createTypeChecker(host) {
|
|
|
68801
68924
|
source = getIntersectionType(sources);
|
|
68802
68925
|
target = getIntersectionType(targets);
|
|
68803
68926
|
}
|
|
68804
|
-
}
|
|
68927
|
+
}
|
|
68928
|
+
if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
|
|
68805
68929
|
target = getActualTypeVariable(target);
|
|
68806
68930
|
}
|
|
68807
68931
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
@@ -69076,7 +69200,7 @@ function createTypeChecker(host) {
|
|
|
69076
69200
|
}
|
|
69077
69201
|
}
|
|
69078
69202
|
function inferToMappedType(source, target, constraintType) {
|
|
69079
|
-
if (constraintType.flags & 1048576 /* Union */) {
|
|
69203
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
69080
69204
|
let result = false;
|
|
69081
69205
|
for (const type of constraintType.types) {
|
|
69082
69206
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -75818,19 +75942,9 @@ function createTypeChecker(host) {
|
|
|
75818
75942
|
return Debug.fail();
|
|
75819
75943
|
}
|
|
75820
75944
|
}
|
|
75821
|
-
function getDiagnosticSpanForCallNode(node
|
|
75822
|
-
let start2;
|
|
75823
|
-
let length2;
|
|
75945
|
+
function getDiagnosticSpanForCallNode(node) {
|
|
75824
75946
|
const sourceFile = getSourceFileOfNode(node);
|
|
75825
|
-
|
|
75826
|
-
const nameSpan = getErrorSpanForNode(sourceFile, node.expression.name);
|
|
75827
|
-
start2 = nameSpan.start;
|
|
75828
|
-
length2 = doNotIncludeArguments ? nameSpan.length : node.end - start2;
|
|
75829
|
-
} else {
|
|
75830
|
-
const expressionSpan = getErrorSpanForNode(sourceFile, node.expression);
|
|
75831
|
-
start2 = expressionSpan.start;
|
|
75832
|
-
length2 = doNotIncludeArguments ? expressionSpan.length : node.end - start2;
|
|
75833
|
-
}
|
|
75947
|
+
const { start: start2, length: length2 } = getErrorSpanForNode(sourceFile, isPropertyAccessExpression(node.expression) ? node.expression.name : node.expression);
|
|
75834
75948
|
return { start: start2, length: length2, sourceFile };
|
|
75835
75949
|
}
|
|
75836
75950
|
function getDiagnosticForCallNode(node, message, ...args) {
|
|
@@ -75847,6 +75961,18 @@ function createTypeChecker(host) {
|
|
|
75847
75961
|
return createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, message);
|
|
75848
75962
|
}
|
|
75849
75963
|
}
|
|
75964
|
+
function getErrorNodeForCallNode(callLike) {
|
|
75965
|
+
if (isCallOrNewExpression(callLike)) {
|
|
75966
|
+
return isPropertyAccessExpression(callLike.expression) ? callLike.expression.name : callLike.expression;
|
|
75967
|
+
}
|
|
75968
|
+
if (isTaggedTemplateExpression(callLike)) {
|
|
75969
|
+
return isPropertyAccessExpression(callLike.tag) ? callLike.tag.name : callLike.tag;
|
|
75970
|
+
}
|
|
75971
|
+
if (isJsxOpeningLikeElement(callLike)) {
|
|
75972
|
+
return callLike.tagName;
|
|
75973
|
+
}
|
|
75974
|
+
return callLike;
|
|
75975
|
+
}
|
|
75850
75976
|
function isPromiseResolveArityError(node) {
|
|
75851
75977
|
if (!isCallExpression(node) || !isIdentifier(node.expression))
|
|
75852
75978
|
return false;
|
|
@@ -76148,7 +76274,7 @@ function createTypeChecker(host) {
|
|
|
76148
76274
|
const { file, start: start2, length: length2 } = diags[0];
|
|
76149
76275
|
diag2 = { file, start: start2, length: length2, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related };
|
|
76150
76276
|
} else {
|
|
76151
|
-
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, chain, related);
|
|
76277
|
+
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), getErrorNodeForCallNode(node), chain, related);
|
|
76152
76278
|
}
|
|
76153
76279
|
addImplementationSuccessElaboration(candidatesForArgumentError[0], diag2);
|
|
76154
76280
|
diagnostics.add(diag2);
|
|
@@ -76468,7 +76594,7 @@ function createTypeChecker(host) {
|
|
|
76468
76594
|
}
|
|
76469
76595
|
return resolveErrorCall(node);
|
|
76470
76596
|
}
|
|
76471
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
76597
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
|
|
76472
76598
|
skippedGenericFunction(node, checkMode);
|
|
76473
76599
|
return resolvingSignature;
|
|
76474
76600
|
}
|
|
@@ -76478,8 +76604,12 @@ function createTypeChecker(host) {
|
|
|
76478
76604
|
}
|
|
76479
76605
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
76480
76606
|
}
|
|
76481
|
-
function
|
|
76482
|
-
|
|
76607
|
+
function isGenericFunctionReturningFunctionOrConstructor(signature) {
|
|
76608
|
+
if (!signature.typeParameters) {
|
|
76609
|
+
return false;
|
|
76610
|
+
}
|
|
76611
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
76612
|
+
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
76483
76613
|
}
|
|
76484
76614
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
76485
76615
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -76676,11 +76806,7 @@ function createTypeChecker(host) {
|
|
|
76676
76806
|
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
|
|
76677
76807
|
}
|
|
76678
76808
|
if (isCallExpression(errorTarget.parent)) {
|
|
76679
|
-
const { start: start2, length: length2 } = getDiagnosticSpanForCallNode(
|
|
76680
|
-
errorTarget.parent,
|
|
76681
|
-
/*doNotIncludeArguments*/
|
|
76682
|
-
true
|
|
76683
|
-
);
|
|
76809
|
+
const { start: start2, length: length2 } = getDiagnosticSpanForCallNode(errorTarget.parent);
|
|
76684
76810
|
diagnostic.start = start2;
|
|
76685
76811
|
diagnostic.length = length2;
|
|
76686
76812
|
}
|
|
@@ -80050,16 +80176,19 @@ function createTypeChecker(host) {
|
|
|
80050
80176
|
}
|
|
80051
80177
|
}
|
|
80052
80178
|
}
|
|
80053
|
-
function
|
|
80179
|
+
function getNonGenericReturnTypeOfSingleCallSignature(funcType) {
|
|
80054
80180
|
const signature = getSingleCallSignature(funcType);
|
|
80055
|
-
if (signature
|
|
80056
|
-
|
|
80181
|
+
if (signature) {
|
|
80182
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
80183
|
+
if (!signature.typeParameters || !couldContainTypeVariables(returnType)) {
|
|
80184
|
+
return returnType;
|
|
80185
|
+
}
|
|
80057
80186
|
}
|
|
80058
80187
|
}
|
|
80059
80188
|
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
|
|
80060
80189
|
const funcType = checkExpression(expr.expression);
|
|
80061
80190
|
const nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
|
|
80062
|
-
const returnType =
|
|
80191
|
+
const returnType = getNonGenericReturnTypeOfSingleCallSignature(funcType);
|
|
80063
80192
|
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
|
|
80064
80193
|
}
|
|
80065
80194
|
function getTypeOfExpression(node) {
|
|
@@ -80104,7 +80233,7 @@ function createTypeChecker(host) {
|
|
|
80104
80233
|
/*requireStringLiteralLikeArgument*/
|
|
80105
80234
|
true
|
|
80106
80235
|
) && !isSymbolOrSymbolForCall(expr)) {
|
|
80107
|
-
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
|
80236
|
+
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getNonGenericReturnTypeOfSingleCallSignature(checkNonNullExpression(expr.expression));
|
|
80108
80237
|
} else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
|
|
80109
80238
|
return getTypeFromTypeNode(expr.type);
|
|
80110
80239
|
} else if (isLiteralExpression(node) || isBooleanLiteral(node)) {
|
|
@@ -80976,7 +81105,8 @@ function createTypeChecker(host) {
|
|
|
80976
81105
|
}
|
|
80977
81106
|
const objectType = type.objectType;
|
|
80978
81107
|
const indexType = type.indexType;
|
|
80979
|
-
|
|
81108
|
+
const objectIndexType = isGenericMappedType(objectType) && getMappedTypeNameTypeKind(objectType) === 2 /* Remapping */ ? getIndexTypeForMappedType(objectType, 0 /* None */) : getIndexType(objectType, 0 /* None */);
|
|
81109
|
+
if (isTypeAssignableTo(indexType, objectIndexType)) {
|
|
80980
81110
|
if (accessNode.kind === 212 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
80981
81111
|
error2(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
80982
81112
|
}
|
|
@@ -137685,7 +137815,7 @@ function transpileModule(input, transpileOptions) {
|
|
|
137685
137815
|
options
|
|
137686
137816
|
),
|
|
137687
137817
|
setExternalModuleIndicator: getSetExternalModuleIndicator(options),
|
|
137688
|
-
jsDocParsingMode: 1 /* ParseNone */
|
|
137818
|
+
jsDocParsingMode: transpileOptions.jsDocParsingMode ?? 1 /* ParseNone */
|
|
137689
137819
|
}
|
|
137690
137820
|
);
|
|
137691
137821
|
if (transpileOptions.moduleName) {
|
|
@@ -165805,6 +165935,17 @@ function provideInlayHints(context) {
|
|
|
165805
165935
|
visitForDisplayParts(node.type);
|
|
165806
165936
|
}
|
|
165807
165937
|
break;
|
|
165938
|
+
case 181 /* IndexSignature */:
|
|
165939
|
+
Debug.assertNode(node, isIndexSignatureDeclaration);
|
|
165940
|
+
Debug.assertEqual(node.parameters.length, 1);
|
|
165941
|
+
parts.push({ text: "[" });
|
|
165942
|
+
visitForDisplayParts(node.parameters[0]);
|
|
165943
|
+
parts.push({ text: "]" });
|
|
165944
|
+
if (node.type) {
|
|
165945
|
+
parts.push({ text: ": " });
|
|
165946
|
+
visitForDisplayParts(node.type);
|
|
165947
|
+
}
|
|
165948
|
+
break;
|
|
165808
165949
|
case 173 /* MethodSignature */:
|
|
165809
165950
|
Debug.assertNode(node, isMethodSignature);
|
|
165810
165951
|
if ((_b = node.modifiers) == null ? void 0 : _b.length) {
|
package/lib/typescript.d.ts
CHANGED
|
@@ -11618,6 +11618,7 @@ declare namespace ts {
|
|
|
11618
11618
|
moduleName?: string;
|
|
11619
11619
|
renamedDependencies?: MapLike<string>;
|
|
11620
11620
|
transformers?: CustomTransformers;
|
|
11621
|
+
jsDocParsingMode?: JSDocParsingMode;
|
|
11621
11622
|
}
|
|
11622
11623
|
interface TranspileOutput {
|
|
11623
11624
|
outputText: string;
|