typescript 5.2.0-dev.20230612 → 5.2.0-dev.20230614

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
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.2";
21
- var version = `${versionMajorMinor}.0-dev.20230612`;
21
+ var version = `${versionMajorMinor}.0-dev.20230614`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -7729,6 +7729,9 @@ var Diagnostics = {
7729
7729
  Use_type_0: diag(95181, 3 /* Message */, "Use_type_0_95181", "Use 'type {0}'"),
7730
7730
  Fix_all_with_type_only_imports: diag(95182, 3 /* Message */, "Fix_all_with_type_only_imports_95182", "Fix all with type-only imports"),
7731
7731
  Cannot_move_statements_to_the_selected_file: diag(95183, 3 /* Message */, "Cannot_move_statements_to_the_selected_file_95183", "Cannot move statements to the selected file"),
7732
+ Inline_variable: diag(95184, 3 /* Message */, "Inline_variable_95184", "Inline variable"),
7733
+ Could_not_find_variable_to_inline: diag(95185, 3 /* Message */, "Could_not_find_variable_to_inline_95185", "Could not find variable to inline."),
7734
+ Variables_with_multiple_declarations_cannot_be_inlined: diag(95186, 3 /* Message */, "Variables_with_multiple_declarations_cannot_be_inlined_95186", "Variables with multiple declarations cannot be inlined."),
7732
7735
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
7733
7736
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
7734
7737
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -42681,11 +42684,10 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
42681
42684
  CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
42682
42685
  CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
42683
42686
  CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
42684
- CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
42685
- CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
42686
- CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
42687
- CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
42688
- CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
42687
+ CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
42688
+ CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
42689
+ CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
42690
+ CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
42689
42691
  return CheckMode3;
42690
42692
  })(CheckMode || {});
42691
42693
  var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -42960,14 +42962,25 @@ function createTypeChecker(host) {
42960
42962
  getTypeOfPropertyOfContextualType,
42961
42963
  getFullyQualifiedName,
42962
42964
  getResolvedSignature: (node, candidatesOutArray, argumentCount) => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */),
42963
- getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray) => runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(
42964
- call,
42965
- candidatesOutArray,
42966
- /*argumentCount*/
42967
- void 0,
42968
- 64 /* IsForStringLiteralArgumentCompletions */
42969
- )),
42970
- getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
42965
+ getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray, checkMode = 32 /* IsForStringLiteralArgumentCompletions */) => {
42966
+ if (checkMode & 32 /* IsForStringLiteralArgumentCompletions */) {
42967
+ return runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(
42968
+ call,
42969
+ candidatesOutArray,
42970
+ /*argumentCount*/
42971
+ void 0,
42972
+ checkMode & ~32 /* IsForStringLiteralArgumentCompletions */
42973
+ ));
42974
+ }
42975
+ return runWithoutResolvedSignatureCaching(editingArgument, () => getResolvedSignatureWorker(
42976
+ call,
42977
+ candidatesOutArray,
42978
+ /*argumentCount*/
42979
+ void 0,
42980
+ checkMode & ~32 /* IsForStringLiteralArgumentCompletions */
42981
+ ));
42982
+ },
42983
+ getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
42971
42984
  getExpandedParameters,
42972
42985
  hasEffectiveRestParameter,
42973
42986
  containsArgumentsReference,
@@ -50793,9 +50806,15 @@ function createTypeChecker(host) {
50793
50806
  const prop = getPropertyOfType(type, name);
50794
50807
  return prop ? getTypeOfSymbol(prop) : void 0;
50795
50808
  }
50796
- function getTypeOfPropertyOrIndexSignature(type, name) {
50809
+ function getTypeOfPropertyOrIndexSignature(type, name, addOptionalityToIndex) {
50797
50810
  var _a;
50798
- return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) == null ? void 0 : _a.type) || unknownType;
50811
+ let propType;
50812
+ return getTypeOfPropertyOfType(type, name) || (propType = (_a = getApplicableIndexInfoForName(type, name)) == null ? void 0 : _a.type) && addOptionality(
50813
+ propType,
50814
+ /*isProperty*/
50815
+ true,
50816
+ addOptionalityToIndex
50817
+ ) || unknownType;
50799
50818
  }
