@typescript-deploys/pr-build 6.0.0-pr-54029-2 → 6.0.0-pr-53017-28
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/_tsc.js +160 -112
- package/lib/lib.es5.d.ts +9 -0
- package/lib/typescript.js +160 -112
- package/package.json +1 -1
package/lib/_tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "6.0";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20251201`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -17397,16 +17397,15 @@ function getCheckFlags(symbol) {
|
|
|
17397
17397
|
return symbol.flags & 33554432 /* Transient */ ? symbol.links.checkFlags : 0;
|
|
17398
17398
|
}
|
|
17399
17399
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) {
|
|
17400
|
-
|
|
17401
|
-
if (!(checkFlags & 8192 /* ReverseMapped */) && s.valueDeclaration) {
|
|
17400
|
+
if (s.valueDeclaration) {
|
|
17402
17401
|
const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration;
|
|
17403
17402
|
const flags = getCombinedModifierFlags(declaration);
|
|
17404
17403
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */;
|
|
17405
17404
|
}
|
|
17406
|
-
if (
|
|
17407
|
-
const
|
|
17408
|
-
const accessModifier =
|
|
17409
|
-
const staticModifier =
|
|
17405
|
+
if (getCheckFlags(s) & 6 /* Synthetic */) {
|
|
17406
|
+
const checkFlags = s.links.checkFlags;
|
|
17407
|
+
const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */;
|
|
17408
|
+
const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0;
|
|
17410
17409
|
return accessModifier | staticModifier;
|
|
17411
17410
|
}
|
|
17412
17411
|
if (s.flags & 4194304 /* Prototype */) {
|
|
@@ -47076,6 +47075,32 @@ function createTypeChecker(host) {
|
|
|
47076
47075
|
emptyArray
|
|
47077
47076
|
);
|
|
47078
47077
|
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
|
|
47078
|
+
var allKeysUnknownType = createAnonymousType(
|
|
47079
|
+
/*symbol*/
|
|
47080
|
+
void 0,
|
|
47081
|
+
emptySymbols,
|
|
47082
|
+
emptyArray,
|
|
47083
|
+
emptyArray,
|
|
47084
|
+
map(stringNumberSymbolType.types, (t) => createIndexInfo(
|
|
47085
|
+
t,
|
|
47086
|
+
unknownType,
|
|
47087
|
+
/*isReadonly*/
|
|
47088
|
+
false
|
|
47089
|
+
))
|
|
47090
|
+
);
|
|
47091
|
+
var allKeysAllKeysUnknownType = createAnonymousType(
|
|
47092
|
+
/*symbol*/
|
|
47093
|
+
void 0,
|
|
47094
|
+
emptySymbols,
|
|
47095
|
+
emptyArray,
|
|
47096
|
+
emptyArray,
|
|
47097
|
+
map(stringNumberSymbolType.types, (t) => createIndexInfo(
|
|
47098
|
+
t,
|
|
47099
|
+
allKeysUnknownType,
|
|
47100
|
+
/*isReadonly*/
|
|
47101
|
+
false
|
|
47102
|
+
))
|
|
47103
|
+
);
|
|
47079
47104
|
var emptyGenericType = createAnonymousType(
|
|
47080
47105
|
/*symbol*/
|
|
47081
47106
|
void 0,
|
|
@@ -47294,6 +47319,7 @@ function createTypeChecker(host) {
|
|
|
47294
47319
|
var deferredGlobalBigIntType;
|
|
47295
47320
|
var deferredGlobalNaNSymbol;
|
|
47296
47321
|
var deferredGlobalRecordSymbol;
|
|
47322
|
+
var deferredGlobalPartialInferenceSymbol;
|
|
47297
47323
|
var deferredGlobalClassDecoratorContextType;
|
|
47298
47324
|
var deferredGlobalClassMethodDecoratorContextType;
|
|
47299
47325
|
var deferredGlobalClassGetterDecoratorContextType;
|
|
@@ -58285,13 +58311,7 @@ function createTypeChecker(host) {
|
|
|
58285
58311
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
58286
58312
|
const readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true;
|
|
58287
58313
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
58288
|
-
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(
|
|
58289
|
-
indexInfo.type,
|
|
58290
|
-
type.mappedType,
|
|
58291
|
-
type.constraintType,
|
|
58292
|
-
/*sourceValueDeclaration*/
|
|
58293
|
-
void 0
|
|
58294
|
-
) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
58314
|
+
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
58295
58315
|
const members = createSymbolTable();
|
|
58296
58316
|
const limitedConstraint = getLimitedConstraint(type);
|
|
58297
58317
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
@@ -58304,18 +58324,10 @@ function createTypeChecker(host) {
|
|
|
58304
58324
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
58305
58325
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
58306
58326
|
inferredProp.declarations = prop.declarations;
|
|
58307
|
-
inferredProp.valueDeclaration = prop.valueDeclaration;
|
|
58308
58327
|
inferredProp.links.nameType = getSymbolLinks(prop).nameType;
|
|
58309
58328
|
inferredProp.links.propertyType = getTypeOfSymbol(prop);
|
|
58310
|
-
|
|
58311
|
-
|
|
58312
|
-
const newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam);
|
|
58313
|
-
inferredProp.links.mappedType = newMappedType;
|
|
58314
|
-
inferredProp.links.constraintType = getIndexType(newTypeParam);
|
|
58315
|
-
} else {
|
|
58316
|
-
inferredProp.links.mappedType = type.mappedType;
|
|
58317
|
-
inferredProp.links.constraintType = type.constraintType;
|
|
58318
|
-
}
|
|
58329
|
+
inferredProp.links.mappedType = type.mappedType;
|
|
58330
|
+
inferredProp.links.constraintType = type.constraintType;
|
|
58319
58331
|
members.set(prop.escapedName, inferredProp);
|
|
58320
58332
|
}
|
|
58321
58333
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, indexInfos);
|
|
@@ -60884,6 +60896,16 @@ function createTypeChecker(host) {
|
|
|
60884
60896
|
) || unknownSymbol);
|
|
60885
60897
|
return deferredGlobalRecordSymbol === unknownSymbol ? void 0 : deferredGlobalRecordSymbol;
|
|
60886
60898
|
}
|
|
60899
|
+
function getGlobalPartialInferenceSymbol() {
|
|
60900
|
+
deferredGlobalPartialInferenceSymbol || (deferredGlobalPartialInferenceSymbol = getGlobalTypeAliasSymbol(
|
|
60901
|
+
"PartialInference",
|
|
60902
|
+
/*arity*/
|
|
60903
|
+
2,
|
|
60904
|
+
/*reportErrors*/
|
|
60905
|
+
false
|
|
60906
|
+
) || unknownSymbol);
|
|
60907
|
+
return deferredGlobalPartialInferenceSymbol === unknownSymbol ? void 0 : deferredGlobalPartialInferenceSymbol;
|
|
60908
|
+
}
|
|
60887
60909
|
function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
|
|
60888
60910
|
return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
|
|
60889
60911
|
}
|
|
@@ -68115,10 +68137,7 @@ function createTypeChecker(host) {
|
|
|
68115
68137
|
map(context.inferences, (i) => i.typeParameter),
|
|
68116
68138
|
map(context.inferences, (inference, i) => () => {
|
|
68117
68139
|
if (!inference.isFixed) {
|
|
68118
|
-
|
|
68119
|
-
inferFromIntraExpressionSites(context.inferences, context.intraExpressionInferenceSites);
|
|
68120
|
-
context.intraExpressionInferenceSites = void 0;
|
|
68121
|
-
}
|
|
68140
|
+
inferFromIntraExpressionSites(context);
|
|
68122
68141
|
clearCachedInferences(context.inferences);
|
|
68123
68142
|
inference.isFixed = true;
|
|
68124
68143
|
}
|
|
@@ -68142,38 +68161,17 @@ function createTypeChecker(host) {
|
|
|
68142
68161
|
}
|
|
68143
68162
|
}
|
|
68144
68163
|
function addIntraExpressionInferenceSite(context, node, type) {
|
|
68145
|
-
|
|
68146
|
-
(context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push(site);
|
|
68147
|
-
if (context.reverseMappedIntraExpressionInferenceSites) {
|
|
68148
|
-
for (const reverseMappedSites of context.reverseMappedIntraExpressionInferenceSites) {
|
|
68149
|
-
reverseMappedSites.push(site);
|
|
68150
|
-
}
|
|
68151
|
-
}
|
|
68152
|
-
}
|
|
68153
|
-
function pushReverseMappedTypeIntraExpressionInferenceScope(context, node) {
|
|
68154
|
-
(context.reverseMappedIntraExpressionInferenceScopeNodes ?? (context.reverseMappedIntraExpressionInferenceScopeNodes = [])).push(node);
|
|
68155
|
-
(context.reverseMappedIntraExpressionInferenceSites ?? (context.reverseMappedIntraExpressionInferenceSites = [])).push([]);
|
|
68164
|
+
(context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push({ node, type });
|
|
68156
68165
|
}
|
|
68157
|
-
function
|
|
68158
|
-
context.
|
|
68159
|
-
|
|
68160
|
-
|
|
68161
|
-
|
|
68162
|
-
|
|
68163
|
-
for (let i = context.reverseMappedIntraExpressionInferenceScopeNodes.length - 1; i >= 0; i--) {
|
|
68164
|
-
if (context.reverseMappedIntraExpressionInferenceScopeNodes[i] === node) {
|
|
68165
|
-
return i;
|
|
68166
|
+
function inferFromIntraExpressionSites(context) {
|
|
68167
|
+
if (context.intraExpressionInferenceSites) {
|
|
68168
|
+
for (const { node, type } of context.intraExpressionInferenceSites) {
|
|
68169
|
+
const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType(node, 2 /* NoConstraints */);
|
|
68170
|
+
if (contextualType) {
|
|
68171
|
+
inferTypes(context.inferences, type, contextualType);
|
|
68166
68172
|
}
|
|
68167
68173
|
}
|
|
68168
|
-
|
|
68169
|
-
return -1;
|
|
68170
|
-
}
|
|
68171
|
-
function inferFromIntraExpressionSites(inferences, intraExpressionInferenceSites) {
|
|
68172
|
-
for (const { node, type } of intraExpressionInferenceSites) {
|
|
68173
|
-
const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType(node, 2 /* NoConstraints */);
|
|
68174
|
-
if (contextualType) {
|
|
68175
|
-
inferTypes(inferences, type, contextualType);
|
|
68176
|
-
}
|
|
68174
|
+
context.intraExpressionInferenceSites = void 0;
|
|
68177
68175
|
}
|
|
68178
68176
|
}
|
|
68179
68177
|
function createInferenceInfo(typeParameter) {
|
|
@@ -68185,7 +68183,8 @@ function createTypeChecker(host) {
|
|
|
68185
68183
|
priority: void 0,
|
|
68186
68184
|
topLevel: true,
|
|
68187
68185
|
isFixed: false,
|
|
68188
|
-
impliedArity: void 0
|
|
68186
|
+
impliedArity: void 0,
|
|
68187
|
+
indexes: void 0
|
|
68189
68188
|
};
|
|
68190
68189
|
}
|
|
68191
68190
|
function cloneInferenceInfo(inference) {
|
|
@@ -68197,7 +68196,8 @@ function createTypeChecker(host) {
|
|
|
68197
68196
|
priority: inference.priority,
|
|
68198
68197
|
topLevel: inference.topLevel,
|
|
68199
68198
|
isFixed: inference.isFixed,
|
|
68200
|
-
impliedArity: inference.impliedArity
|
|
68199
|
+
impliedArity: inference.impliedArity,
|
|
68200
|
+
indexes: inference.indexes && inference.indexes.slice()
|
|
68201
68201
|
};
|
|
68202
68202
|
}
|
|
68203
68203
|
function cloneInferredPartOfContext(context) {
|
|
@@ -68263,6 +68263,11 @@ function createTypeChecker(host) {
|
|
|
68263
68263
|
);
|
|
68264
68264
|
}
|
|
68265
68265
|
function inferTypeForHomomorphicMappedType(source, target, constraint) {
|
|
68266
|
+
if (constraint.type.flags & 8388608 /* IndexedAccess */) {
|
|
68267
|
+
const newTypeParam = constraint.type.objectType;
|
|
68268
|
+
target = replaceIndexedAccess(target, constraint.type, newTypeParam);
|
|
68269
|
+
constraint = getIndexType(newTypeParam);
|
|
68270
|
+
}
|
|
68266
68271
|
const cacheKey = source.id + "," + target.id + "," + constraint.id;
|
|
68267
68272
|
if (reverseHomomorphicMappedCache.has(cacheKey)) {
|
|
68268
68273
|
return reverseHomomorphicMappedCache.get(cacheKey);
|
|
@@ -68271,31 +68276,22 @@ function createTypeChecker(host) {
|
|
|
68271
68276
|
reverseHomomorphicMappedCache.set(cacheKey, type);
|
|
68272
68277
|
return type;
|
|
68273
68278
|
}
|
|
68279
|
+
function isPartiallyInferableType(type) {
|
|
68280
|
+
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
|
|
68281
|
+
}
|
|
68274
68282
|
function createReverseMappedType(source, target, constraint) {
|
|
68275
|
-
if (!getIndexInfoOfType(source, stringType)
|
|
68283
|
+
if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
|
|
68276
68284
|
return void 0;
|
|
68277
68285
|
}
|
|
68278
68286
|
if (isArrayType(source)) {
|
|
68279
|
-
const elementType = inferReverseMappedType(
|
|
68280
|
-
getTypeArguments(source)[0],
|
|
68281
|
-
target,
|
|
68282
|
-
constraint,
|
|
68283
|
-
/*sourceValueDeclaration*/
|
|
68284
|
-
void 0
|
|
68285
|
-
);
|
|
68287
|
+
const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint);
|
|
68286
68288
|
if (!elementType) {
|
|
68287
68289
|
return void 0;
|
|
68288
68290
|
}
|
|
68289
68291
|
return createArrayType(elementType, isReadonlyArrayType(source));
|
|
68290
68292
|
}
|
|
68291
68293
|
if (isTupleType(source)) {
|
|
68292
|
-
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(
|
|
68293
|
-
t,
|
|
68294
|
-
target,
|
|
68295
|
-
constraint,
|
|
68296
|
-
/*sourceValueDeclaration*/
|
|
68297
|
-
void 0
|
|
68298
|
-
));
|
|
68294
|
+
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
|
|
68299
68295
|
if (!every(elementTypes, (t) => !!t)) {
|
|
68300
68296
|
return void 0;
|
|
68301
68297
|
}
|
|
@@ -68315,39 +68311,28 @@ function createTypeChecker(host) {
|
|
|
68315
68311
|
function getTypeOfReverseMappedSymbol(symbol) {
|
|
68316
68312
|
const links = getSymbolLinks(symbol);
|
|
68317
68313
|
if (!links.type) {
|
|
68318
|
-
links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType
|
|
68314
|
+
links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType) || unknownType;
|
|
68319
68315
|
}
|
|
68320
68316
|
return links.type;
|
|
68321
68317
|
}
|
|
68322
|
-
function inferReverseMappedTypeWorker(sourceType, target, constraint
|
|
68323
|
-
const typeParameter =
|
|
68318
|
+
function inferReverseMappedTypeWorker(sourceType, target, constraint) {
|
|
68319
|
+
const typeParameter = getTypeParameterFromMappedType(target);
|
|
68320
|
+
const inferenceTarget = getIndexedAccessType(constraint.type, typeParameter);
|
|
68324
68321
|
const templateType = getTemplateTypeFromMappedType(target);
|
|
68325
|
-
const inference = createInferenceInfo(
|
|
68322
|
+
const inference = createInferenceInfo(inferenceTarget);
|
|
68326
68323
|
inferTypes([inference], sourceType, templateType);
|
|
68327
|
-
|
|
68328
|
-
|
|
68329
|
-
|
|
68330
|
-
const index = findReverseMappedTypeIntraExpressionInferenceScope(inferenceContext, scopeNode);
|
|
68331
|
-
if (index !== -1) {
|
|
68332
|
-
Debug.assert(inferenceContext);
|
|
68333
|
-
const intraExpressionSites = inferenceContext.reverseMappedIntraExpressionInferenceSites[index];
|
|
68334
|
-
const recordSymbol = getGlobalRecordSymbol();
|
|
68335
|
-
if (intraExpressionSites.length && recordSymbol) {
|
|
68336
|
-
pushContextualType(
|
|
68337
|
-
scopeNode,
|
|
68338
|
-
getTypeAliasInstantiation(recordSymbol, [stringNumberSymbolType, templateType]),
|
|
68339
|
-
/*isCache*/
|
|
68340
|
-
false
|
|
68341
|
-
);
|
|
68342
|
-
inferFromIntraExpressionSites([inference], intraExpressionSites);
|
|
68343
|
-
popContextualType();
|
|
68344
|
-
}
|
|
68345
|
-
}
|
|
68324
|
+
const inferredType = getTypeFromInference(inference);
|
|
68325
|
+
if (inferredType) {
|
|
68326
|
+
return inferredType;
|
|
68346
68327
|
}
|
|
68347
|
-
|
|
68328
|
+
if (inference.indexes) {
|
|
68329
|
+
const eraseSelfMapper = makeArrayTypeMapper([constraint.type, typeParameter], [allKeysAllKeysUnknownType, stringNumberSymbolType]);
|
|
68330
|
+
return instantiateType(getIntersectionType(inference.indexes), eraseSelfMapper);
|
|
68331
|
+
}
|
|
68332
|
+
return unknownType;
|
|
68348
68333
|
}
|
|
68349
|
-
function inferReverseMappedType(source, target, constraint
|
|
68350
|
-
const cacheKey = source.id + "," + target.id + "," + constraint.id
|
|
68334
|
+
function inferReverseMappedType(source, target, constraint) {
|
|
68335
|
+
const cacheKey = source.id + "," + target.id + "," + constraint.id;
|
|
68351
68336
|
if (reverseMappedCache.has(cacheKey)) {
|
|
68352
68337
|
return reverseMappedCache.get(cacheKey) || unknownType;
|
|
68353
68338
|
}
|
|
@@ -68358,7 +68343,7 @@ function createTypeChecker(host) {
|
|
|
68358
68343
|
if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2)) reverseExpandingFlags |= 2 /* Target */;
|
|
68359
68344
|
let type;
|
|
68360
68345
|
if (reverseExpandingFlags !== 3 /* Both */) {
|
|
68361
|
-
type = inferReverseMappedTypeWorker(source, target, constraint
|
|
68346
|
+
type = inferReverseMappedTypeWorker(source, target, constraint);
|
|
68362
68347
|
}
|
|
68363
68348
|
reverseMappedSourceStack.pop();
|
|
68364
68349
|
reverseMappedTargetStack.pop();
|
|
@@ -68685,6 +68670,29 @@ function createTypeChecker(host) {
|
|
|
68685
68670
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
68686
68671
|
inferFromTypes(source.objectType, target.objectType);
|
|
68687
68672
|
inferFromTypes(source.indexType, target.indexType);
|
|
68673
|
+
} else if (!(priority & 1 /* NakedTypeVariable */) && target.flags & 8388608 /* IndexedAccess */) {
|
|
68674
|
+
if (isFromInferenceBlockedSource(source)) {
|
|
68675
|
+
return;
|
|
68676
|
+
}
|
|
68677
|
+
const inference = getInferenceInfoForType(getActualTypeVariable(target.objectType));
|
|
68678
|
+
if (inference) {
|
|
68679
|
+
if (getObjectFlags(source) & 262144 /* NonInferrableType */ || source === nonInferrableAnyType) {
|
|
68680
|
+
return;
|
|
68681
|
+
}
|
|
68682
|
+
if (!inference.isFixed) {
|
|
68683
|
+
const partialInferenceTypeSymbol = getGlobalPartialInferenceSymbol();
|
|
68684
|
+
if (partialInferenceTypeSymbol) {
|
|
68685
|
+
if (target.indexType.flags & 465829888 /* Instantiable */) {
|
|
68686
|
+
const recordSymbol = getGlobalRecordSymbol();
|
|
68687
|
+
if (recordSymbol) {
|
|
68688
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(recordSymbol, [target.indexType, source]));
|
|
68689
|
+
}
|
|
68690
|
+
} else {
|
|
68691
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(partialInferenceTypeSymbol, [source, target.indexType]));
|
|
68692
|
+
}
|
|
68693
|
+
}
|
|
68694
|
+
}
|
|
68695
|
+
}
|
|
68688
68696
|
} else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) {
|
|
68689
68697
|
if (source.symbol === target.symbol) {
|
|
68690
68698
|
inferFromTypes(source.type, target.type);
|
|
@@ -68878,7 +68886,7 @@ function createTypeChecker(host) {
|
|
|
68878
68886
|
}
|
|
68879
68887
|
}
|
|
68880
68888
|
function inferToMappedType(source, target, constraintType) {
|
|
68881
|
-
if (constraintType.flags &
|
|
68889
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
68882
68890
|
let result = false;
|
|
68883
68891
|
for (const type of constraintType.types) {
|
|
68884
68892
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -69188,6 +69196,52 @@ function createTypeChecker(host) {
|
|
|
69188
69196
|
const preferCovariantType = inferredCovariantType && (!inferredContravariantType || !(inferredCovariantType.flags & (131072 /* Never */ | 1 /* Any */)) && some(inference.contraCandidates, (t) => isTypeAssignableTo(inferredCovariantType, t)) && every(context.inferences, (other) => other !== inference && getConstraintOfTypeParameter(other.typeParameter) !== inference.typeParameter || every(other.candidates, (t) => isTypeAssignableTo(t, inferredCovariantType))));
|
|
69189
69197
|
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
69190
69198
|
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
69199
|
+
} else if (inference.indexes) {
|
|
69200
|
+
const eraseSelfMapper = makeUnaryTypeMapper(inference.typeParameter, allKeysUnknownType);
|
|
69201
|
+
let aggregateInference = instantiateType(getIntersectionType(inference.indexes), mergeTypeMappers(eraseSelfMapper, context.nonFixingMapper));
|
|
69202
|
+
const constraint2 = getConstraintOfTypeParameter(inference.typeParameter);
|
|
69203
|
+
if (constraint2) {
|
|
69204
|
+
const instantiatedConstraint = instantiateType(constraint2, context.nonFixingMapper);
|
|
69205
|
+
if (instantiatedConstraint.flags & 1048576 /* Union */ && !context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference))) {
|
|
69206
|
+
const discriminantProps = findDiscriminantProperties(getPropertiesOfType(aggregateInference), instantiatedConstraint);
|
|
69207
|
+
if (discriminantProps) {
|
|
69208
|
+
let match;
|
|
69209
|
+
findDiscriminant:
|
|
69210
|
+
for (const p of discriminantProps) {
|
|
69211
|
+
const candidatePropType = getTypeOfPropertyOfType(aggregateInference, p.escapedName);
|
|
69212
|
+
for (const type of instantiatedConstraint.types) {
|
|
69213
|
+
const propType = getTypeOfPropertyOfType(type, p.escapedName);
|
|
69214
|
+
if (propType && candidatePropType && checkTypeAssignableTo(
|
|
69215
|
+
candidatePropType,
|
|
69216
|
+
propType,
|
|
69217
|
+
/*errorNode*/
|
|
69218
|
+
void 0
|
|
69219
|
+
)) {
|
|
69220
|
+
if (match && match !== type) {
|
|
69221
|
+
match = void 0;
|
|
69222
|
+
break findDiscriminant;
|
|
69223
|
+
} else {
|
|
69224
|
+
match = type;
|
|
69225
|
+
}
|
|
69226
|
+
}
|
|
69227
|
+
}
|
|
69228
|
+
}
|
|
69229
|
+
if (match) {
|
|
69230
|
+
aggregateInference = getSpreadType(
|
|
69231
|
+
match,
|
|
69232
|
+
aggregateInference,
|
|
69233
|
+
/*symbol*/
|
|
69234
|
+
void 0,
|
|
69235
|
+
/*propegatedFlags*/
|
|
69236
|
+
0,
|
|
69237
|
+
/*readonly*/
|
|
69238
|
+
false
|
|
69239
|
+
);
|
|
69240
|
+
}
|
|
69241
|
+
}
|
|
69242
|
+
}
|
|
69243
|
+
}
|
|
69244
|
+
inferredType = aggregateInference;
|
|
69191
69245
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
69192
69246
|
inferredType = silentNeverType;
|
|
69193
69247
|
} else {
|
|
@@ -74042,25 +74096,17 @@ function createTypeChecker(host) {
|
|
|
74042
74096
|
checkComputedPropertyName(elem.name);
|
|
74043
74097
|
}
|
|
74044
74098
|
}
|
|
74045
|
-
const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
|
|
74046
74099
|
let offset = 0;
|
|
74047
74100
|
for (const memberDecl of node.properties) {
|
|
74048
74101
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
74049
74102
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
74050
74103
|
if (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 305 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
74051
|
-
const isIntraExpressionInferenceSource = intraExpressionInferenceContext && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl);
|
|
74052
|
-
if (isIntraExpressionInferenceSource) {
|
|
74053
|
-
pushReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext, node);
|
|
74054
|
-
}
|
|
74055
74104
|
let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
74056
74105
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
74057
74106
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
74058
74107
|
// we don't want to say "could not find 'a'".
|
|
74059
74108
|
memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
74060
74109
|
);
|
|
74061
|
-
if (isIntraExpressionInferenceSource) {
|
|
74062
|
-
popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
|
|
74063
|
-
}
|
|
74064
74110
|
if (isInJavascript) {
|
|
74065
74111
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
74066
74112
|
if (jsDocType) {
|
|
@@ -74095,9 +74141,11 @@ function createTypeChecker(host) {
|
|
|
74095
74141
|
prop.links.target = member;
|
|
74096
74142
|
member = prop;
|
|
74097
74143
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
74098
|
-
if (
|
|
74144
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
74145
|
+
const inferenceContext = getInferenceContext(node);
|
|
74146
|
+
Debug.assert(inferenceContext);
|
|
74099
74147
|
const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
74100
|
-
addIntraExpressionInferenceSite(
|
|
74148
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
74101
74149
|
}
|
|
74102
74150
|
} else if (memberDecl.kind === 306 /* SpreadAssignment */) {
|
|
74103
74151
|
if (languageVersion < LanguageFeatureMinimumTarget.ObjectAssign) {
|
package/lib/lib.es5.d.ts
CHANGED
|
@@ -1682,6 +1682,15 @@ type NoInfer<T> = intrinsic;
|
|
|
1682
1682
|
*/
|
|
1683
1683
|
interface ThisType<T> {}
|
|
1684
1684
|
|
|
1685
|
+
/**
|
|
1686
|
+
* Type instantiated to perform partial inferences from indexed accesses
|
|
1687
|
+
*/
|
|
1688
|
+
type PartialInference<T, Keys extends PropertyKey> = ({
|
|
1689
|
+
[K in Keys]: {
|
|
1690
|
+
[K1 in K]: T;
|
|
1691
|
+
};
|
|
1692
|
+
})[Keys];
|
|
1693
|
+
|
|
1685
1694
|
/**
|
|
1686
1695
|
* Stores types to be used with WeakSet, WeakMap, WeakRef, and FinalizationRegistry
|
|
1687
1696
|
*/
|
package/lib/typescript.js
CHANGED
|
@@ -2286,7 +2286,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2286
2286
|
|
|
2287
2287
|
// src/compiler/corePublic.ts
|
|
2288
2288
|
var versionMajorMinor = "6.0";
|
|
2289
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2289
|
+
var version = `${versionMajorMinor}.0-insiders.20251201`;
|
|
2290
2290
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2291
2291
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2292
2292
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -21301,16 +21301,15 @@ function getCheckFlags(symbol) {
|
|
|
21301
21301
|
return symbol.flags & 33554432 /* Transient */ ? symbol.links.checkFlags : 0;
|
|
21302
21302
|
}
|
|
21303
21303
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) {
|
|
21304
|
-
|
|
21305
|
-
if (!(checkFlags & 8192 /* ReverseMapped */) && s.valueDeclaration) {
|
|
21304
|
+
if (s.valueDeclaration) {
|
|
21306
21305
|
const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration;
|
|
21307
21306
|
const flags = getCombinedModifierFlags(declaration);
|
|
21308
21307
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */;
|
|
21309
21308
|
}
|
|
21310
|
-
if (
|
|
21311
|
-
const
|
|
21312
|
-
const accessModifier =
|
|
21313
|
-
const staticModifier =
|
|
21309
|
+
if (getCheckFlags(s) & 6 /* Synthetic */) {
|
|
21310
|
+
const checkFlags = s.links.checkFlags;
|
|
21311
|
+
const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */;
|
|
21312
|
+
const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0;
|
|
21314
21313
|
return accessModifier | staticModifier;
|
|
21315
21314
|
}
|
|
21316
21315
|
if (s.flags & 4194304 /* Prototype */) {
|
|
@@ -51704,6 +51703,32 @@ function createTypeChecker(host) {
|
|
|
51704
51703
|
emptyArray
|
|
51705
51704
|
);
|
|
51706
51705
|
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
|
|
51706
|
+
var allKeysUnknownType = createAnonymousType(
|
|
51707
|
+
/*symbol*/
|
|
51708
|
+
void 0,
|
|
51709
|
+
emptySymbols,
|
|
51710
|
+
emptyArray,
|
|
51711
|
+
emptyArray,
|
|
51712
|
+
map(stringNumberSymbolType.types, (t) => createIndexInfo(
|
|
51713
|
+
t,
|
|
51714
|
+
unknownType,
|
|
51715
|
+
/*isReadonly*/
|
|
51716
|
+
false
|
|
51717
|
+
))
|
|
51718
|
+
);
|
|
51719
|
+
var allKeysAllKeysUnknownType = createAnonymousType(
|
|
51720
|
+
/*symbol*/
|
|
51721
|
+
void 0,
|
|
51722
|
+
emptySymbols,
|
|
51723
|
+
emptyArray,
|
|
51724
|
+
emptyArray,
|
|
51725
|
+
map(stringNumberSymbolType.types, (t) => createIndexInfo(
|
|
51726
|
+
t,
|
|
51727
|
+
allKeysUnknownType,
|
|
51728
|
+
/*isReadonly*/
|
|
51729
|
+
false
|
|
51730
|
+
))
|
|
51731
|
+
);
|
|
51707
51732
|
var emptyGenericType = createAnonymousType(
|
|
51708
51733
|
/*symbol*/
|
|
51709
51734
|
void 0,
|
|
@@ -51922,6 +51947,7 @@ function createTypeChecker(host) {
|
|
|
51922
51947
|
var deferredGlobalBigIntType;
|
|
51923
51948
|
var deferredGlobalNaNSymbol;
|
|
51924
51949
|
var deferredGlobalRecordSymbol;
|
|
51950
|
+
var deferredGlobalPartialInferenceSymbol;
|
|
51925
51951
|
var deferredGlobalClassDecoratorContextType;
|
|
51926
51952
|
var deferredGlobalClassMethodDecoratorContextType;
|
|
51927
51953
|
var deferredGlobalClassGetterDecoratorContextType;
|
|
@@ -62913,13 +62939,7 @@ function createTypeChecker(host) {
|
|
|
62913
62939
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
62914
62940
|
const readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true;
|
|
62915
62941
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
62916
|
-
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(
|
|
62917
|
-
indexInfo.type,
|
|
62918
|
-
type.mappedType,
|
|
62919
|
-
type.constraintType,
|
|
62920
|
-
/*sourceValueDeclaration*/
|
|
62921
|
-
void 0
|
|
62922
|
-
) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
62942
|
+
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
62923
62943
|
const members = createSymbolTable();
|
|
62924
62944
|
const limitedConstraint = getLimitedConstraint(type);
|
|
62925
62945
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
@@ -62932,18 +62952,10 @@ function createTypeChecker(host) {
|
|
|
62932
62952
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
62933
62953
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
62934
62954
|
inferredProp.declarations = prop.declarations;
|
|
62935
|
-
inferredProp.valueDeclaration = prop.valueDeclaration;
|
|
62936
62955
|
inferredProp.links.nameType = getSymbolLinks(prop).nameType;
|
|
62937
62956
|
inferredProp.links.propertyType = getTypeOfSymbol(prop);
|
|
62938
|
-
|
|
62939
|
-
|
|
62940
|
-
const newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam);
|
|
62941
|
-
inferredProp.links.mappedType = newMappedType;
|
|
62942
|
-
inferredProp.links.constraintType = getIndexType(newTypeParam);
|
|
62943
|
-
} else {
|
|
62944
|
-
inferredProp.links.mappedType = type.mappedType;
|
|
62945
|
-
inferredProp.links.constraintType = type.constraintType;
|
|
62946
|
-
}
|
|
62957
|
+
inferredProp.links.mappedType = type.mappedType;
|
|
62958
|
+
inferredProp.links.constraintType = type.constraintType;
|
|
62947
62959
|
members.set(prop.escapedName, inferredProp);
|
|
62948
62960
|
}
|
|
62949
62961
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, indexInfos);
|
|
@@ -65512,6 +65524,16 @@ function createTypeChecker(host) {
|
|
|
65512
65524
|
) || unknownSymbol);
|
|
65513
65525
|
return deferredGlobalRecordSymbol === unknownSymbol ? void 0 : deferredGlobalRecordSymbol;
|
|
65514
65526
|
}
|
|
65527
|
+
function getGlobalPartialInferenceSymbol() {
|
|
65528
|
+
deferredGlobalPartialInferenceSymbol || (deferredGlobalPartialInferenceSymbol = getGlobalTypeAliasSymbol(
|
|
65529
|
+
"PartialInference",
|
|
65530
|
+
/*arity*/
|
|
65531
|
+
2,
|
|
65532
|
+
/*reportErrors*/
|
|
65533
|
+
false
|
|
65534
|
+
) || unknownSymbol);
|
|
65535
|
+
return deferredGlobalPartialInferenceSymbol === unknownSymbol ? void 0 : deferredGlobalPartialInferenceSymbol;
|
|
65536
|
+
}
|
|
65515
65537
|
function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
|
|
65516
65538
|
return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
|
|
65517
65539
|
}
|
|
@@ -72743,10 +72765,7 @@ function createTypeChecker(host) {
|
|
|
72743
72765
|
map(context.inferences, (i) => i.typeParameter),
|
|
72744
72766
|
map(context.inferences, (inference, i) => () => {
|
|
72745
72767
|
if (!inference.isFixed) {
|
|
72746
|
-
|
|
72747
|
-
inferFromIntraExpressionSites(context.inferences, context.intraExpressionInferenceSites);
|
|
72748
|
-
context.intraExpressionInferenceSites = void 0;
|
|
72749
|
-
}
|
|
72768
|
+
inferFromIntraExpressionSites(context);
|
|
72750
72769
|
clearCachedInferences(context.inferences);
|
|
72751
72770
|
inference.isFixed = true;
|
|
72752
72771
|
}
|
|
@@ -72770,38 +72789,17 @@ function createTypeChecker(host) {
|
|
|
72770
72789
|
}
|
|
72771
72790
|
}
|
|
72772
72791
|
function addIntraExpressionInferenceSite(context, node, type) {
|
|
72773
|
-
|
|
72774
|
-
(context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push(site);
|
|
72775
|
-
if (context.reverseMappedIntraExpressionInferenceSites) {
|
|
72776
|
-
for (const reverseMappedSites of context.reverseMappedIntraExpressionInferenceSites) {
|
|
72777
|
-
reverseMappedSites.push(site);
|
|
72778
|
-
}
|
|
72779
|
-
}
|
|
72780
|
-
}
|
|
72781
|
-
function pushReverseMappedTypeIntraExpressionInferenceScope(context, node) {
|
|
72782
|
-
(context.reverseMappedIntraExpressionInferenceScopeNodes ?? (context.reverseMappedIntraExpressionInferenceScopeNodes = [])).push(node);
|
|
72783
|
-
(context.reverseMappedIntraExpressionInferenceSites ?? (context.reverseMappedIntraExpressionInferenceSites = [])).push([]);
|
|
72784
|
-
}
|
|
72785
|
-
function popReverseMappedTypeIntraExpressionInferenceScope(context) {
|
|
72786
|
-
context.reverseMappedIntraExpressionInferenceScopeNodes.pop();
|
|
72787
|
-
context.reverseMappedIntraExpressionInferenceSites.pop();
|
|
72792
|
+
(context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push({ node, type });
|
|
72788
72793
|
}
|
|
72789
|
-
function
|
|
72790
|
-
if (context
|
|
72791
|
-
for (
|
|
72792
|
-
|
|
72793
|
-
|
|
72794
|
+
function inferFromIntraExpressionSites(context) {
|
|
72795
|
+
if (context.intraExpressionInferenceSites) {
|
|
72796
|
+
for (const { node, type } of context.intraExpressionInferenceSites) {
|
|
72797
|
+
const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType2(node, 2 /* NoConstraints */);
|
|
72798
|
+
if (contextualType) {
|
|
72799
|
+
inferTypes(context.inferences, type, contextualType);
|
|
72794
72800
|
}
|
|
72795
72801
|
}
|
|
72796
|
-
|
|
72797
|
-
return -1;
|
|
72798
|
-
}
|
|
72799
|
-
function inferFromIntraExpressionSites(inferences, intraExpressionInferenceSites) {
|
|
72800
|
-
for (const { node, type } of intraExpressionInferenceSites) {
|
|
72801
|
-
const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType2(node, 2 /* NoConstraints */);
|
|
72802
|
-
if (contextualType) {
|
|
72803
|
-
inferTypes(inferences, type, contextualType);
|
|
72804
|
-
}
|
|
72802
|
+
context.intraExpressionInferenceSites = void 0;
|
|
72805
72803
|
}
|
|
72806
72804
|
}
|
|
72807
72805
|
function createInferenceInfo(typeParameter) {
|
|
@@ -72813,7 +72811,8 @@ function createTypeChecker(host) {
|
|
|
72813
72811
|
priority: void 0,
|
|
72814
72812
|
topLevel: true,
|
|
72815
72813
|
isFixed: false,
|
|
72816
|
-
impliedArity: void 0
|
|
72814
|
+
impliedArity: void 0,
|
|
72815
|
+
indexes: void 0
|
|
72817
72816
|
};
|
|
72818
72817
|
}
|
|
72819
72818
|
function cloneInferenceInfo(inference) {
|
|
@@ -72825,7 +72824,8 @@ function createTypeChecker(host) {
|
|
|
72825
72824
|
priority: inference.priority,
|
|
72826
72825
|
topLevel: inference.topLevel,
|
|
72827
72826
|
isFixed: inference.isFixed,
|
|
72828
|
-
impliedArity: inference.impliedArity
|
|
72827
|
+
impliedArity: inference.impliedArity,
|
|
72828
|
+
indexes: inference.indexes && inference.indexes.slice()
|
|
72829
72829
|
};
|
|
72830
72830
|
}
|
|
72831
72831
|
function cloneInferredPartOfContext(context) {
|
|
@@ -72891,6 +72891,11 @@ function createTypeChecker(host) {
|
|
|
72891
72891
|
);
|
|
72892
72892
|
}
|
|
72893
72893
|
function inferTypeForHomomorphicMappedType(source, target, constraint) {
|
|
72894
|
+
if (constraint.type.flags & 8388608 /* IndexedAccess */) {
|
|
72895
|
+
const newTypeParam = constraint.type.objectType;
|
|
72896
|
+
target = replaceIndexedAccess(target, constraint.type, newTypeParam);
|
|
72897
|
+
constraint = getIndexType(newTypeParam);
|
|
72898
|
+
}
|
|
72894
72899
|
const cacheKey = source.id + "," + target.id + "," + constraint.id;
|
|
72895
72900
|
if (reverseHomomorphicMappedCache.has(cacheKey)) {
|
|
72896
72901
|
return reverseHomomorphicMappedCache.get(cacheKey);
|
|
@@ -72899,31 +72904,22 @@ function createTypeChecker(host) {
|
|
|
72899
72904
|
reverseHomomorphicMappedCache.set(cacheKey, type);
|
|
72900
72905
|
return type;
|
|
72901
72906
|
}
|
|
72907
|
+
function isPartiallyInferableType(type) {
|
|
72908
|
+
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType2(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
|
|
72909
|
+
}
|
|
72902
72910
|
function createReverseMappedType(source, target, constraint) {
|
|
72903
|
-
if (!getIndexInfoOfType(source, stringType)
|
|
72911
|
+
if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
|
|
72904
72912
|
return void 0;
|
|
72905
72913
|
}
|
|
72906
72914
|
if (isArrayType(source)) {
|
|
72907
|
-
const elementType = inferReverseMappedType(
|
|
72908
|
-
getTypeArguments(source)[0],
|
|
72909
|
-
target,
|
|
72910
|
-
constraint,
|
|
72911
|
-
/*sourceValueDeclaration*/
|
|
72912
|
-
void 0
|
|
72913
|
-
);
|
|
72915
|
+
const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint);
|
|
72914
72916
|
if (!elementType) {
|
|
72915
72917
|
return void 0;
|
|
72916
72918
|
}
|
|
72917
72919
|
return createArrayType(elementType, isReadonlyArrayType(source));
|
|
72918
72920
|
}
|
|
72919
72921
|
if (isTupleType(source)) {
|
|
72920
|
-
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(
|
|
72921
|
-
t,
|
|
72922
|
-
target,
|
|
72923
|
-
constraint,
|
|
72924
|
-
/*sourceValueDeclaration*/
|
|
72925
|
-
void 0
|
|
72926
|
-
));
|
|
72922
|
+
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
|
|
72927
72923
|
if (!every(elementTypes, (t) => !!t)) {
|
|
72928
72924
|
return void 0;
|
|
72929
72925
|
}
|
|
@@ -72943,39 +72939,28 @@ function createTypeChecker(host) {
|
|
|
72943
72939
|
function getTypeOfReverseMappedSymbol(symbol) {
|
|
72944
72940
|
const links = getSymbolLinks(symbol);
|
|
72945
72941
|
if (!links.type) {
|
|
72946
|
-
links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType
|
|
72942
|
+
links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType) || unknownType;
|
|
72947
72943
|
}
|
|
72948
72944
|
return links.type;
|
|
72949
72945
|
}
|
|
72950
|
-
function inferReverseMappedTypeWorker(sourceType, target, constraint
|
|
72951
|
-
const typeParameter =
|
|
72946
|
+
function inferReverseMappedTypeWorker(sourceType, target, constraint) {
|
|
72947
|
+
const typeParameter = getTypeParameterFromMappedType(target);
|
|
72948
|
+
const inferenceTarget = getIndexedAccessType(constraint.type, typeParameter);
|
|
72952
72949
|
const templateType = getTemplateTypeFromMappedType(target);
|
|
72953
|
-
const inference = createInferenceInfo(
|
|
72950
|
+
const inference = createInferenceInfo(inferenceTarget);
|
|
72954
72951
|
inferTypes([inference], sourceType, templateType);
|
|
72955
|
-
|
|
72956
|
-
|
|
72957
|
-
|
|
72958
|
-
const index = findReverseMappedTypeIntraExpressionInferenceScope(inferenceContext, scopeNode);
|
|
72959
|
-
if (index !== -1) {
|
|
72960
|
-
Debug.assert(inferenceContext);
|
|
72961
|
-
const intraExpressionSites = inferenceContext.reverseMappedIntraExpressionInferenceSites[index];
|
|
72962
|
-
const recordSymbol = getGlobalRecordSymbol();
|
|
72963
|
-
if (intraExpressionSites.length && recordSymbol) {
|
|
72964
|
-
pushContextualType(
|
|
72965
|
-
scopeNode,
|
|
72966
|
-
getTypeAliasInstantiation(recordSymbol, [stringNumberSymbolType, templateType]),
|
|
72967
|
-
/*isCache*/
|
|
72968
|
-
false
|
|
72969
|
-
);
|
|
72970
|
-
inferFromIntraExpressionSites([inference], intraExpressionSites);
|
|
72971
|
-
popContextualType();
|
|
72972
|
-
}
|
|
72973
|
-
}
|
|
72952
|
+
const inferredType = getTypeFromInference(inference);
|
|
72953
|
+
if (inferredType) {
|
|
72954
|
+
return inferredType;
|
|
72974
72955
|
}
|
|
72975
|
-
|
|
72956
|
+
if (inference.indexes) {
|
|
72957
|
+
const eraseSelfMapper = makeArrayTypeMapper([constraint.type, typeParameter], [allKeysAllKeysUnknownType, stringNumberSymbolType]);
|
|
72958
|
+
return instantiateType(getIntersectionType(inference.indexes), eraseSelfMapper);
|
|
72959
|
+
}
|
|
72960
|
+
return unknownType;
|
|
72976
72961
|
}
|
|
72977
|
-
function inferReverseMappedType(source, target, constraint
|
|
72978
|
-
const cacheKey = source.id + "," + target.id + "," + constraint.id
|
|
72962
|
+
function inferReverseMappedType(source, target, constraint) {
|
|
72963
|
+
const cacheKey = source.id + "," + target.id + "," + constraint.id;
|
|
72979
72964
|
if (reverseMappedCache.has(cacheKey)) {
|
|
72980
72965
|
return reverseMappedCache.get(cacheKey) || unknownType;
|
|
72981
72966
|
}
|
|
@@ -72986,7 +72971,7 @@ function createTypeChecker(host) {
|
|
|
72986
72971
|
if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2)) reverseExpandingFlags |= 2 /* Target */;
|
|
72987
72972
|
let type;
|
|
72988
72973
|
if (reverseExpandingFlags !== 3 /* Both */) {
|
|
72989
|
-
type = inferReverseMappedTypeWorker(source, target, constraint
|
|
72974
|
+
type = inferReverseMappedTypeWorker(source, target, constraint);
|
|
72990
72975
|
}
|
|
72991
72976
|
reverseMappedSourceStack.pop();
|
|
72992
72977
|
reverseMappedTargetStack.pop();
|
|
@@ -73313,6 +73298,29 @@ function createTypeChecker(host) {
|
|
|
73313
73298
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
73314
73299
|
inferFromTypes(source.objectType, target.objectType);
|
|
73315
73300
|
inferFromTypes(source.indexType, target.indexType);
|
|
73301
|
+
} else if (!(priority & 1 /* NakedTypeVariable */) && target.flags & 8388608 /* IndexedAccess */) {
|
|
73302
|
+
if (isFromInferenceBlockedSource(source)) {
|
|
73303
|
+
return;
|
|
73304
|
+
}
|
|
73305
|
+
const inference = getInferenceInfoForType(getActualTypeVariable(target.objectType));
|
|
73306
|
+
if (inference) {
|
|
73307
|
+
if (getObjectFlags(source) & 262144 /* NonInferrableType */ || source === nonInferrableAnyType) {
|
|
73308
|
+
return;
|
|
73309
|
+
}
|
|
73310
|
+
if (!inference.isFixed) {
|
|
73311
|
+
const partialInferenceTypeSymbol = getGlobalPartialInferenceSymbol();
|
|
73312
|
+
if (partialInferenceTypeSymbol) {
|
|
73313
|
+
if (target.indexType.flags & 465829888 /* Instantiable */) {
|
|
73314
|
+
const recordSymbol = getGlobalRecordSymbol();
|
|
73315
|
+
if (recordSymbol) {
|
|
73316
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(recordSymbol, [target.indexType, source]));
|
|
73317
|
+
}
|
|
73318
|
+
} else {
|
|
73319
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(partialInferenceTypeSymbol, [source, target.indexType]));
|
|
73320
|
+
}
|
|
73321
|
+
}
|
|
73322
|
+
}
|
|
73323
|
+
}
|
|
73316
73324
|
} else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) {
|
|
73317
73325
|
if (source.symbol === target.symbol) {
|
|
73318
73326
|
inferFromTypes(source.type, target.type);
|
|
@@ -73506,7 +73514,7 @@ function createTypeChecker(host) {
|
|
|
73506
73514
|
}
|
|
73507
73515
|
}
|
|
73508
73516
|
function inferToMappedType(source, target, constraintType) {
|
|
73509
|
-
if (constraintType.flags &
|
|
73517
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
73510
73518
|
let result = false;
|
|
73511
73519
|
for (const type of constraintType.types) {
|
|
73512
73520
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -73816,6 +73824,52 @@ function createTypeChecker(host) {
|
|
|
73816
73824
|
const preferCovariantType = inferredCovariantType && (!inferredContravariantType || !(inferredCovariantType.flags & (131072 /* Never */ | 1 /* Any */)) && some(inference.contraCandidates, (t) => isTypeAssignableTo(inferredCovariantType, t)) && every(context.inferences, (other) => other !== inference && getConstraintOfTypeParameter(other.typeParameter) !== inference.typeParameter || every(other.candidates, (t) => isTypeAssignableTo(t, inferredCovariantType))));
|
|
73817
73825
|
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
73818
73826
|
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
73827
|
+
} else if (inference.indexes) {
|
|
73828
|
+
const eraseSelfMapper = makeUnaryTypeMapper(inference.typeParameter, allKeysUnknownType);
|
|
73829
|
+
let aggregateInference = instantiateType(getIntersectionType(inference.indexes), mergeTypeMappers(eraseSelfMapper, context.nonFixingMapper));
|
|
73830
|
+
const constraint2 = getConstraintOfTypeParameter(inference.typeParameter);
|
|
73831
|
+
if (constraint2) {
|
|
73832
|
+
const instantiatedConstraint = instantiateType(constraint2, context.nonFixingMapper);
|
|
73833
|
+
if (instantiatedConstraint.flags & 1048576 /* Union */ && !context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference))) {
|
|
73834
|
+
const discriminantProps = findDiscriminantProperties(getPropertiesOfType(aggregateInference), instantiatedConstraint);
|
|
73835
|
+
if (discriminantProps) {
|
|
73836
|
+
let match;
|
|
73837
|
+
findDiscriminant:
|
|
73838
|
+
for (const p of discriminantProps) {
|
|
73839
|
+
const candidatePropType = getTypeOfPropertyOfType(aggregateInference, p.escapedName);
|
|
73840
|
+
for (const type of instantiatedConstraint.types) {
|
|
73841
|
+
const propType = getTypeOfPropertyOfType(type, p.escapedName);
|
|
73842
|
+
if (propType && candidatePropType && checkTypeAssignableTo(
|
|
73843
|
+
candidatePropType,
|
|
73844
|
+
propType,
|
|
73845
|
+
/*errorNode*/
|
|
73846
|
+
void 0
|
|
73847
|
+
)) {
|
|
73848
|
+
if (match && match !== type) {
|
|
73849
|
+
match = void 0;
|
|
73850
|
+
break findDiscriminant;
|
|
73851
|
+
} else {
|
|
73852
|
+
match = type;
|
|
73853
|
+
}
|
|
73854
|
+
}
|
|
73855
|
+
}
|
|
73856
|
+
}
|
|
73857
|
+
if (match) {
|
|
73858
|
+
aggregateInference = getSpreadType(
|
|
73859
|
+
match,
|
|
73860
|
+
aggregateInference,
|
|
73861
|
+
/*symbol*/
|
|
73862
|
+
void 0,
|
|
73863
|
+
/*propegatedFlags*/
|
|
73864
|
+
0,
|
|
73865
|
+
/*readonly*/
|
|
73866
|
+
false
|
|
73867
|
+
);
|
|
73868
|
+
}
|
|
73869
|
+
}
|
|
73870
|
+
}
|
|
73871
|
+
}
|
|
73872
|
+
inferredType = aggregateInference;
|
|
73819
73873
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
73820
73874
|
inferredType = silentNeverType;
|
|
73821
73875
|
} else {
|
|
@@ -78670,25 +78724,17 @@ function createTypeChecker(host) {
|
|
|
78670
78724
|
checkComputedPropertyName(elem.name);
|
|
78671
78725
|
}
|
|
78672
78726
|
}
|
|
78673
|
-
const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
|
|
78674
78727
|
let offset = 0;
|
|
78675
78728
|
for (const memberDecl of node.properties) {
|
|
78676
78729
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
78677
78730
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
78678
78731
|
if (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 305 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
78679
|
-
const isIntraExpressionInferenceSource = intraExpressionInferenceContext && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl);
|
|
78680
|
-
if (isIntraExpressionInferenceSource) {
|
|
78681
|
-
pushReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext, node);
|
|
78682
|
-
}
|
|
78683
78732
|
let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
78684
78733
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
78685
78734
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
78686
78735
|
// we don't want to say "could not find 'a'".
|
|
78687
78736
|
memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
78688
78737
|
);
|
|
78689
|
-
if (isIntraExpressionInferenceSource) {
|
|
78690
|
-
popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
|
|
78691
|
-
}
|
|
78692
78738
|
if (isInJavascript) {
|
|
78693
78739
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
78694
78740
|
if (jsDocType) {
|
|
@@ -78723,9 +78769,11 @@ function createTypeChecker(host) {
|
|
|
78723
78769
|
prop.links.target = member;
|
|
78724
78770
|
member = prop;
|
|
78725
78771
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
78726
|
-
if (
|
|
78772
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
78773
|
+
const inferenceContext = getInferenceContext(node);
|
|
78774
|
+
Debug.assert(inferenceContext);
|
|
78727
78775
|
const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
78728
|
-
addIntraExpressionInferenceSite(
|
|
78776
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
78729
78777
|
}
|
|
78730
78778
|
} else if (memberDecl.kind === 306 /* SpreadAssignment */) {
|
|
78731
78779
|
if (languageVersion < LanguageFeatureMinimumTarget.ObjectAssign) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typescript-deploys/pr-build",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "6.0.0-pr-
|
|
5
|
+
"version": "6.0.0-pr-53017-28",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|