@typescript-deploys/pr-build 5.2.0-pr-52095-16 → 5.2.0-pr-54753-25

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/tsserver.js CHANGED
@@ -2329,7 +2329,7 @@ module.exports = __toCommonJS(server_exports);
2329
2329
 
2330
2330
  // src/compiler/corePublic.ts
2331
2331
  var versionMajorMinor = "5.2";
2332
- var version = `${versionMajorMinor}.0-insiders.20230725`;
2332
+ var version = `${versionMajorMinor}.0-insiders.20230726`;
2333
2333
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2334
2334
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2335
2335
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9287,6 +9287,7 @@ var Diagnostics = {
9287
9287
  Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, 1 /* Error */, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
9288
9288
  An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, 1 /* Error */, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
9289
9289
  The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
9290
+ The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1065, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065", "The return type of an async function or method must be the global Promise<T> type."),
9290
9291
  In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, 1 /* Error */, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
9291
9292
  Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, 1 /* Error */, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
9292
9293
  Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, 1 /* Error */, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
@@ -58622,7 +58623,12 @@ function createTypeChecker(host) {
58622
58623
  for (const current of type.types) {
58623
58624
  for (const prop of getPropertiesOfType(current)) {
58624
58625
  if (!members.has(prop.escapedName)) {
58625
- const combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
58626
+ const combinedProp = getPropertyOfUnionOrIntersectionType(
58627
+ type,
58628
+ prop.escapedName,
58629
+ /*skipObjectFunctionPropertyAugment*/
58630
+ !!(type.flags & 2097152 /* Intersection */)
58631
+ );
58626
58632
  if (combinedProp) {
58627
58633
  members.set(prop.escapedName, combinedProp);
58628
58634
  }
@@ -59102,13 +59108,17 @@ function createTypeChecker(host) {
59102
59108
  return result;
59103
59109
  }
59104
59110
  function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
59105
- var _a, _b;
59111
+ var _a, _b, _c;
59106
59112
  let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
59107
59113
  if (!property) {
59108
59114
  property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
59109
59115
  if (property) {
59110
59116
  const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
59111
59117
  properties.set(name, property);
59118
+ if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
59119
+ const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
59120
+ properties2.set(name, property);
59121
+ }
59112
59122
  }
59113
59123
  }
59114
59124
  return property;
@@ -59228,7 +59238,22 @@ function createTypeChecker(host) {
59228
59238
  }
59229
59239
  return getPropertyOfObjectType(globalObjectType, name);
59230
59240
  }
59231
- if (type.flags & 3145728 /* UnionOrIntersection */) {
59241
+ if (type.flags & 2097152 /* Intersection */) {
59242
+ const prop = getPropertyOfUnionOrIntersectionType(
59243
+ type,
59244
+ name,
59245
+ /*skipObjectFunctionPropertyAugment*/
59246
+ true
59247
+ );
59248
+ if (prop) {
59249
+ return prop;
59250
+ }
59251
+ if (!skipObjectFunctionPropertyAugment) {
59252
+ return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
59253
+ }
59254
+ return void 0;
59255
+ }
59256
+ if (type.flags & 1048576 /* Union */) {
59232
59257
  return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
59233
59258
  }
59234
59259
  return void 0;
@@ -65867,26 +65892,6 @@ function createTypeChecker(host) {
65867
65892
  )) {
65868
65893
  return result2;
65869
65894
  }
65870
- if (sourceFlags & 8388608 /* IndexedAccess */) {
65871
- const indexType = source2.indexType;
65872
- if (indexType.flags & 4194304 /* Index */) {
65873
- const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
65874
- const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
65875
- const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
65876
- if (result2 = isRelatedTo(
65877
- constraint2,
65878
- target2,
65879
- 1 /* Source */,
65880
- /*reportErrors*/
65881
- false,
65882
- /*headMessage*/
65883
- void 0,
65884
- intersectionState
65885
- )) {
65886
- return result2;
65887
- }
65888
- }
65889
- }
65890
65895
  if (isMappedTypeGenericIndexedAccess(source2)) {
65891
65896
  const indexConstraint = getConstraintOfType(source2.indexType);
65892
65897
  if (indexConstraint) {
@@ -71981,75 +71986,41 @@ function createTypeChecker(host) {
71981
71986
  return mapType(
71982
71987
  type,
71983
71988
  (t) => {
71984
- if (!(t.flags & 3670016 /* StructuredType */)) {
71985
- return void 0;
71986
- }
71987
- if (t.flags & 2097152 /* Intersection */) {
71988
- const intersection = t;
71989
- let applicableIndexedMappedTypeSubstitions;
71990
- let concretePropertyTypes;
71991
- let applicableIndexInfoCandidates;
71992
- for (const t2 of intersection.types) {
71993
- if (isGenericMappedType(t2) && !t2.declaration.nameType) {
71994
- applicableIndexedMappedTypeSubstitions = append(applicableIndexedMappedTypeSubstitions, getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t2));
71995
- continue;
71996
- }
71997
- const typeOfConcreteProperty = getTypeOfConcretePropertyOfContextualType(t2);
71998
- if (typeOfConcreteProperty) {
71999
- concretePropertyTypes = append(concretePropertyTypes, typeOfConcreteProperty);
72000
- continue;
72001
- }
72002
- applicableIndexInfoCandidates = append(applicableIndexInfoCandidates, t2);
72003
- }
72004
- if (concretePropertyTypes) {
72005
- return getIntersectionType(concatenate(concretePropertyTypes, applicableIndexedMappedTypeSubstitions));
71989
+ var _a;
71990
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
71991
+ const constraint = getConstraintTypeFromMappedType(t);
71992
+ const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
71993
+ const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
71994
+ if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
71995
+ return substituteIndexedMappedType(t, propertyNameType);
71996
+ }
71997
+ } else if (t.flags & 3670016 /* StructuredType */) {
71998
+ const prop = getPropertyOfType(t, name);
71999
+ if (prop) {
72000
+ return isCircularMappedProperty(prop) ? void 0 : getTypeOfSymbol(prop);
72006
72001
  }
72007
- const types = concatenate(mapDefined(applicableIndexInfoCandidates, getTypeOfApplicableIndexInfoOfContextualType), applicableIndexedMappedTypeSubstitions);
72008
- if (types.length > 0) {
72009
- return getIntersectionType(types);
72002
+ if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
72003
+ const restType = getElementTypeOfSliceOfTupleType(
72004
+ t,
72005
+ t.target.fixedLength,
72006
+ /*endSkipCount*/
72007
+ 0,
72008
+ /*writing*/
72009
+ false,
72010
+ /*noReductions*/
72011
+ true
72012
+ );
72013
+ if (restType) {
72014
+ return restType;
72015
+ }
72010
72016
  }
72011
- return void 0;
72017
+ return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
72012
72018
  }
72013
- return isGenericMappedType(t) && !t.declaration.nameType ? getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) : getTypeOfConcretePropertyOfContextualType(t) || getTypeOfApplicableIndexInfoOfContextualType(t);
72019
+ return void 0;
72014
72020
  },
72015
72021
  /*noReductions*/
72016
72022
  true
72017
72023
  );
72018
- function getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) {
72019
- const constraint = getConstraintTypeFromMappedType(t);
72020
- const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
72021
- const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
72022
- if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
72023
- return substituteIndexedMappedType(t, propertyNameType);
72024
- }
72025
- return void 0;
72026
- }
72027
- function getTypeOfConcretePropertyOfContextualType(t) {
72028
- const prop = getPropertyOfType(t, name);
72029
- if (prop) {
72030
- return isCircularMappedProperty(prop) ? void 0 : getTypeOfSymbol(prop);
72031
- }
72032
- if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
72033
- const restType = getElementTypeOfSliceOfTupleType(
72034
- t,
72035
- t.target.fixedLength,
72036
- /*endSkipCount*/
72037
- 0,
72038
- /*writing*/
72039
- false,
72040
- /*noReductions*/
72041
- true
72042
- );
72043
- if (restType) {
72044
- return restType;
72045
- }
72046
- }
72047
- return void 0;
72048
- }
72049
- function getTypeOfApplicableIndexInfoOfContextualType(t) {
72050
- var _a;
72051
- return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
72052
- }
72053
72024
  }
