@typescript-deploys/pr-build 6.0.0-pr-54029-2 → 6.0.0-pr-53017-35
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 +174 -112
- package/lib/lib.es5.d.ts +9 -0
- package/lib/typescript.js +174 -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.20251202`;
|
|
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,31 @@ 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
|
-
|
|
68331
|
-
|
|
68332
|
-
|
|
68333
|
-
|
|
68334
|
-
|
|
68335
|
-
|
|
68336
|
-
pushContextualType(
|
|
68337
|
-
scopeNode,
|
|
68338
|
-
getTypeAliasInstantiation(recordSymbol, [stringNumberSymbolType, templateType]),
|
|
68339
|
-
/*isCache*/
|
|
68340
|
-
false
|
|
68341
|
-
);
|
|
68342
|
-
inferFromIntraExpressionSites([inference], intraExpressionSites);
|
|
68343
|
-
popContextualType();
|
|
68344
|
-
}
|
|
68324
|
+
const inferredType = getTypeFromInference(inference);
|
|
68325
|
+
if (inferredType) {
|
|
68326
|
+
return inferredType;
|
|
68327
|
+
}
|
|
68328
|
+
if (inference.indexes) {
|
|
68329
|
+
const eraseSelfMapper = makeArrayTypeMapper([constraint.type, typeParameter], [allKeysAllKeysUnknownType, stringNumberSymbolType]);
|
|
68330
|
+
const aggregateInference = instantiateType(getIntersectionType(inference.indexes), eraseSelfMapper);
|
|
68331
|
+
if (!(getReducedType(aggregateInference).flags & 131072 /* Never */)) {
|
|
68332
|
+
return aggregateInference;
|
|
68345
68333
|
}
|
|
68346
68334
|
}
|
|
68347
|
-
return
|
|
68335
|
+
return unknownType;
|
|
68348
68336
|
}
|
|
68349
|
-
function inferReverseMappedType(source, target, constraint
|
|
68350
|
-
const cacheKey = source.id + "," + target.id + "," + constraint.id
|
|
68337
|
+
function inferReverseMappedType(source, target, constraint) {
|
|
68338
|
+
const cacheKey = source.id + "," + target.id + "," + constraint.id;
|
|
68351
68339
|
if (reverseMappedCache.has(cacheKey)) {
|
|
68352
68340
|
return reverseMappedCache.get(cacheKey) || unknownType;
|
|
68353
68341
|
}
|
|
@@ -68358,7 +68346,7 @@ function createTypeChecker(host) {
|
|
|
68358
68346
|
if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2)) reverseExpandingFlags |= 2 /* Target */;
|
|
68359
68347
|
let type;
|
|
68360
68348
|
if (reverseExpandingFlags !== 3 /* Both */) {
|
|
68361
|
-
type = inferReverseMappedTypeWorker(source, target, constraint
|
|
68349
|
+
type = inferReverseMappedTypeWorker(source, target, constraint);
|
|
68362
68350
|
}
|
|
68363
68351
|
reverseMappedSourceStack.pop();
|
|
68364
68352
|
reverseMappedTargetStack.pop();
|
|
@@ -68685,6 +68673,29 @@ function createTypeChecker(host) {
|
|
|
68685
68673
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
68686
68674
|
inferFromTypes(source.objectType, target.objectType);
|
|
68687
68675
|
inferFromTypes(source.indexType, target.indexType);
|
|
68676
|
+
} else if (!(priority & 1 /* NakedTypeVariable */) && target.flags & 8388608 /* IndexedAccess */) {
|
|
68677
|
+
if (isFromInferenceBlockedSource(source)) {
|
|
68678
|
+
return;
|
|
68679
|
+
}
|
|
68680
|
+
const inference = getInferenceInfoForType(getActualTypeVariable(target.objectType));
|
|
68681
|
+
if (inference) {
|
|
68682
|
+
if (getObjectFlags(source) & 262144 /* NonInferrableType */ || source === nonInferrableAnyType) {
|
|
68683
|
+
return;
|
|
68684
|
+
}
|
|
68685
|
+
if (!hasInferenceCandidates(inference)) {
|
|
68686
|
+
const partialInferenceTypeSymbol = getGlobalPartialInferenceSymbol();
|
|
68687
|
+
if (partialInferenceTypeSymbol) {
|
|
68688
|
+
if (target.indexType.flags & 465829888 /* Instantiable */) {
|
|
68689
|
+
const recordSymbol = getGlobalRecordSymbol();
|
|
68690
|
+
if (recordSymbol) {
|
|
68691
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(recordSymbol, [target.indexType, source]));
|
|
68692
|
+
}
|
|
68693
|
+
} else {
|
|
68694
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(partialInferenceTypeSymbol, [source, target.indexType]));
|
|
68695
|
+
}
|
|
68696
|
+
}
|
|
68697
|
+
}
|
|
68698
|
+
}
|
|
68688
68699
|
} else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) {
|
|
68689
68700
|
if (source.symbol === target.symbol) {
|
|
68690
68701
|
inferFromTypes(source.type, target.type);
|
|
@@ -68878,7 +68889,7 @@ function createTypeChecker(host) {
|
|
|
68878
68889
|
}
|
|
68879
68890
|
}
|
|
68880
68891
|
function inferToMappedType(source, target, constraintType) {
|
|
68881
|
-
if (constraintType.flags &
|
|
68892
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
68882
68893
|
let result = false;
|
|
68883
68894
|
for (const type of constraintType.types) {
|
|
68884
68895
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -69188,9 +69199,66 @@ function createTypeChecker(host) {
|
|
|
69188
69199
|
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
69200
|
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
69190
69201
|
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
69202
|
+
} else if (inference.indexes) {
|
|
69203
|
+
const eraseSelfMapper = makeUnaryTypeMapper(inference.typeParameter, allKeysUnknownType);
|
|
69204
|
+
let aggregateInference = instantiateType(getIntersectionType(inference.indexes), mergeTypeMappers(eraseSelfMapper, context.nonFixingMapper));
|
|
69205
|
+
if (getReducedType(aggregateInference).flags & 131072 /* Never */) {
|
|
69206
|
+
aggregateInference = void 0;
|
|
69207
|
+
}
|
|
69208
|
+
const constraint2 = getConstraintOfTypeParameter(inference.typeParameter);
|
|
69209
|
+
if (aggregateInference && constraint2) {
|
|
69210
|
+
const instantiatedConstraint = instantiateType(constraint2, context.nonFixingMapper);
|
|
69211
|
+
let assignableToConstraint = context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference));
|
|
69212
|
+
if (!assignableToConstraint) {
|
|
69213
|
+
if (instantiatedConstraint.flags & 1048576 /* Union */) {
|
|
69214
|
+
const discriminantProps = findDiscriminantProperties(getPropertiesOfType(aggregateInference), instantiatedConstraint);
|
|
69215
|
+
if (discriminantProps) {
|
|
69216
|
+
let match;
|
|
69217
|
+
findDiscriminant:
|
|
69218
|
+
for (const p of discriminantProps) {
|
|
69219
|
+
const candidatePropType = getTypeOfPropertyOfType(aggregateInference, p.escapedName);
|
|
69220
|
+
for (const type of instantiatedConstraint.types) {
|
|
69221
|
+
const propType = getTypeOfPropertyOfType(type, p.escapedName);
|
|
69222
|
+
if (propType && candidatePropType && checkTypeAssignableTo(
|
|
69223
|
+
candidatePropType,
|
|
69224
|
+
propType,
|
|
69225
|
+
/*errorNode*/
|
|
69226
|
+
void 0
|
|
69227
|
+
)) {
|
|
69228
|
+
if (match && match !== type) {
|
|
69229
|
+
match = void 0;
|
|
69230
|
+
break findDiscriminant;
|
|
69231
|
+
} else {
|
|
69232
|
+
match = type;
|
|
69233
|
+
}
|
|
69234
|
+
}
|
|
69235
|
+
}
|
|
69236
|
+
}
|
|
69237
|
+
if (match) {
|
|
69238
|
+
aggregateInference = getSpreadType(
|
|
69239
|
+
match,
|
|
69240
|
+
aggregateInference,
|
|
69241
|
+
/*symbol*/
|
|
69242
|
+
void 0,
|
|
69243
|
+
/*propegatedFlags*/
|
|
69244
|
+
0,
|
|
69245
|
+
/*readonly*/
|
|
69246
|
+
false
|
|
69247
|
+
);
|
|
69248
|
+
assignableToConstraint = context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference));
|
|
69249
|
+
}
|
|
69250
|
+
}
|
|
69251
|
+
}
|
|
69252
|
+
if (!assignableToConstraint) {
|
|
69253
|
+
aggregateInference = void 0;
|
|
69254
|
+
}
|
|
69255
|
+
}
|
|
69256
|
+
}
|
|
69257
|
+
inferredType = aggregateInference;
|
|
69191
69258
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
69192
69259
|
inferredType = silentNeverType;
|
|
69193
|
-
}
|
|
69260
|
+
}
|
|
69261
|
+
if (!inferredType) {
|
|
69194
69262
|
const defaultType = getDefaultFromTypeParameter(inference.typeParameter);
|
|
69195
69263
|
if (defaultType) {
|
|
69196
69264
|
inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
|
|
@@ -74042,25 +74110,17 @@ function createTypeChecker(host) {
|
|
|
74042
74110
|
checkComputedPropertyName(elem.name);
|
|
74043
74111
|
}
|
|
74044
74112
|
}
|
|
74045
|
-
const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
|
|
74046
74113
|
let offset = 0;
|
|
74047
74114
|
for (const memberDecl of node.properties) {
|
|
74048
74115
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
74049
74116
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
74050
74117
|
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
74118
|
let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
74056
74119
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
74057
74120
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
74058
74121
|
// we don't want to say "could not find 'a'".
|
|
74059
74122
|
memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
74060
74123
|
);
|
|
74061
|
-
if (isIntraExpressionInferenceSource) {
|
|
74062
|
-
popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
|
|
74063
|
-
}
|
|
74064
74124
|
if (isInJavascript) {
|
|
74065
74125
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
74066
74126
|
if (jsDocType) {
|
|
@@ -74095,9 +74155,11 @@ function createTypeChecker(host) {
|
|
|
74095
74155
|
prop.links.target = member;
|
|
74096
74156
|
member = prop;
|
|
74097
74157
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
74098
|
-
if (
|
|
74158
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
74159
|
+
const inferenceContext = getInferenceContext(node);
|
|
74160
|
+
Debug.assert(inferenceContext);
|
|
74099
74161
|
const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
74100
|
-
addIntraExpressionInferenceSite(
|
|
74162
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
74101
74163
|
}
|
|
74102
74164
|
} else if (memberDecl.kind === 306 /* SpreadAssignment */) {
|
|
74103
74165
|
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.20251202`;
|
|
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,31 @@ 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
|
-
|
|
72959
|
-
|
|
72960
|
-
|
|
72961
|
-
|
|
72962
|
-
|
|
72963
|
-
|
|
72964
|
-
pushContextualType(
|
|
72965
|
-
scopeNode,
|
|
72966
|
-
getTypeAliasInstantiation(recordSymbol, [stringNumberSymbolType, templateType]),
|
|
72967
|
-
/*isCache*/
|
|
72968
|
-
false
|
|
72969
|
-
);
|
|
72970
|
-
inferFromIntraExpressionSites([inference], intraExpressionSites);
|
|
72971
|
-
popContextualType();
|
|
72972
|
-
}
|
|
72952
|
+
const inferredType = getTypeFromInference(inference);
|
|
72953
|
+
if (inferredType) {
|
|
72954
|
+
return inferredType;
|
|
72955
|
+
}
|
|
72956
|
+
if (inference.indexes) {
|
|
72957
|
+
const eraseSelfMapper = makeArrayTypeMapper([constraint.type, typeParameter], [allKeysAllKeysUnknownType, stringNumberSymbolType]);
|
|
72958
|
+
const aggregateInference = instantiateType(getIntersectionType(inference.indexes), eraseSelfMapper);
|
|
72959
|
+
if (!(getReducedType(aggregateInference).flags & 131072 /* Never */)) {
|
|
72960
|
+
return aggregateInference;
|
|
72973
72961
|
}
|
|
72974
72962
|
}
|
|
72975
|
-
return
|
|
72963
|
+
return unknownType;
|
|
72976
72964
|
}
|
|
72977
|
-
function inferReverseMappedType(source, target, constraint
|
|
72978
|
-
const cacheKey = source.id + "," + target.id + "," + constraint.id
|
|
72965
|
+
function inferReverseMappedType(source, target, constraint) {
|
|
72966
|
+
const cacheKey = source.id + "," + target.id + "," + constraint.id;
|
|
72979
72967
|
if (reverseMappedCache.has(cacheKey)) {
|
|
72980
72968
|
return reverseMappedCache.get(cacheKey) || unknownType;
|
|
72981
72969
|
}
|
|
@@ -72986,7 +72974,7 @@ function createTypeChecker(host) {
|
|
|
72986
72974
|
if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2)) reverseExpandingFlags |= 2 /* Target */;
|
|
72987
72975
|
let type;
|
|
72988
72976
|
if (reverseExpandingFlags !== 3 /* Both */) {
|
|
72989
|
-
type = inferReverseMappedTypeWorker(source, target, constraint
|
|
72977
|
+
type = inferReverseMappedTypeWorker(source, target, constraint);
|
|
72990
72978
|
}
|
|
72991
72979
|
reverseMappedSourceStack.pop();
|
|
72992
72980
|
reverseMappedTargetStack.pop();
|
|
@@ -73313,6 +73301,29 @@ function createTypeChecker(host) {
|
|
|
73313
73301
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
73314
73302
|
inferFromTypes(source.objectType, target.objectType);
|
|
73315
73303
|
inferFromTypes(source.indexType, target.indexType);
|
|
73304
|
+
} else if (!(priority & 1 /* NakedTypeVariable */) && target.flags & 8388608 /* IndexedAccess */) {
|
|
73305
|
+
if (isFromInferenceBlockedSource(source)) {
|
|
73306
|
+
return;
|
|
73307
|
+
}
|
|
73308
|
+
const inference = getInferenceInfoForType(getActualTypeVariable(target.objectType));
|
|
73309
|
+
if (inference) {
|
|
73310
|
+
if (getObjectFlags(source) & 262144 /* NonInferrableType */ || source === nonInferrableAnyType) {
|
|
73311
|
+
return;
|
|
73312
|
+
}
|
|
73313
|
+
if (!hasInferenceCandidates(inference)) {
|
|
73314
|
+
const partialInferenceTypeSymbol = getGlobalPartialInferenceSymbol();
|
|
73315
|
+
if (partialInferenceTypeSymbol) {
|
|
73316
|
+
if (target.indexType.flags & 465829888 /* Instantiable */) {
|
|
73317
|
+
const recordSymbol = getGlobalRecordSymbol();
|
|
73318
|
+
if (recordSymbol) {
|
|
73319
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(recordSymbol, [target.indexType, source]));
|
|
73320
|
+
}
|
|
73321
|
+
} else {
|
|
73322
|
+
inference.indexes = append(inference.indexes, getTypeAliasInstantiation(partialInferenceTypeSymbol, [source, target.indexType]));
|
|
73323
|
+
}
|
|
73324
|
+
}
|
|
73325
|
+
}
|
|
73326
|
+
}
|
|
73316
73327
|
} else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) {
|
|
73317
73328
|
if (source.symbol === target.symbol) {
|
|
73318
73329
|
inferFromTypes(source.type, target.type);
|
|
@@ -73506,7 +73517,7 @@ function createTypeChecker(host) {
|
|
|
73506
73517
|
}
|
|
73507
73518
|
}
|
|
73508
73519
|
function inferToMappedType(source, target, constraintType) {
|
|
73509
|
-
if (constraintType.flags &
|
|
73520
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
73510
73521
|
let result = false;
|
|
73511
73522
|
for (const type of constraintType.types) {
|
|
73512
73523
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -73816,9 +73827,66 @@ function createTypeChecker(host) {
|
|
|
73816
73827
|
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
73828
|
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
73818
73829
|
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
73830
|
+
} else if (inference.indexes) {
|
|
73831
|
+
const eraseSelfMapper = makeUnaryTypeMapper(inference.typeParameter, allKeysUnknownType);
|
|
73832
|
+
let aggregateInference = instantiateType(getIntersectionType(inference.indexes), mergeTypeMappers(eraseSelfMapper, context.nonFixingMapper));
|
|
73833
|
+
if (getReducedType(aggregateInference).flags & 131072 /* Never */) {
|
|
73834
|
+
aggregateInference = void 0;
|
|
73835
|
+
}
|
|
73836
|
+
const constraint2 = getConstraintOfTypeParameter(inference.typeParameter);
|
|
73837
|
+
if (aggregateInference && constraint2) {
|
|
73838
|
+
const instantiatedConstraint = instantiateType(constraint2, context.nonFixingMapper);
|
|
73839
|
+
let assignableToConstraint = context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference));
|
|
73840
|
+
if (!assignableToConstraint) {
|
|
73841
|
+
if (instantiatedConstraint.flags & 1048576 /* Union */) {
|
|
73842
|
+
const discriminantProps = findDiscriminantProperties(getPropertiesOfType(aggregateInference), instantiatedConstraint);
|
|
73843
|
+
if (discriminantProps) {
|
|
73844
|
+
let match;
|
|
73845
|
+
findDiscriminant:
|
|
73846
|
+
for (const p of discriminantProps) {
|
|
73847
|
+
const candidatePropType = getTypeOfPropertyOfType(aggregateInference, p.escapedName);
|
|
73848
|
+
for (const type of instantiatedConstraint.types) {
|
|
73849
|
+
const propType = getTypeOfPropertyOfType(type, p.escapedName);
|
|
73850
|
+
if (propType && candidatePropType && checkTypeAssignableTo(
|
|
73851
|
+
candidatePropType,
|
|
73852
|
+
propType,
|
|
73853
|
+
/*errorNode*/
|
|
73854
|
+
void 0
|
|
73855
|
+
)) {
|
|
73856
|
+
if (match && match !== type) {
|
|
73857
|
+
match = void 0;
|
|
73858
|
+
break findDiscriminant;
|
|
73859
|
+
} else {
|
|
73860
|
+
match = type;
|
|
73861
|
+
}
|
|
73862
|
+
}
|
|
73863
|
+
}
|
|
73864
|
+
}
|
|
73865
|
+
if (match) {
|
|
73866
|
+
aggregateInference = getSpreadType(
|
|
73867
|
+
match,
|
|
73868
|
+
aggregateInference,
|
|
73869
|
+
/*symbol*/
|
|
73870
|
+
void 0,
|
|
73871
|
+
/*propegatedFlags*/
|
|
73872
|
+
0,
|
|
73873
|
+
/*readonly*/
|
|
73874
|
+
false
|
|
73875
|
+
);
|
|
73876
|
+
assignableToConstraint = context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference));
|
|
73877
|
+
}
|
|
73878
|
+
}
|
|
73879
|
+
}
|
|
73880
|
+
if (!assignableToConstraint) {
|
|
73881
|
+
aggregateInference = void 0;
|
|
73882
|
+
}
|
|
73883
|
+
}
|
|
73884
|
+
}
|
|
73885
|
+
inferredType = aggregateInference;
|
|
73819
73886
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
73820
73887
|
inferredType = silentNeverType;
|
|
73821
|
-
}
|
|
73888
|
+
}
|
|
73889
|
+
if (!inferredType) {
|
|
73822
73890
|
const defaultType = getDefaultFromTypeParameter(inference.typeParameter);
|
|
73823
73891
|
if (defaultType) {
|
|
73824
73892
|
inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
|
|
@@ -78670,25 +78738,17 @@ function createTypeChecker(host) {
|
|
|
78670
78738
|
checkComputedPropertyName(elem.name);
|
|
78671
78739
|
}
|
|
78672
78740
|
}
|
|
78673
|
-
const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
|
|
78674
78741
|
let offset = 0;
|
|
78675
78742
|
for (const memberDecl of node.properties) {
|
|
78676
78743
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
78677
78744
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
78678
78745
|
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
78746
|
let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
78684
78747
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
78685
78748
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
78686
78749
|
// we don't want to say "could not find 'a'".
|
|
78687
78750
|
memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
78688
78751
|
);
|
|
78689
|
-
if (isIntraExpressionInferenceSource) {
|
|
78690
|
-
popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
|
|
78691
|
-
}
|
|
78692
78752
|
if (isInJavascript) {
|
|
78693
78753
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
78694
78754
|
if (jsDocType) {
|
|
@@ -78723,9 +78783,11 @@ function createTypeChecker(host) {
|
|
|
78723
78783
|
prop.links.target = member;
|
|
78724
78784
|
member = prop;
|
|
78725
78785
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
78726
|
-
if (
|
|
78786
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
78787
|
+
const inferenceContext = getInferenceContext(node);
|
|
78788
|
+
Debug.assert(inferenceContext);
|
|
78727
78789
|
const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
78728
|
-
addIntraExpressionInferenceSite(
|
|
78790
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
78729
78791
|
}
|
|
78730
78792
|
} else if (memberDecl.kind === 306 /* SpreadAssignment */) {
|
|
78731
78793
|
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-35",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|