50800
50819
  function isTypeAny(type) {
50801
50820
  return type && (type.flags & 1 /* Any */) !== 0;
@@ -50922,7 +50941,7 @@ function createTypeChecker(host) {
50922
50941
  return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
50923
50942
  }
50924
50943
  function getTypeForBindingElement(declaration) {
50925
- const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
50944
+ const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
50926
50945
  const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
50927
50946
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
50928
50947
  }
@@ -52679,19 +52698,13 @@ function createTypeChecker(host) {
52679
52698
  if (getObjectFlags(type) & 4 /* Reference */) {
52680
52699
  const target = type.target;
52681
52700
  const typeArguments = getTypeArguments(type);
52682
- if (length(target.typeParameters) === length(typeArguments)) {
52683
- const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType]));
52684
- return needApparentType ? getApparentType(ref) : ref;
52685
- }
52701
+ return length(target.typeParameters) === length(typeArguments) ? createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])) : type;
52686
52702
  } else if (type.flags & 2097152 /* Intersection */) {
52687
52703
  const types = sameMap(type.types, (t) => getTypeWithThisArgument(t, thisArgument, needApparentType));
52688
52704
  return types !== type.types ? getIntersectionType(types) : type;
52689
52705
  }
52690
52706
  return needApparentType ? getApparentType(type) : type;
52691
52707
  }
52692
- function getThisArgument(type) {
52693
- return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
52694
- }
52695
52708
  function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
52696
52709
  let mapper;
52697
52710
  let members;
@@ -53757,7 +53770,7 @@ function createTypeChecker(host) {
53757
53770
  return type.resolvedBaseConstraint;
53758
53771
  }
53759
53772
  const stack = [];
53760
- return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
53773
+ return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
53761
53774
  function getImmediateBaseConstraint(t) {
53762
53775
  if (!t.immediateBaseConstraint) {
53763
53776
  if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
@@ -53849,18 +53862,18 @@ function createTypeChecker(host) {
53849
53862
  }
53850
53863
  if (isGenericTupleType(t)) {
53851
53864
  const newElements = map(getElementTypes(t), (v, i) => {
53852
- const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
53853
- return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
53865
+ const constraint = v.flags & 262144 /* TypeParameter */ && t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
53866
+ return constraint !== v && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
53854
53867
  });
53855
53868
  return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
53856
53869
  }
53857
53870
  return t;
53858
53871
  }
53859
53872
  }
53860
- function getApparentTypeOfIntersectionType(type) {
53873
+ function getApparentTypeOfIntersectionType(type, thisArgument) {
53861
53874
  return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
53862
53875
  type,
53863
- type,
53876
+ thisArgument,
53864
53877
  /*needApparentType*/
53865
53878
  true
53866
53879
  ));
@@ -53911,8 +53924,9 @@ function createTypeChecker(host) {
53911
53924
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
53912
53925
  }
53913
53926
  function getApparentType(type) {
53914
- const t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
53915
- return getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
53927
+ const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
53928
+ const objectFlags = getObjectFlags(t);
53929
+ return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
53916
53930
  }