72054
72025
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
72055
72026
  Debug.assert(isObjectLiteralMethod(node));
@@ -79729,7 +79700,18 @@ function createTypeChecker(host) {
79729
79700
  addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
79730
79701
  function checkSignatureDeclarationDiagnostics() {
79731
79702
  checkCollisionWithArgumentsInGeneratedCode(node);
79732
- const returnTypeNode = getEffectiveReturnTypeNode(node);
79703
+ let returnTypeNode = getEffectiveReturnTypeNode(node);
79704
+ let returnTypeErrorLocation = returnTypeNode;
79705
+ if (isInJSFile(node)) {
79706
+ const typeTag = getJSDocTypeTag(node);
79707
+ if (typeTag && typeTag.typeExpression && isTypeReferenceNode(typeTag.typeExpression.type)) {
79708
+ const signature = getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
79709
+ if (signature && signature.declaration) {
79710
+ returnTypeNode = getEffectiveReturnTypeNode(signature.declaration);
79711
+ returnTypeErrorLocation = typeTag.typeExpression.type;
79712
+ }
79713
+ }
79714
+ }
79733
79715
  if (noImplicitAny && !returnTypeNode) {
79734
79716
  switch (node.kind) {
79735
79717
  case 180 /* ConstructSignature */:
@@ -79740,21 +79722,21 @@ function createTypeChecker(host) {
79740
79722
  break;
79741
79723
  }
79742
79724
  }
79743
- if (returnTypeNode) {
79725
+ if (returnTypeNode && returnTypeErrorLocation) {
79744
79726
  const functionFlags2 = getFunctionFlags(node);
79745
79727
  if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
79746
79728
  const returnType = getTypeFromTypeNode(returnTypeNode);
79747
79729
  if (returnType === voidType) {
79748
- error2(returnTypeNode, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
79730
+ error2(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
79749
79731
  } else {
79750
79732
  const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
79751
79733
  const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
79752
79734
  const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType;
79753
79735
  const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */));
79754
- checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
79736
+ checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation);
79755
79737
  }
79756
79738
  } else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) {
79757
- checkAsyncFunctionReturnType(node, returnTypeNode);
79739
+ checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation);
79758
79740
  }
79759
79741
  }
