@typescript-deploys/pr-build 6.0.0-pr-53017-20 → 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) || 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 */) {
@@ -68107,7 +68115,10 @@ function createTypeChecker(host) {
68107
68115
  map(context.inferences, (i) => i.typeParameter),
68108
68116
  map(context.inferences, (inference, i) => () => {
68109
68117
  if (!inference.isFixed) {
68110
- inferFromIntraExpressionSites(context);
68118
+ if (context.intraExpressionInferenceSites) {
68119
+ inferFromIntraExpressionSites(context.inferences, context.intraExpressionInferenceSites);
68120
+ context.intraExpressionInferenceSites = void 0;
68121
+ }
68111
68122
  clearCachedInferences(context.inferences);
68112
68123
  inference.isFixed = true;
68113
68124
  }
@@ -68131,17 +68142,38 @@ function createTypeChecker(host) {
68131
68142
  }
68132
68143
  }
68133
68144
  function addIntraExpressionInferenceSite(context, node, type) {
68134
- (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
+ }
68135
68152
  }
68136
- function inferFromIntraExpressionSites(context) {
68137
- if (context.intraExpressionInferenceSites) {
68138
- for (const { node, type } of context.intraExpressionInferenceSites) {
68139
- const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType(node, 2 /* NoConstraints */);
68140
- if (contextualType) {
68141
- 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;
68142
68166
  }
68143
68167
  }
68144
- 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
+ }
68145
68177
  }
68146
68178
  }
68147
68179
  function createInferenceInfo(typeParameter) {
@@ -68153,8 +68185,7 @@ function createTypeChecker(host) {
68153
68185
  priority: void 0,
68154
68186
  topLevel: true,
68155
68187
  isFixed: false,
68156
- impliedArity: void 0,
68157
- indexes: void 0
68188
+ impliedArity: void 0
68158
68189
  };
68159
68190
  }
68160
68191
  function cloneInferenceInfo(inference) {
@@ -68166,8 +68197,7 @@ function createTypeChecker(host) {
68166
68197
  priority: inference.priority,
68167
68198
  topLevel: inference.topLevel,
68168
68199
  isFixed: inference.isFixed,
68169
- impliedArity: inference.impliedArity,
68170
- indexes: inference.indexes && inference.indexes.slice()
68200
+ impliedArity: inference.impliedArity
68171
68201
  };
68172
68202
  }
68173
68203
  function cloneInferredPartOfContext(context) {
@@ -68241,22 +68271,31 @@ function createTypeChecker(host) {
68241
68271
  reverseHomomorphicMappedCache.set(cacheKey, type);
68242
68272
  return type;
68243
68273
  }
68244
- function isPartiallyInferableType(type) {
68245
- return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
68246
- }
68247
68274
  function createReverseMappedType(source, target, constraint) {
68248
- if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
68275
+ if (!getIndexInfoOfType(source, stringType) && !getPropertiesOfType(source).length) {
68249
68276
  return void 0;
68250
68277
  }
68251
68278
  if (isArrayType(source)) {
68252
- 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
+ );
68253
68286
  if (!elementType) {
68254
68287
  return void 0;
68255
68288
  }
68256
68289
  return createArrayType(elementType, isReadonlyArrayType(source));
68257
68290
  }
68258
68291
  if (isTupleType(source)) {
68259
- 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
+ ));
68260
68299
  if (!every(elementTypes, (t) => !!t)) {
68261
68300
  return void 0;
68262
68301
  }
@@ -68276,19 +68315,39 @@ function createTypeChecker(host) {
68276
68315
  function getTypeOfReverseMappedSymbol(symbol) {
68277
68316
  const links = getSymbolLinks(symbol);
68278
68317
  if (!links.type) {
68279
- links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType) || 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) {
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) || (inference.indexes ? getIntersectionType(inference.indexes) : 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) {
68291
- const cacheKey = source.id + "," + target.id + "," + constraint.id;
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);
68361
+ type = inferReverseMappedTypeWorker(source, target, constraint, sourceValueDeclaration);
68303
68362
  }
68304
68363
  reverseMappedSourceStack.pop();
68305
68364
  reverseMappedTargetStack.pop();
@@ -68626,24 +68685,6 @@ function createTypeChecker(host) {
68626
68685
  } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
68627
68686
  inferFromTypes(source.objectType, target.objectType);
68628
68687
  inferFromTypes(source.indexType, target.indexType);
68629
- } else if (!(priority & 1 /* NakedTypeVariable */) && target.flags & 8388608 /* IndexedAccess */) {
68630
- if (isFromInferenceBlockedSource(source)) {
68631
- return;
68632
- }
68633
- const inference = getInferenceInfoForType(getActualTypeVariable(target.objectType));
68634
- if (inference) {
68635
- if (getObjectFlags(source) & 262144 /* NonInferrableType */ || source === nonInferrableAnyType) {
68636
- return;
68637
- }
68638
- if (!inference.isFixed) {
68639
- const inferenceTypeSymbol = getGlobalSymbol("PartialInference", 788968 /* Type */, Diagnostics.Cannot_find_global_type_0);
68640
- const inferenceType = inferenceTypeSymbol && getDeclaredTypeOfSymbol(inferenceTypeSymbol);
68641
- if (inferenceType && inferenceType !== unknownType) {
68642
- const mapper = createTypeMapper(getSymbolLinks(inferenceTypeSymbol).typeParameters, [source, target.indexType]);
68643
- inference.indexes = append(inference.indexes, instantiateType(inferenceType, mapper));
68644
- }
68645
- }
68646
- }
68647
68688
  } else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) {
68648
68689
  if (source.symbol === target.symbol) {
68649
68690
  inferFromTypes(source.type, target.type);
@@ -68837,7 +68878,7 @@ function createTypeChecker(host) {
68837
68878
  }
68838
68879
  }
68839
68880
  function inferToMappedType(source, target, constraintType) {
68840
- if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
68881
+ if (constraintType.flags & 3145728 /* UnionOrIntersection */) {
68841
68882
  let result = false;
68842
68883
  for (const type of constraintType.types) {
68843
68884
  result = inferToMappedType(source, target, type) || result;
@@ -69147,51 +69188,6 @@ function createTypeChecker(host) {
69147
69188
  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))));
69148
69189
  inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
69149
69190
  fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
69150
- } else if (inference.indexes) {
69151
- let aggregateInference = getIntersectionType(inference.indexes);
69152
- const constraint2 = getConstraintOfTypeParameter(inference.typeParameter);
69153
- if (constraint2) {
69154
- const instantiatedConstraint = instantiateType(constraint2, context.nonFixingMapper);
69155
- if (instantiatedConstraint.flags & 1048576 /* Union */ && !context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference))) {
69156
- const discriminantProps = findDiscriminantProperties(getPropertiesOfType(aggregateInference), instantiatedConstraint);
69157
- if (discriminantProps) {
69158
- let match;
69159
- findDiscriminant:
69160
- for (const p of discriminantProps) {
69161
- const candidatePropType = getTypeOfPropertyOfType(aggregateInference, p.escapedName);
69162
- for (const type of instantiatedConstraint.types) {
69163
- const propType = getTypeOfPropertyOfType(type, p.escapedName);
69164
- if (propType && candidatePropType && checkTypeAssignableTo(
69165
- candidatePropType,
69166
- propType,
69167
- /*errorNode*/
69168
- void 0
69169
- )) {
69170
- if (match && match !== type) {
69171
- match = void 0;
69172
- break findDiscriminant;
69173
- } else {
69174
- match = type;
69175
- }
69176
- }
69177
- }
69178
- }
69179
- if (match) {
69180
- aggregateInference = getSpreadType(
69181
- match,
69182
- aggregateInference,
69183
- /*symbol*/
69184
- void 0,
69185
- /*propegatedFlags*/
69186
- 0,
69187
- /*readonly*/
69188
- false
69189
- );
69190
- }
69191
- }
69192
- }
69193
- }
69194
- inferredType = aggregateInference;
69195
69191
  } else if (context.flags & 1 /* NoDefault */) {
69196
69192
  inferredType = silentNeverType;
69197
69193
  } else {
@@ -74046,17 +74042,25 @@ function createTypeChecker(host) {
74046
74042
  checkComputedPropertyName(elem.name);
74047
74043
  }
74048
74044
  }