53917
53931
  function getReducedApparentType(type) {
53918
53932
  return getReducedType(getApparentType(getReducedType(type)));
@@ -60741,7 +60755,7 @@ function createTypeChecker(host) {
60741
60755
  return 3 /* Maybe */;
60742
60756
  }
60743
60757
  const c = target2;
60744
- if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
60758
+ if (!c.root.inferTypeParameters && !isDistributionDependent(c.root) && !(source2.flags & 16777216 /* Conditional */ && source2.root === c.root)) {
60745
60759
  const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
60746
60760
  const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
60747
60761
  if (result2 = skipTrue ? -1 /* True */ : isRelatedTo(
@@ -61802,7 +61816,12 @@ function createTypeChecker(host) {
61802
61816
  let matched = false;
61803
61817
  for (let i = 0; i < types.length; i++) {
61804
61818
  if (include[i]) {
61805
- const targetType = getTypeOfPropertyOfType(types[i], propertyName);
61819
+ const targetType = getTypeOfPropertyOrIndexSignature(
61820
+ types[i],
61821
+ propertyName,
61822
+ /*addOptionalityToIndex*/
61823
+ true
61824
+ );
61806
61825
  if (targetType && related(getDiscriminatingType(), targetType)) {
61807
61826
  matched = true;
61808
61827
  } else {
@@ -63733,7 +63752,7 @@ function createTypeChecker(host) {
63733
63752
  const constraint = getConstraintOfTypeParameter(inference.typeParameter);
63734
63753
  if (constraint) {
63735
63754
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
63736
- if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
63755
+ if (!inferredType || inferredType === wildcardType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
63737
63756
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
63738
63757
  }
63739
63758
  }
@@ -65200,7 +65219,12 @@ function createTypeChecker(host) {
65200
65219
  propType = removeNullable && optionalChain ? getOptionalType(propType) : propType;
65201
65220
  const narrowedPropType = narrowType2(propType);
65202
65221
  return filterType(type, (t) => {
65203
- const discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
65222
+ const discriminantType = getTypeOfPropertyOrIndexSignature(
65223
+ t,
65224
+ propName,
65225
+ /*addOptionalityToIndex*/
65226
+ false
65227
+ );
65204
65228
  return !(discriminantType.flags & 131072 /* Never */) && !(narrowedPropType.flags & 131072 /* Never */) && areTypesComparable(narrowedPropType, discriminantType);
65205
65229
  });
65206
65230
  }
@@ -65827,7 +65851,7 @@ function createTypeChecker(host) {
65827
65851
  return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
65828
65852
  }
65829
65853
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
65830
- const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
65854
+ const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
65831
65855
  node,
65832
65856
  /*contextFlags*/
65833
65857
  void 0
@@ -66474,6 +66498,25 @@ function createTypeChecker(host) {
66474
66498
  return t.flags & 2097152 /* Intersection */ ? forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
66475
66499
  });
66476
66500
  }
66501
+ function getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType) {
66502
+ let literal = containingLiteral;
66503
+ let type = contextualType;
66504
+ while (type) {
66505
+ const thisType = getThisTypeFromContextualType(type);
66506
+ if (thisType) {
66507
+ return thisType;
66508
+ }
66509
+ if (literal.parent.kind !== 302 /* PropertyAssignment */) {
66510
+ break;
66511
+ }
66512
+ literal = literal.parent.parent;
66513
+ type = getApparentTypeOfContextualType(
66514
+ literal,
66515
+ /*contextFlags*/
66516
+ void 0
66517
+ );
66518
+ }
66519
+ }
66477
66520
  function getContextualThisParameterType(func) {
66478
66521
  if (func.kind === 218 /* ArrowFunction */) {
66479
66522
  return void 0;
@@ -66496,22 +66539,9 @@ function createTypeChecker(host) {
66496
66539
  /*contextFlags*/
66497
66540
  void 0
66498
66541
  );
66499
- let literal = containingLiteral;
66500
- let type = contextualType;
66501
- while (type) {
66502
- const thisType = getThisTypeFromContextualType(type);
66503
- if (thisType) {
66504
- return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
66505
- }
66506
- if (literal.parent.kind !== 302 /* PropertyAssignment */) {
66507
- break;
66508
- }
66509
- literal = literal.parent.parent;
66510
- type = getApparentTypeOfContextualType(
66511
- literal,
66512
- /*contextFlags*/
66513
- void 0
66514
- );
66542
+ const thisType = getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType);
66543
+ if (thisType) {
66544
+ return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
66515
66545
  }
66516
66546
  return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
66517
66547
  }
@@ -66584,7 +66614,7 @@ function createTypeChecker(host) {
66584
66614
  function getContextualTypeForBindingElement(declaration, contextFlags) {
66585
66615
  const parent = declaration.parent.parent;
66586
66616
  const name = declaration.propertyName || declaration.name;
66587
- const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
66617
+ const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
66588
66618
  if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
66589
66619
  return void 0;
66590
66620
  if (parent.name.kind === 206 /* ArrayBindingPattern */) {
@@ -67633,9 +67663,7 @@ function createTypeChecker(host) {
67633
67663
  elementTypes.push(undefinedOrMissingType);
67634
67664
  elementFlags.push(2 /* Optional */);
67635
67665
  } else {
67636
- const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
67637
- const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
67638
- const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
67666
+ const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
67639
67667
  elementTypes.push(addOptionality(
67640
67668
  type,
67641
67669
  /*isProperty*/
@@ -67643,7 +67671,7 @@ function createTypeChecker(host) {
67643
67671
  hasOmittedExpression
67644
67672
  ));
67645
67673
  elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
67646
- if (shouldAddAsIntraExpressionInferenceSite) {
67674
+ if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
67647
67675
  const inferenceContext = getInferenceContext(node);
67648
67676
  Debug.assert(inferenceContext);
67649
67677
  addIntraExpressionInferenceSite(inferenceContext, e, type);
@@ -67784,13 +67812,11 @@ function createTypeChecker(host) {
67784
67812
  let member = getSymbolOfDeclaration(memberDecl);
67785
67813
  const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
67786
67814
  if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
67787
- const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
67788
- const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
67789
- let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
67815
+ let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
67790
67816
  // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
67791
67817
  // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
67792
67818
  // we don't want to say "could not find 'a'".
67793
- memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
67819
+ memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
67794
67820
  );
67795
67821
  if (isInJavascript) {
67796
67822
  const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
@@ -67834,7 +67860,7 @@ function createTypeChecker(host) {
67834
67860
  prop.links.target = member;
67835
67861
  member = prop;
67836
67862
  allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
67837
- if (shouldAddAsIntraExpressionInferenceSite) {
67863
+ if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
67838
67864
  const inferenceContext = getInferenceContext(node);
67839
67865
  Debug.assert(inferenceContext);
67840
67866
  const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
@@ -68007,9 +68033,7 @@ function createTypeChecker(host) {
68007
68033
  for (const attributeDecl of attributes.properties) {
68008
68034
  const member = attributeDecl.symbol;
68009
68035
  if (isJsxAttribute(attributeDecl)) {
68010
- const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
68011
- const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
68012
- const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
68036
+ const exprType = checkJsxAttribute(attributeDecl, checkMode);
68013
68037
  objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
68014
68038
  const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
68015
68039
  attributeSymbol.declarations = member.declarations;
@@ -68030,7 +68054,7 @@ function createTypeChecker(host) {
68030
68054
  addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
68031
68055
  }
68032
68056
  }
68033
- if (shouldAddAsIntraExpressionInferenceSite) {
68057
+ if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
68034
68058
  const inferenceContext = getInferenceContext(attributes);
68035
68059
  Debug.assert(inferenceContext);
68036
68060
  const inferenceNode = attributeDecl.initializer.expression;
@@ -69648,7 +69672,7 @@ function createTypeChecker(host) {
69648
69672
  }
69649
69673
  for (let i = 0; i < argCount; i++) {
69650
69674
  const arg = args[i];
69651
- if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
69675
+ if (arg.kind !== 231 /* OmittedExpression */) {
69652
69676
  const paramType = getTypeAtPosition(signature, i);
69653
69677
  if (couldContainTypeVariables(paramType)) {
69654
69678
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -70261,12 +70285,11 @@ function createTypeChecker(host) {
70261
70285
  const args = getEffectiveCallArguments(node);
70262
70286
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
70263
70287
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
70264
- argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
70265
70288
  let candidatesForArgumentError;
70266
70289
  let candidateForArgumentArityError;
70267
70290
  let candidateForTypeArgumentError;
70268
70291
  let result;
70269
- const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
70292
+ const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
70270
70293
  if (candidates.length > 1) {
70271
70294
  result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
70272
70295
  }
@@ -70485,7 +70508,7 @@ function createTypeChecker(host) {
70485
70508
  continue;
70486
70509
  }
70487
70510
  if (argCheckMode) {
70488
- argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
70511
+ argCheckMode = 0 /* Normal */;
70489
70512
  if (inferenceContext) {
70490
70513
  const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
70491
70514
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
@@ -73563,8 +73586,9 @@ function createTypeChecker(host) {
73563
73586
  case 36 /* ExclamationEqualsToken */:
73564
73587
  case 37 /* EqualsEqualsEqualsToken */:
73565
73588
  case 38 /* ExclamationEqualsEqualsToken */:
73566
- if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
73567
- if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
73589
+ if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
73590
+ if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
73591
+ (!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
73568
73592
  const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
73569
73593
  error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
73570
73594
  }
@@ -74222,7 +74246,7 @@ function createTypeChecker(host) {
74222
74246
  }
74223
74247
  }
74224
74248
  const startInvocationCount = flowInvocationCount;
74225
- const type = checkExpression(node, 256 /* TypeOnly */);
74249
+ const type = checkExpression(node, 128 /* TypeOnly */);
74226
74250
  if (flowInvocationCount !== startInvocationCount) {
74227
74251
  const cache = flowTypeCache || (flowTypeCache = []);
74228
74252
  cache[getNodeId(node)] = type;
@@ -74337,7 +74361,7 @@ function createTypeChecker(host) {
74337
74361
  return nullWideningType;
74338
74362
  case 15 /* NoSubstitutionTemplateLiteral */:
74339
74363
  case 11 /* StringLiteral */:
74340
- return hasSkipDirectInferenceFlag(node) ? anyType : getFreshTypeOfLiteralType(getStringLiteralType(node.text));
74364
+ return hasSkipDirectInferenceFlag(node) ? wildcardType : getFreshTypeOfLiteralType(getStringLiteralType(node.text));
74341
74365
  case 9 /* NumericLiteral */:
74342
74366
  checkGrammarNumericLiteral(node);
74343
74367
  return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text));
@@ -76693,7 +76717,7 @@ function createTypeChecker(host) {
76693
76717
  checkComputedPropertyName(node.propertyName);
76694
76718
  }
76695
76719
  const parent = node.parent.parent;
76696
- const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
76720
+ const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
76697
76721
  const parentType = getTypeForBindingElementParent(parent, parentCheckMode);
76698
76722
  const name = node.propertyName || node.name;
76699
76723
  if (parentType && !isBindingPattern(name)) {
@@ -80283,7 +80307,7 @@ function createTypeChecker(host) {
80283
80307
  /*contextFlags*/
80284
80308
  void 0
80285
80309
  );
80286
- const type = contextualType && getThisTypeFromContextualType(contextualType);
80310
+ const type = getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType);
80287
80311
  return type && !isTypeAny(type);
80288
80312
  }
80289
80313
  }
@@ -113766,7 +113790,9 @@ var plainJSErrors = /* @__PURE__ */ new Set([
113766
113790
  Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
113767
113791
  Diagnostics.Class_constructor_may_not_be_a_generator.code,
113768
113792
  Diagnostics.Class_constructor_may_not_be_an_accessor.code,
113769
- Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code
113793
+ Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
113794
+ // Type errors
113795
+ Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value.code
113770
113796
  ]);
113771
113797
  function shouldProgramCreateNewSourceFiles(program, newOptions) {
113772
113798
  if (!program)