79760
79742
  if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
@@ -80836,7 +80818,7 @@ function createTypeChecker(host) {
80836
80818
  }
80837
80819
  return typeAsAwaitable.awaitedTypeOfType = type;
80838
80820
  }
80839
- function checkAsyncFunctionReturnType(node, returnTypeNode) {
80821
+ function checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation) {
80840
80822
  const returnType = getTypeFromTypeNode(returnTypeNode);
80841
80823
  if (languageVersion >= 2 /* ES2015 */) {
80842
80824
  if (isErrorType(returnType)) {
@@ -80847,7 +80829,7 @@ function createTypeChecker(host) {
80847
80829
  true
80848
80830
  );
80849
80831
  if (globalPromiseType !== emptyGenericType && !isReferenceToType2(returnType, globalPromiseType)) {
80850
- error2(returnTypeNode, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
80832
+ reportErrorForInvalidReturnType(Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, returnTypeNode, returnTypeErrorLocation, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
80851
80833
  return;
80852
80834
  }
80853
80835
  } else {
@@ -80857,7 +80839,7 @@ function createTypeChecker(host) {
80857
80839
  }
80858
80840
  const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
80859
80841
  if (promiseConstructorName === void 0) {
80860
- error2(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType));
80842
+ reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
80861
80843
  return;
80862
80844
  }
80863
80845
  const promiseConstructorSymbol = resolveEntityName(
@@ -80872,9 +80854,9 @@ function createTypeChecker(host) {
80872
80854
  /*reportErrors*/
80873
80855
  false
80874
80856
  )) {
80875
- error2(returnTypeNode, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
80857
+ error2(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
80876
80858
  } else {
80877
- error2(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName));
80859
+ reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
80878
80860
  }
80879
80861
  return;
80880
80862
  }
@@ -80883,15 +80865,16 @@ function createTypeChecker(host) {
80883
80865
  true
80884
80866
  );
80885
80867
  if (globalPromiseConstructorLikeType === emptyObjectType) {
80886
- error2(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName));
80868
+ reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
80887
80869
  return;
80888
80870
  }
80889
- if (!checkTypeAssignableTo(
80890
- promiseConstructorType,
80891
- globalPromiseConstructorLikeType,
80892
- returnTypeNode,
80893
- Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value
80894
- )) {
80871
+ const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
80872
+ const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? void 0 : chainDiagnosticMessages(
80873
+ /*details*/
80874
+ void 0,
80875
+ Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type
80876
+ );
80877
+ if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
80895
80878
  return;
80896
80879
  }
80897
80880
  const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
@@ -80913,6 +80896,14 @@ function createTypeChecker(host) {
80913
80896
  node,
80914
80897
  Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
80915
80898
  );
80899
+ function reportErrorForInvalidReturnType(message, returnTypeNode2, returnTypeErrorLocation2, typeName) {
80900
+ if (returnTypeNode2 === returnTypeErrorLocation2) {
80901
+ error2(returnTypeErrorLocation2, message, typeName);
80902
+ } else {
80903
+ const diag2 = error2(returnTypeErrorLocation2, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
80904
+ addRelatedInfo(diag2, createDiagnosticForNode(returnTypeNode2, message, typeName));
80905
+ }
80906
+ }
80916
80907
  }
80917
80908
  function checkDecorator(node) {
80918
80909
  const signature = getResolvedSignature(node);