74045
+ const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
74049
74046
  let offset = 0;
74050
74047
  for (const memberDecl of node.properties) {
74051
74048
  let member = getSymbolOfDeclaration(memberDecl);
74052
74049
  const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
74053
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
+ }
74054
74055
  let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
74055
74056
  // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
74056
74057
  // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
74057
74058
  // we don't want to say "could not find 'a'".
74058
74059
  memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
74059
74060
  );
74061
+ if (isIntraExpressionInferenceSource) {
74062
+ popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
74063
+ }
74060
74064
  if (isInJavascript) {
74061
74065
  const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
74062
74066
  if (jsDocType) {
@@ -74091,11 +74095,9 @@ function createTypeChecker(host) {
74091
74095
  prop.links.target = member;
74092
74096
  member = prop;
74093
74097
  allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
74094
- if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
74095
- const inferenceContext = getInferenceContext(node);
74096
- Debug.assert(inferenceContext);
74098
+ if (isIntraExpressionInferenceSource) {
74097
74099
  const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
74098
- addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
74100
+ addIntraExpressionInferenceSite(intraExpressionInferenceContext, inferenceNode, type);
74099
74101
  }
74100
74102
  } else if (memberDecl.kind === 306 /* SpreadAssignment */) {
74101
74103
  if (languageVersion < LanguageFeatureMinimumTarget.ObjectAssign) {
package/lib/lib.es5.d.ts CHANGED
@@ -1682,15 +1682,6 @@ 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 string> = ({
1689
- [K in Keys]: {
1690
- [K1 in K]: T;
1691
- };
1692
- })[Keys];
1693
-
1694
1685
  /**
1695
1686
  * Stores types to be used with WeakSet, WeakMap, WeakRef, and FinalizationRegistry
1696
1687
  */
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) || 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 */) {
@@ -72735,7 +72743,10 @@ function createTypeChecker(host) {
72735
72743
  map(context.inferences, (i) => i.typeParameter),
72736
72744
  map(context.inferences, (inference, i) => () => {
72737
72745
  if (!inference.isFixed) {
72738
- inferFromIntraExpressionSites(context);
72746
+ if (context.intraExpressionInferenceSites) {
72747
+ inferFromIntraExpressionSites(context.inferences, context.intraExpressionInferenceSites);
72748
+ context.intraExpressionInferenceSites = void 0;
72749
+ }
72739
72750
  clearCachedInferences(context.inferences);
72740
72751
  inference.isFixed = true;
72741
72752
  }
@@ -72759,17 +72770,38 @@ function createTypeChecker(host) {
72759
72770
  }
72760
72771
  }
72761
72772
  function addIntraExpressionInferenceSite(context, node, type) {
72762
- (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
+ }
72763
72780
  }
72764
- function inferFromIntraExpressionSites(context) {
72765
- if (context.intraExpressionInferenceSites) {
72766
- for (const { node, type } of context.intraExpressionInferenceSites) {
72767
- const contextualType = node.kind === 175 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType2(node, 2 /* NoConstraints */);
72768
- if (contextualType) {
72769
- 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;
72770
72794
  }
72771
72795
  }
72772
- 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
+ }
72773
72805
  }
72774
72806
  }
72775
72807
  function createInferenceInfo(typeParameter) {
@@ -72781,8 +72813,7 @@ function createTypeChecker(host) {
72781
72813
  priority: void 0,
72782
72814
  topLevel: true,
72783
72815
  isFixed: false,
72784
- impliedArity: void 0,
72785
- indexes: void 0
72816
+ impliedArity: void 0
72786
72817
  };
72787
72818
  }
72788
72819
  function cloneInferenceInfo(inference) {
@@ -72794,8 +72825,7 @@ function createTypeChecker(host) {
72794
72825
  priority: inference.priority,
72795
72826
  topLevel: inference.topLevel,
72796
72827
  isFixed: inference.isFixed,
72797
- impliedArity: inference.impliedArity,
72798
- indexes: inference.indexes && inference.indexes.slice()
72828
+ impliedArity: inference.impliedArity
72799
72829
  };
72800
72830
  }
72801
72831
  function cloneInferredPartOfContext(context) {
@@ -72869,22 +72899,31 @@ function createTypeChecker(host) {
72869
72899
  reverseHomomorphicMappedCache.set(cacheKey, type);
72870
72900
  return type;
72871
72901
  }
72872
- function isPartiallyInferableType(type) {
72873
- return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType2(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
72874
- }
72875
72902
  function createReverseMappedType(source, target, constraint) {
72876
- if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
72903
+ if (!getIndexInfoOfType(source, stringType) && !getPropertiesOfType(source).length) {
72877
72904
  return void 0;
72878
72905
  }
72879
72906
  if (isArrayType(source)) {
72880
- 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
+ );
72881
72914
  if (!elementType) {
72882
72915
  return void 0;
72883
72916
  }
72884
72917
  return createArrayType(elementType, isReadonlyArrayType(source));
72885
72918
  }
72886
72919
  if (isTupleType(source)) {
72887
- 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
+ ));
72888
72927
  if (!every(elementTypes, (t) => !!t)) {
72889
72928
  return void 0;
72890
72929
  }
@@ -72904,19 +72943,39 @@ function createTypeChecker(host) {
72904
72943
  function getTypeOfReverseMappedSymbol(symbol) {
72905
72944
  const links = getSymbolLinks(symbol);
72906
72945
  if (!links.type) {
72907
- links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType) || 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) {
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) || (inference.indexes ? getIntersectionType(inference.indexes) : 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) {
72919
- const cacheKey = source.id + "," + target.id + "," + constraint.id;
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);
72989
+ type = inferReverseMappedTypeWorker(source, target, constraint, sourceValueDeclaration);
72931
72990
  }
72932
72991
  reverseMappedSourceStack.pop();
72933
72992
  reverseMappedTargetStack.pop();
@@ -73254,24 +73313,6 @@ function createTypeChecker(host) {
73254
73313
  } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
73255
73314
  inferFromTypes(source.objectType, target.objectType);
73256
73315
  inferFromTypes(source.indexType, target.indexType);
73257
- } else if (!(priority & 1 /* NakedTypeVariable */) && target.flags & 8388608 /* IndexedAccess */) {
73258
- if (isFromInferenceBlockedSource(source)) {
73259
- return;
73260
- }
73261
- const inference = getInferenceInfoForType(getActualTypeVariable(target.objectType));
73262
- if (inference) {
73263
- if (getObjectFlags(source) & 262144 /* NonInferrableType */ || source === nonInferrableAnyType) {
73264
- return;
73265
- }
73266
- if (!inference.isFixed) {
73267
- const inferenceTypeSymbol = getGlobalSymbol("PartialInference", 788968 /* Type */, Diagnostics.Cannot_find_global_type_0);
73268
- const inferenceType = inferenceTypeSymbol && getDeclaredTypeOfSymbol(inferenceTypeSymbol);
73269
- if (inferenceType && inferenceType !== unknownType) {
73270
- const mapper = createTypeMapper(getSymbolLinks(inferenceTypeSymbol).typeParameters, [source, target.indexType]);
73271
- inference.indexes = append(inference.indexes, instantiateType(inferenceType, mapper));
73272
- }
73273
- }
73274
- }
73275
73316
  } else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) {
73276
73317
  if (source.symbol === target.symbol) {
73277
73318
  inferFromTypes(source.type, target.type);
@@ -73465,7 +73506,7 @@ function createTypeChecker(host) {
73465
73506
  }
73466
73507
  }
73467
73508
  function inferToMappedType(source, target, constraintType) {
73468
- if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
73509
+ if (constraintType.flags & 3145728 /* UnionOrIntersection */) {
73469
73510
  let result = false;
73470
73511
  for (const type of constraintType.types) {
73471
73512
  result = inferToMappedType(source, target, type) || result;
@@ -73775,51 +73816,6 @@ function createTypeChecker(host) {
73775
73816
  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))));
73776
73817
  inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
73777
73818
  fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
73778
- } else if (inference.indexes) {
73779
- let aggregateInference = getIntersectionType(inference.indexes);
73780
- const constraint2 = getConstraintOfTypeParameter(inference.typeParameter);
73781
- if (constraint2) {
73782
- const instantiatedConstraint = instantiateType(constraint2, context.nonFixingMapper);
73783
- if (instantiatedConstraint.flags & 1048576 /* Union */ && !context.compareTypes(aggregateInference, getTypeWithThisArgument(instantiatedConstraint, aggregateInference))) {
73784
- const discriminantProps = findDiscriminantProperties(getPropertiesOfType(aggregateInference), instantiatedConstraint);
73785
- if (discriminantProps) {
73786
- let match;
73787
- findDiscriminant:
73788
- for (const p of discriminantProps) {
73789
- const candidatePropType = getTypeOfPropertyOfType(aggregateInference, p.escapedName);
73790
- for (const type of instantiatedConstraint.types) {
73791
- const propType = getTypeOfPropertyOfType(type, p.escapedName);
73792
- if (propType && candidatePropType && checkTypeAssignableTo(
73793
- candidatePropType,
73794
- propType,
73795
- /*errorNode*/
73796
- void 0
73797
- )) {
73798
- if (match && match !== type) {
73799
- match = void 0;
73800
- break findDiscriminant;
73801
- } else {
73802
- match = type;
73803
- }
73804
- }
73805
- }
73806
- }
73807
- if (match) {
73808
- aggregateInference = getSpreadType(
73809
- match,
73810
- aggregateInference,
73811
- /*symbol*/
73812
- void 0,
73813
- /*propegatedFlags*/
73814
- 0,
73815
- /*readonly*/
73816
- false
73817
- );
73818
- }
73819
- }
73820
- }
73821
- }
73822
- inferredType = aggregateInference;
73823
73819
  } else if (context.flags & 1 /* NoDefault */) {
73824
73820
  inferredType = silentNeverType;
73825
73821
  } else {
@@ -78674,17 +78670,25 @@ function createTypeChecker(host) {
78674
78670
  checkComputedPropertyName(elem.name);
78675
78671
  }
78676
78672
  }
78673
+ const intraExpressionInferenceContext = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) ? getInferenceContext(node) : void 0;
78677
78674
  let offset = 0;
78678
78675
  for (const memberDecl of node.properties) {
78679
78676
  let member = getSymbolOfDeclaration(memberDecl);
78680
78677
  const computedNameType = memberDecl.name && memberDecl.name.kind === 168 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
78681
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
+ }
78682
78683
  let type = memberDecl.kind === 304 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
78683
78684
  // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
78684
78685
  // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
78685
78686
  // we don't want to say "could not find 'a'".
78686
78687
  memberDecl.kind === 305 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
78687
78688
  );
78689
+ if (isIntraExpressionInferenceSource) {
78690
+ popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext);
78691
+ }
78688
78692
  if (isInJavascript) {
78689
78693
  const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
78690
78694
  if (jsDocType) {
@@ -78719,11 +78723,9 @@ function createTypeChecker(host) {
78719
78723
  prop.links.target = member;
78720
78724
  member = prop;
78721
78725
  allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
78722
- if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 304 /* PropertyAssignment */ || memberDecl.kind === 175 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
78723
- const inferenceContext = getInferenceContext(node);
78724
- Debug.assert(inferenceContext);
78726
+ if (isIntraExpressionInferenceSource) {
78725
78727
  const inferenceNode = memberDecl.kind === 304 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
78726
- addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
78728
+ addIntraExpressionInferenceSite(intraExpressionInferenceContext, inferenceNode, type);
78727
78729
  }
78728
78730
  } else if (memberDecl.kind === 306 /* SpreadAssignment */) {
78729
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-53017-20",
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": [