@typescript-deploys/pr-build 6.0.0-pr-56300-12 → 6.0.0-pr-54029-2

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 CHANGED
@@ -17397,15 +17397,16 @@ function getCheckFlags(symbol) {
17397
17397
  return symbol.flags & 33554432 /* Transient */ ? symbol.links.checkFlags : 0;
17398
17398
  }
17399
17399
  function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) {
17400
- if (s.valueDeclaration) {
17400
+ const checkFlags = getCheckFlags(s);
17401
+ if (!(checkFlags & 8192 /* ReverseMapped */) && s.valueDeclaration) {
17401
17402
  const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration;
17402
17403
  const flags = getCombinedModifierFlags(declaration);
17403
17404
  return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */;
17404
17405
  }
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;
17406
+ if (checkFlags & 6 /* Synthetic */) {
17407
+ const checkFlags2 = s.links.checkFlags;
17408
+ const accessModifier = checkFlags2 & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags2 & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */;
17409
+ const staticModifier = checkFlags2 & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0;
17409
17410
  return accessModifier | staticModifier;
17410
17411
  }
17411
17412
  if (s.flags & 4194304 /* Prototype */) {
@@ -58284,7 +58285,13 @@ function createTypeChecker(host) {
58284
58285
  const modifiers = getMappedTypeModifiers(type.mappedType);
58285
58286
  const readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true;
58286
58287
  const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
58287
- const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType, type.inferenceConstraintType && getIndexedAccessTypeOrUndefined(type.inferenceConstraintType, indexInfo.keyType)) ?? unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
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;
58288
58295
  const members = createSymbolTable();
58289
58296
  const limitedConstraint = getLimitedConstraint(type);
58290
58297
  for (const prop of getPropertiesOfType(type.source)) {
@@ -58297,6 +58304,7 @@ function createTypeChecker(host) {
58297
58304
  const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
58298
58305
  const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
58299
58306
  inferredProp.declarations = prop.declarations;
58307
+ inferredProp.valueDeclaration = prop.valueDeclaration;
58300
58308
  inferredProp.links.nameType = getSymbolLinks(prop).nameType;
58301
58309
  inferredProp.links.propertyType = getTypeOfSymbol(prop);
58302
58310
  if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) {
@@ -58308,7 +58316,6 @@ function createTypeChecker(host) {
58308
58316
  inferredProp.links.mappedType = type.mappedType;
58309
58317
  inferredProp.links.constraintType = type.constraintType;
58310
58318
  }
58311
- inferredProp.links.inferenceConstraintType = type.inferenceConstraintType;
58312
58319
  members.set(prop.escapedName, inferredProp);
58313
58320
  }
58314
58321
  setStructuredTypeMembers(type, members, emptyArray, emptyArray, indexInfos);
@@ -68108,7 +68115,10 @@ function createTypeChecker(host) {
68108
68115
  map(context.inferences, (i) => i.typeParameter),
68109
68116
  map(context.inferences, (inference, i) => () => {
68110
68117
  if (!inference.isFixed) {
68111
- inferFromIntraExpressionSites(context);
68118
+ if (context.intraExpressionInferenceSites) {
68119
+ inferFromIntraExpressionSites(context.inferences, context.intraExpressionInferenceSites);
68120
+ context.intraExpressionInferenceSites = void 0;
68121
+ }
68112
68122
  clearCachedInferences(context.inferences);
68113
68123
  inference.isFixed = true;
68114
68124
  }
@@ -68132,17 +68142,38 @@ function createTypeChecker(host) {
68132
68142
  }
68133
68143
  }
68134
68144
  function addIntraExpressionInferenceSite(context, node, type) {
68135
- (context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push({ node, type });
68145
+ const site = { node, type };
68146
+ (context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push(site);
68147
+ if (context.reverseMappedIntraExpressionInferenceSites) {
68148
+ for (const reverseMappedSites of context.reverseMappedIntraExpressionInferenceSites) {
68149
+ reverseMappedSites.push(site);
68150
+ }
68151
+ }
68136
68152
  }
68137
- function inferFromIntraExpressionSites(context) {
68138
- if (context.intraExpressionInferenceSites) {
68139
- for (const { node, type } of context.intraExpressionInferenceSites) {
68140
- const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType(node, 2 /* NoConstraints */);
68141
- if (contextualType) {
68142
- inferTypes(context.inferences, type, contextualType);
68153
+ function pushReverseMappedTypeIntraExpressionInferenceScope(context, node) {
68154
+ (context.reverseMappedIntraExpressionInferenceScopeNodes ?? (context.reverseMappedIntraExpressionInferenceScopeNodes = [])).push(node);
68155
+ (context.reverseMappedIntraExpressionInferenceSites ?? (context.reverseMappedIntraExpressionInferenceSites = [])).push([]);
68156
+ }
68157
+ function popReverseMappedTypeIntraExpressionInferenceScope(context) {
68158
+ context.reverseMappedIntraExpressionInferenceScopeNodes.pop();
68159
+ context.reverseMappedIntraExpressionInferenceSites.pop();
68160
+ }
68161
+ function findReverseMappedTypeIntraExpressionInferenceScope(context, node) {
68162
+ if (context == null ? void 0 : context.reverseMappedIntraExpressionInferenceScopeNodes) {
68163
+ for (let i = context.reverseMappedIntraExpressionInferenceScopeNodes.length - 1; i >= 0; i--) {
68164
+ if (context.reverseMappedIntraExpressionInferenceScopeNodes[i] === node) {
68165
+ return i;
68143
68166
  }
68144
68167
  }
68145
- context.intraExpressionInferenceSites = void 0;
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
+ }
68146
68177
  }
68147
68178
  }
68148
68179
  function createInferenceInfo(typeParameter) {
@@ -68240,22 +68271,31 @@ function createTypeChecker(host) {
68240
68271
  reverseHomomorphicMappedCache.set(cacheKey, type);
68241
68272
  return type;
68242
68273
  }
68243
- function isPartiallyInferableType(type) {
68244
- return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
68245
- }
68246
68274
  function createReverseMappedType(source, target, constraint) {
68247
- if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
68275
+ if (!getIndexInfoOfType(source, stringType) && !getPropertiesOfType(source).length) {
68248
68276
  return void 0;
68249
68277
  }
68250
68278
  if (isArrayType(source)) {
68251
- const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint);
68279
+ const elementType = inferReverseMappedType(
68280
+ getTypeArguments(source)[0],
68281
+ target,
68282
+ constraint,
68283
+ /*sourceValueDeclaration*/
68284
+ void 0
68285
+ );
68252
68286
  if (!elementType) {
68253
68287
  return void 0;
68254
68288
  }
68255
68289
  return createArrayType(elementType, isReadonlyArrayType(source));
68256
68290
  }
68257
68291
  if (isTupleType(source)) {
68258
- const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
68292
+ const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(
68293
+ t,
68294
+ target,
68295
+ constraint,
68296
+ /*sourceValueDeclaration*/
68297
+ void 0
68298
+ ));
68259
68299
  if (!every(elementTypes, (t) => !!t)) {
68260
68300
  return void 0;
68261
68301
  }
@@ -68275,20 +68315,39 @@ function createTypeChecker(host) {
68275
68315
  function getTypeOfReverseMappedSymbol(symbol) {
68276
68316
  const links = getSymbolLinks(symbol);
68277
68317
  if (!links.type) {
68278
- const reverseConstraint = symbol.links.inferenceConstraintType && getIndexedAccessTypeOrUndefined(symbol.links.inferenceConstraintType, getStringLiteralType(unescapeLeadingUnderscores(symbol.escapedName)));
68279
- links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType, reverseConstraint) ?? unknownType;
68318
+ links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType, symbol.valueDeclaration) || unknownType;
68280
68319
  }
68281
68320
  return links.type;
68282
68321
  }
68283
- function inferReverseMappedTypeWorker(sourceType, target, constraint, reverseMappedConstraint) {
68322
+ function inferReverseMappedTypeWorker(sourceType, target, constraint, sourceValueDeclaration) {
68284
68323
  const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
68285
68324
  const templateType = getTemplateTypeFromMappedType(target);
68286
68325
  const inference = createInferenceInfo(typeParameter);
68287
68326
  inferTypes([inference], sourceType, templateType);
68288
- return getTypeFromInference(inference) ?? reverseMappedConstraint ?? unknownType;
68327
+ if (sourceValueDeclaration && getObjectFlags(sourceType) & 262144 /* NonInferrableType */) {
68328
+ const scopeNode = sourceValueDeclaration.parent;
68329
+ const inferenceContext = getInferenceContext(scopeNode);
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
+ }
68346
+ }
68347
+ return getTypeFromInference(inference) || unknownType;
68289
68348
  }
68290
- function inferReverseMappedType(source, target, constraint, reverseMappedConstraint) {
68291
- const cacheKey = source.id + "," + target.id + "," + constraint.id + "," + ((reverseMappedConstraint == null ? void 0 : reverseMappedConstraint.id) ?? "0");
68349
+ function inferReverseMappedType(source, target, constraint, sourceValueDeclaration) {
68350
+ const cacheKey = source.id + "," + target.id + "," + constraint.id + (sourceValueDeclaration && getObjectFlags(source) & 262144 /* NonInferrableType */ ? "," + getNodeId(sourceValueDeclaration) : "");
68292
68351
  if (reverseMappedCache.has(cacheKey)) {
68293
68352
  return reverseMappedCache.get(cacheKey) || unknownType;
68294
68353
  }
@@ -68299,7 +68358,7 @@ function createTypeChecker(host) {
68299
68358
  if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2)) reverseExpandingFlags |= 2 /* Target */;
68300
68359
  let type;
68301
68360
  if (reverseExpandingFlags !== 3 /* Both */) {
68302
- type = inferReverseMappedTypeWorker(source, target, constraint, reverseMappedConstraint);
68361
+ type = inferReverseMappedTypeWorker(source, target, constraint, sourceValueDeclaration);
68303
68362
  }
68304
68363
  reverseMappedSourceStack.pop();
68305
68364
  reverseMappedTargetStack.pop();
@@ -68819,7 +68878,7 @@ function createTypeChecker(host) {
68819
68878
  }
68820
68879
  }
68821
68880
  function inferToMappedType(source, target, constraintType) {
68822
- if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
68881
+ if (constraintType.flags & 3145728 /* UnionOrIntersection */) {
68823
68882
  let result = false;
68824
68883
  for (const type of constraintType.types) {
68825
68884
  result = inferToMappedType(source, target, type) || result;
@@ -69144,39 +69203,13 @@ function createTypeChecker(host) {
69144
69203
  const constraint = getConstraintOfTypeParameter(inference.typeParameter);
69145
69204
  if (constraint) {
69146
69205
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
69147
- inferredType = cloneWithInferenceConstraintIfNeeded(inferredType, instantiatedConstraint);
69148
- if (inferredType) {
69149
- inference.inferredType = inferredType;
69150
- }
69151
69206
  if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
69152
- fallbackType = cloneWithInferenceConstraintIfNeeded(fallbackType, instantiatedConstraint);
69153
69207
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
69154
69208
  }
69155
69209
  }
69156
69210
  clearActiveMapperCaches();
69157
69211
  }
69158
69212
  return inference.inferredType;
69159
- function cloneWithInferenceConstraintIfNeeded(type, inferenceConstraintType) {
69160
- if (!type || !(type.flags & 524288 /* Object */) || !(type.objectFlags & 1024 /* ReverseMapped */)) {
69161
- return type;
69162
- }
69163
- const reversed = type;
69164
- const cacheKey = reversed.source.id + "," + reversed.mappedType.id + "," + reversed.constraintType.id + "," + inferenceConstraintType.id;
69165
- if (reverseHomomorphicMappedCache.has(cacheKey)) {
69166
- return reverseHomomorphicMappedCache.get(cacheKey);
69167
- }
69168
- const clone = createObjectType(
69169
- 1024 /* ReverseMapped */ | 16 /* Anonymous */,
69170
- /*symbol*/
69171
- void 0
69172
- );
69173
- clone.source = reversed.source;
69174
- clone.mappedType = reversed.mappedType;
69175
- clone.constraintType = reversed.constraintType;
69176
- clone.inferenceConstraintType = inferenceConstraintType;
69177
- reverseHomomorphicMappedCache.set(cacheKey, clone);
69178
- return clone;
69179
- }
69180
69213
  }
69181
69214
  function getDefaultTypeArgumentType(isInJavaScriptFile) {
69182
69215
  return isInJavaScriptFile ? anyType : unknownType;
@@ -74009,17 +74042,25 @@ function createTypeChecker(host) {
74009
74042
  checkComputedPropertyName(elem.name);
74010
74043
  }
74011
74044
  }
74045
+ const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
74012
74046
  let offset = 0;
74013
74047
  for (const memberDecl of node.properties) {
74014
74048
  let member = getSymbolOfDeclaration(memberDecl);
74015
74049
  const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
74016
74050
  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
+ }
74017
74055
  let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
74018
74056
  // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
74019
74057
  // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
74020
74058
  // we don't want to say "could not find 'a'".
74021
74059
  memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
74022
74060
  );
74061
+ if (isIntraExpressionInferenceSource) {
74062
+ popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
74063
+ }
74023
74064
  if (isInJavascript) {
74024
74065
  const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
74025
74066
  if (jsDocType) {
@@ -74054,11 +74095,9 @@ function createTypeChecker(host) {
74054
74095
  prop.links.target = member;
74055
74096
  member = prop;
74056
74097
  allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
74057
- if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
74058
- const inferenceContext = getInferenceContext(node);
74059
- Debug.assert(inferenceContext);
74098
+ if (isIntraExpressionInferenceSource) {
74060
74099
  const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
74061
- addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
74100
+ addIntraExpressionInferenceSite(intraExpressionInferenceContext, inferenceNode, type);
74062
74101
  }
74063
74102
  } else if (memberDecl.kind === 306 /* SpreadAssignment */) {
74064
74103
  if (languageVersion < LanguageFeatureMinimumTarget.ObjectAssign) {
package/lib/typescript.js CHANGED
@@ -21301,15 +21301,16 @@ function getCheckFlags(symbol) {
21301
21301
  return symbol.flags & 33554432 /* Transient */ ? symbol.links.checkFlags : 0;
21302
21302
  }
21303
21303
  function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) {
21304
- if (s.valueDeclaration) {
21304
+ const checkFlags = getCheckFlags(s);
21305
+ if (!(checkFlags & 8192 /* ReverseMapped */) && s.valueDeclaration) {
21305
21306
  const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration;
21306
21307
  const flags = getCombinedModifierFlags(declaration);
21307
21308
  return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */;
21308
21309
  }
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;
21310
+ if (checkFlags & 6 /* Synthetic */) {
21311
+ const checkFlags2 = s.links.checkFlags;
21312
+ const accessModifier = checkFlags2 & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags2 & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */;
21313
+ const staticModifier = checkFlags2 & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0;
21313
21314
  return accessModifier | staticModifier;
21314
21315
  }
21315
21316
  if (s.flags & 4194304 /* Prototype */) {
@@ -62912,7 +62913,13 @@ function createTypeChecker(host) {
62912
62913
  const modifiers = getMappedTypeModifiers(type.mappedType);
62913
62914
  const readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true;
62914
62915
  const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
62915
- const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType, type.inferenceConstraintType && getIndexedAccessTypeOrUndefined(type.inferenceConstraintType, indexInfo.keyType)) ?? unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
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;
62916
62923
  const members = createSymbolTable();
62917
62924
  const limitedConstraint = getLimitedConstraint(type);
62918
62925
  for (const prop of getPropertiesOfType(type.source)) {
@@ -62925,6 +62932,7 @@ function createTypeChecker(host) {
62925
62932
  const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
62926
62933
  const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
62927
62934
  inferredProp.declarations = prop.declarations;
62935
+ inferredProp.valueDeclaration = prop.valueDeclaration;
62928
62936
  inferredProp.links.nameType = getSymbolLinks(prop).nameType;
62929
62937
  inferredProp.links.propertyType = getTypeOfSymbol(prop);
62930
62938
  if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) {
@@ -62936,7 +62944,6 @@ function createTypeChecker(host) {
62936
62944
  inferredProp.links.mappedType = type.mappedType;
62937
62945
  inferredProp.links.constraintType = type.constraintType;
62938
62946
  }
62939
- inferredProp.links.inferenceConstraintType = type.inferenceConstraintType;
62940
62947
  members.set(prop.escapedName, inferredProp);
62941
62948
  }
62942
62949
  setStructuredTypeMembers(type, members, emptyArray, emptyArray, indexInfos);
@@ -72736,7 +72743,10 @@ function createTypeChecker(host) {
72736
72743
  map(context.inferences, (i) => i.typeParameter),
72737
72744
  map(context.inferences, (inference, i) => () => {
72738
72745
  if (!inference.isFixed) {
72739
- inferFromIntraExpressionSites(context);
72746
+ if (context.intraExpressionInferenceSites) {
72747
+ inferFromIntraExpressionSites(context.inferences, context.intraExpressionInferenceSites);
72748
+ context.intraExpressionInferenceSites = void 0;
72749
+ }
72740
72750
  clearCachedInferences(context.inferences);
72741
72751
  inference.isFixed = true;
72742
72752
  }
@@ -72760,17 +72770,38 @@ function createTypeChecker(host) {
72760
72770
  }
72761
72771
  }
72762
72772
  function addIntraExpressionInferenceSite(context, node, type) {
72763
- (context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push({ node, type });
72773
+ const site = { node, type };
72774
+ (context.intraExpressionInferenceSites ?? (context.intraExpressionInferenceSites = [])).push(site);
72775
+ if (context.reverseMappedIntraExpressionInferenceSites) {
72776
+ for (const reverseMappedSites of context.reverseMappedIntraExpressionInferenceSites) {
72777
+ reverseMappedSites.push(site);
72778
+ }
72779
+ }
72764
72780
  }
72765
- function inferFromIntraExpressionSites(context) {
72766
- if (context.intraExpressionInferenceSites) {
72767
- for (const { node, type } of context.intraExpressionInferenceSites) {
72768
- const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType2(node, 2 /* NoConstraints */);
72769
- if (contextualType) {
72770
- inferTypes(context.inferences, type, contextualType);
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();
72788
+ }
72789
+ function findReverseMappedTypeIntraExpressionInferenceScope(context, node) {
72790
+ if (context == null ? void 0 : context.reverseMappedIntraExpressionInferenceScopeNodes) {
72791
+ for (let i = context.reverseMappedIntraExpressionInferenceScopeNodes.length - 1; i >= 0; i--) {
72792
+ if (context.reverseMappedIntraExpressionInferenceScopeNodes[i] === node) {
72793
+ return i;
72771
72794
  }
72772
72795
  }
72773
- context.intraExpressionInferenceSites = void 0;
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
+ }
72774
72805
  }
72775
72806
  }
72776
72807
  function createInferenceInfo(typeParameter) {
@@ -72868,22 +72899,31 @@ function createTypeChecker(host) {
72868
72899
  reverseHomomorphicMappedCache.set(cacheKey, type);
72869
72900
  return type;
72870
72901
  }
72871
- function isPartiallyInferableType(type) {
72872
- return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType2(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
72873
- }
72874
72902
  function createReverseMappedType(source, target, constraint) {
72875
- if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
72903
+ if (!getIndexInfoOfType(source, stringType) && !getPropertiesOfType(source).length) {
72876
72904
  return void 0;
72877
72905
  }
72878
72906
  if (isArrayType(source)) {
72879
- const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint);
72907
+ const elementType = inferReverseMappedType(
72908
+ getTypeArguments(source)[0],
72909
+ target,
72910
+ constraint,
72911
+ /*sourceValueDeclaration*/
72912
+ void 0
72913
+ );
72880
72914
  if (!elementType) {
72881
72915
  return void 0;
72882
72916
  }
72883
72917
  return createArrayType(elementType, isReadonlyArrayType(source));
72884
72918
  }
72885
72919
  if (isTupleType(source)) {
72886
- const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
72920
+ const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(
72921
+ t,
72922
+ target,
72923
+ constraint,
72924
+ /*sourceValueDeclaration*/
72925
+ void 0
72926
+ ));
72887
72927
  if (!every(elementTypes, (t) => !!t)) {
72888
72928
  return void 0;
72889
72929
  }
@@ -72903,20 +72943,39 @@ function createTypeChecker(host) {
72903
72943
  function getTypeOfReverseMappedSymbol(symbol) {
72904
72944
  const links = getSymbolLinks(symbol);
72905
72945
  if (!links.type) {
72906
- const reverseConstraint = symbol.links.inferenceConstraintType && getIndexedAccessTypeOrUndefined(symbol.links.inferenceConstraintType, getStringLiteralType(unescapeLeadingUnderscores(symbol.escapedName)));
72907
- links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType, reverseConstraint) ?? unknownType;
72946
+ links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType, symbol.valueDeclaration) || unknownType;
72908
72947
  }
72909
72948
  return links.type;
72910
72949
  }
72911
- function inferReverseMappedTypeWorker(sourceType, target, constraint, reverseMappedConstraint) {
72950
+ function inferReverseMappedTypeWorker(sourceType, target, constraint, sourceValueDeclaration) {
72912
72951
  const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
72913
72952
  const templateType = getTemplateTypeFromMappedType(target);
72914
72953
  const inference = createInferenceInfo(typeParameter);
72915
72954
  inferTypes([inference], sourceType, templateType);
72916
- return getTypeFromInference(inference) ?? reverseMappedConstraint ?? unknownType;
72955
+ if (sourceValueDeclaration && getObjectFlags(sourceType) & 262144 /* NonInferrableType */) {
72956
+ const scopeNode = sourceValueDeclaration.parent;
72957
+ const inferenceContext = getInferenceContext(scopeNode);
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
+ }
72974
+ }
72975
+ return getTypeFromInference(inference) || unknownType;
72917
72976
  }
72918
- function inferReverseMappedType(source, target, constraint, reverseMappedConstraint) {
72919
- const cacheKey = source.id + "," + target.id + "," + constraint.id + "," + ((reverseMappedConstraint == null ? void 0 : reverseMappedConstraint.id) ?? "0");
72977
+ function inferReverseMappedType(source, target, constraint, sourceValueDeclaration) {
72978
+ const cacheKey = source.id + "," + target.id + "," + constraint.id + (sourceValueDeclaration && getObjectFlags(source) & 262144 /* NonInferrableType */ ? "," + getNodeId(sourceValueDeclaration) : "");
72920
72979
  if (reverseMappedCache.has(cacheKey)) {
72921
72980
  return reverseMappedCache.get(cacheKey) || unknownType;
72922
72981
  }
@@ -72927,7 +72986,7 @@ function createTypeChecker(host) {
72927
72986
  if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2)) reverseExpandingFlags |= 2 /* Target */;
72928
72987
  let type;
72929
72988
  if (reverseExpandingFlags !== 3 /* Both */) {
72930
- type = inferReverseMappedTypeWorker(source, target, constraint, reverseMappedConstraint);
72989
+ type = inferReverseMappedTypeWorker(source, target, constraint, sourceValueDeclaration);
72931
72990
  }
72932
72991
  reverseMappedSourceStack.pop();
72933
72992
  reverseMappedTargetStack.pop();
@@ -73447,7 +73506,7 @@ function createTypeChecker(host) {
73447
73506
  }
73448
73507
  }
73449
73508
  function inferToMappedType(source, target, constraintType) {
73450
- if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
73509
+ if (constraintType.flags & 3145728 /* UnionOrIntersection */) {
73451
73510
  let result = false;
73452
73511
  for (const type of constraintType.types) {
73453
73512
  result = inferToMappedType(source, target, type) || result;
@@ -73772,39 +73831,13 @@ function createTypeChecker(host) {
73772
73831
  const constraint = getConstraintOfTypeParameter(inference.typeParameter);
73773
73832
  if (constraint) {
73774
73833
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
73775
- inferredType = cloneWithInferenceConstraintIfNeeded(inferredType, instantiatedConstraint);
73776
- if (inferredType) {
73777
- inference.inferredType = inferredType;
73778
- }
73779
73834
  if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
73780
- fallbackType = cloneWithInferenceConstraintIfNeeded(fallbackType, instantiatedConstraint);
73781
73835
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
73782
73836
  }
73783
73837
  }
73784
73838
  clearActiveMapperCaches();
73785
73839
  }
73786
73840
  return inference.inferredType;
73787
- function cloneWithInferenceConstraintIfNeeded(type, inferenceConstraintType) {
73788
- if (!type || !(type.flags & 524288 /* Object */) || !(type.objectFlags & 1024 /* ReverseMapped */)) {
73789
- return type;
73790
- }
73791
- const reversed = type;
73792
- const cacheKey = reversed.source.id + "," + reversed.mappedType.id + "," + reversed.constraintType.id + "," + inferenceConstraintType.id;
73793
- if (reverseHomomorphicMappedCache.has(cacheKey)) {
73794
- return reverseHomomorphicMappedCache.get(cacheKey);
73795
- }
73796
- const clone2 = createObjectType(
73797
- 1024 /* ReverseMapped */ | 16 /* Anonymous */,
73798
- /*symbol*/
73799
- void 0
73800
- );
73801
- clone2.source = reversed.source;
73802
- clone2.mappedType = reversed.mappedType;
73803
- clone2.constraintType = reversed.constraintType;
73804
- clone2.inferenceConstraintType = inferenceConstraintType;
73805
- reverseHomomorphicMappedCache.set(cacheKey, clone2);
73806
- return clone2;
73807
- }
73808
73841
  }
73809
73842
  function getDefaultTypeArgumentType(isInJavaScriptFile) {
73810
73843
  return isInJavaScriptFile ? anyType : unknownType;
@@ -78637,17 +78670,25 @@ function createTypeChecker(host) {
78637
78670
  checkComputedPropertyName(elem.name);
78638
78671
  }
78639
78672
  }
78673
+ const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
78640
78674
  let offset = 0;
78641
78675
  for (const memberDecl of node.properties) {
78642
78676
  let member = getSymbolOfDeclaration(memberDecl);
78643
78677
  const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
78644
78678
  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
+ }
78645
78683
  let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
78646
78684
  // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
78647
78685
  // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
78648
78686
  // we don't want to say "could not find 'a'".
78649
78687
  memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
78650
78688
  );
78689
+ if (isIntraExpressionInferenceSource) {
78690
+ popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
78691
+ }
78651
78692
  if (isInJavascript) {
78652
78693
  const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
78653
78694
  if (jsDocType) {
@@ -78682,11 +78723,9 @@ function createTypeChecker(host) {
78682
78723
  prop.links.target = member;
78683
78724
  member = prop;
78684
78725
  allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
78685
- if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
78686
- const inferenceContext = getInferenceContext(node);
78687
- Debug.assert(inferenceContext);
78726
+ if (isIntraExpressionInferenceSource) {
78688
78727
  const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
78689
- addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
78728
+ addIntraExpressionInferenceSite(intraExpressionInferenceContext, inferenceNode, type);
78690
78729
  }
78691
78730
  } else if (memberDecl.kind === 306 /* SpreadAssignment */) {
78692
78731
  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-56300-12",
5
+ "version": "6.0.0-pr-54029-2",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [