@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/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-insiders.20230725`;
21
+ var version = `${versionMajorMinor}.0-insiders.20230726`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -5764,6 +5764,7 @@ var Diagnostics = {
5764
5764
  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."),
5765
5765
  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."),
5766
5766
  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}>'?"),
5767
+ 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."),
5767
5768
  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."),
5768
5769
  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."),
5769
5770
  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."),
@@ -53913,7 +53914,12 @@ function createTypeChecker(host) {
53913
53914
  for (const current of type.types) {
53914
53915
  for (const prop of getPropertiesOfType(current)) {
53915
53916
  if (!members.has(prop.escapedName)) {
53916
- const combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
53917
+ const combinedProp = getPropertyOfUnionOrIntersectionType(
53918
+ type,
53919
+ prop.escapedName,
53920
+ /*skipObjectFunctionPropertyAugment*/
53921
+ !!(type.flags & 2097152 /* Intersection */)
53922
+ );
53917
53923
  if (combinedProp) {
53918
53924
  members.set(prop.escapedName, combinedProp);
53919
53925
  }
@@ -54393,13 +54399,17 @@ function createTypeChecker(host) {
54393
54399
  return result;
54394
54400
  }
54395
54401
  function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
54396
- var _a, _b;
54402
+ var _a, _b, _c;
54397
54403
  let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
54398
54404
  if (!property) {
54399
54405
  property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
54400
54406
  if (property) {
54401
54407
  const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
54402
54408
  properties.set(name, property);
54409
+ if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
54410
+ const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
54411
+ properties2.set(name, property);
54412
+ }
54403
54413
  }
54404
54414
  }
54405
54415
  return property;
@@ -54519,7 +54529,22 @@ function createTypeChecker(host) {
54519
54529
  }
54520
54530
  return getPropertyOfObjectType(globalObjectType, name);
54521
54531
  }
54522
- if (type.flags & 3145728 /* UnionOrIntersection */) {
54532
+ if (type.flags & 2097152 /* Intersection */) {
54533
+ const prop = getPropertyOfUnionOrIntersectionType(
54534
+ type,
54535
+ name,
54536
+ /*skipObjectFunctionPropertyAugment*/
54537
+ true
54538
+ );
54539
+ if (prop) {
54540
+ return prop;
54541
+ }
54542
+ if (!skipObjectFunctionPropertyAugment) {
54543
+ return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
54544
+ }
54545
+ return void 0;
54546
+ }
54547
+ if (type.flags & 1048576 /* Union */) {
54523
54548
  return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
54524
54549
  }
54525
54550
  return void 0;
@@ -61158,26 +61183,6 @@ function createTypeChecker(host) {
61158
61183
  )) {
61159
61184
  return result2;
61160
61185
  }
61161
- if (sourceFlags & 8388608 /* IndexedAccess */) {
61162
- const indexType = source2.indexType;
61163
- if (indexType.flags & 4194304 /* Index */) {
61164
- const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
61165
- const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
61166
- const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
61167
- if (result2 = isRelatedTo(
61168
- constraint2,
61169
- target2,
61170
- 1 /* Source */,
61171
- /*reportErrors*/
61172
- false,
61173
- /*headMessage*/
61174
- void 0,
61175
- intersectionState
61176
- )) {
61177
- return result2;
61178
- }
61179
- }
61180
- }
61181
61186
  if (isMappedTypeGenericIndexedAccess(source2)) {
61182
61187
  const indexConstraint = getConstraintOfType(source2.indexType);
61183
61188
  if (indexConstraint) {
@@ -67272,75 +67277,41 @@ function createTypeChecker(host) {
67272
67277
  return mapType(
67273
67278
  type,
67274
67279
  (t) => {
67275
- if (!(t.flags & 3670016 /* StructuredType */)) {
67276
- return void 0;
67277
- }
67278
- if (t.flags & 2097152 /* Intersection */) {
67279
- const intersection = t;
67280
- let applicableIndexedMappedTypeSubstitions;
67281
- let concretePropertyTypes;
67282
- let applicableIndexInfoCandidates;
67283
- for (const t2 of intersection.types) {
67284
- if (isGenericMappedType(t2) && !t2.declaration.nameType) {
67285
- applicableIndexedMappedTypeSubstitions = append(applicableIndexedMappedTypeSubstitions, getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t2));
67286
- continue;
67287
- }
67288
- const typeOfConcreteProperty = getTypeOfConcretePropertyOfContextualType(t2);
67289
- if (typeOfConcreteProperty) {
67290
- concretePropertyTypes = append(concretePropertyTypes, typeOfConcreteProperty);
67291
- continue;
67292
- }
67293
- applicableIndexInfoCandidates = append(applicableIndexInfoCandidates, t2);
67294
- }
67295
- if (concretePropertyTypes) {
67296
- return getIntersectionType(concatenate(concretePropertyTypes, applicableIndexedMappedTypeSubstitions));
67280
+ var _a;
67281
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
67282
+ const constraint = getConstraintTypeFromMappedType(t);
67283
+ const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
67284
+ const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
67285
+ if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
67286
+ return substituteIndexedMappedType(t, propertyNameType);
67287
+ }
67288
+ } else if (t.flags & 3670016 /* StructuredType */) {
67289
+ const prop = getPropertyOfType(t, name);
67290
+ if (prop) {
67291
+ return isCircularMappedProperty(prop) ? void 0 : getTypeOfSymbol(prop);
67297
67292
  }
67298
- const types = concatenate(mapDefined(applicableIndexInfoCandidates, getTypeOfApplicableIndexInfoOfContextualType), applicableIndexedMappedTypeSubstitions);
67299
- if (types.length > 0) {
67300
- return getIntersectionType(types);
67293
+ if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
67294
+ const restType = getElementTypeOfSliceOfTupleType(
67295
+ t,
67296
+ t.target.fixedLength,
67297
+ /*endSkipCount*/
67298
+ 0,
67299
+ /*writing*/
67300
+ false,
67301
+ /*noReductions*/
67302
+ true
67303
+ );
67304
+ if (restType) {
67305
+ return restType;
67306
+ }
67301
67307
  }
67302
- return void 0;
67308
+ return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
67303
67309
  }
67304
- return isGenericMappedType(t) && !t.declaration.nameType ? getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) : getTypeOfConcretePropertyOfContextualType(t) || getTypeOfApplicableIndexInfoOfContextualType(t);
67310
+ return void 0;
67305
67311
  },
67306
67312
  /*noReductions*/
67307
67313
  true
67308
67314
  );
67309
- function getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) {
67310
- const constraint = getConstraintTypeFromMappedType(t);
67311
- const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
67312
- const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
67313
- if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
67314
- return substituteIndexedMappedType(t, propertyNameType);
67315
- }
67316
- return void 0;
67317
- }
67318
- function getTypeOfConcretePropertyOfContextualType(t) {
67319
- const prop = getPropertyOfType(t, name);
67320
- if (prop) {
67321
- return isCircularMappedProperty(prop) ? void 0 : getTypeOfSymbol(prop);
67322
- }
67323
- if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
67324
- const restType = getElementTypeOfSliceOfTupleType(
67325
- t,
67326
- t.target.fixedLength,
67327
- /*endSkipCount*/
67328
- 0,
67329
- /*writing*/
67330
- false,
67331
- /*noReductions*/
67332
- true
67333
- );
67334
- if (restType) {
67335
- return restType;
67336
- }
67337
- }
67338
- return void 0;
67339
- }
67340
- function getTypeOfApplicableIndexInfoOfContextualType(t) {
67341
- var _a;
67342
- return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
67343
- }
67344
67315
  }
67345
67316
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
67346
67317
  Debug.assert(isObjectLiteralMethod(node));
@@ -75020,7 +74991,18 @@ function createTypeChecker(host) {
75020
74991
  addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
75021
74992
  function checkSignatureDeclarationDiagnostics() {
75022
74993
  checkCollisionWithArgumentsInGeneratedCode(node);
75023
- const returnTypeNode = getEffectiveReturnTypeNode(node);
74994
+ let returnTypeNode = getEffectiveReturnTypeNode(node);
74995
+ let returnTypeErrorLocation = returnTypeNode;
74996
+ if (isInJSFile(node)) {
74997
+ const typeTag = getJSDocTypeTag(node);
74998
+ if (typeTag && typeTag.typeExpression && isTypeReferenceNode(typeTag.typeExpression.type)) {
74999
+ const signature = getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
75000
+ if (signature && signature.declaration) {
75001
+ returnTypeNode = getEffectiveReturnTypeNode(signature.declaration);
75002
+ returnTypeErrorLocation = typeTag.typeExpression.type;
75003
+ }
75004
+ }
75005
+ }
75024
75006
  if (noImplicitAny && !returnTypeNode) {
75025
75007
  switch (node.kind) {
75026
75008
  case 180 /* ConstructSignature */:
@@ -75031,21 +75013,21 @@ function createTypeChecker(host) {
75031
75013
  break;
75032
75014
  }
75033
75015
  }
75034
- if (returnTypeNode) {
75016
+ if (returnTypeNode && returnTypeErrorLocation) {
75035
75017
  const functionFlags2 = getFunctionFlags(node);
75036
75018
  if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
75037
75019
  const returnType = getTypeFromTypeNode(returnTypeNode);
75038
75020
  if (returnType === voidType) {
75039
- error(returnTypeNode, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
75021
+ error(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
75040
75022
  } else {
75041
75023
  const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
75042
75024
  const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
75043
75025
  const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType;
75044
75026
  const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */));
75045
- checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
75027
+ checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation);
75046
75028
  }
75047
75029
  } else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) {
75048
- checkAsyncFunctionReturnType(node, returnTypeNode);
75030
+ checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation);
75049
75031
  }
75050
75032
  }
75051
75033
  if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
@@ -76127,7 +76109,7 @@ function createTypeChecker(host) {
76127
76109
  }
76128
76110
  return typeAsAwaitable.awaitedTypeOfType = type;
76129
76111
  }
76130
- function checkAsyncFunctionReturnType(node, returnTypeNode) {
76112
+ function checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation) {
76131
76113
  const returnType = getTypeFromTypeNode(returnTypeNode);
76132
76114
  if (languageVersion >= 2 /* ES2015 */) {
76133
76115
  if (isErrorType(returnType)) {
@@ -76138,7 +76120,7 @@ function createTypeChecker(host) {
76138
76120
  true
76139
76121
  );
76140
76122
  if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
76141
- error(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));
76123
+ 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));
76142
76124
  return;
76143
76125
  }
76144
76126
  } else {
@@ -76148,7 +76130,7 @@ function createTypeChecker(host) {
76148
76130
  }
76149
76131
  const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
76150
76132
  if (promiseConstructorName === void 0) {
76151
- error(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));
76133
+ 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));
76152
76134
  return;
76153
76135
  }
76154
76136
  const promiseConstructorSymbol = resolveEntityName(
@@ -76163,9 +76145,9 @@ function createTypeChecker(host) {
76163
76145
  /*reportErrors*/
76164
76146
  false
76165
76147
  )) {
76166
- error(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);
76148
+ error(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);
76167
76149
  } else {
76168
- error(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));
76150
+ 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));
76169
76151
  }
76170
76152
  return;
76171
76153
  }
@@ -76174,15 +76156,16 @@ function createTypeChecker(host) {
76174
76156
  true
76175
76157
  );
76176
76158
  if (globalPromiseConstructorLikeType === emptyObjectType) {
76177
- error(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));
76159
+ 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));
76178
76160
  return;
76179
76161
  }
76180
- if (!checkTypeAssignableTo(
76181
- promiseConstructorType,
76182
- globalPromiseConstructorLikeType,
76183
- returnTypeNode,
76184
- 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
76185
- )) {
76162
+ 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;
76163
+ const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? void 0 : chainDiagnosticMessages(
76164
+ /*details*/
76165
+ void 0,
76166
+ Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type
76167
+ );
76168
+ if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
76186
76169
  return;
76187
76170
  }
76188
76171
  const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
@@ -76204,6 +76187,14 @@ function createTypeChecker(host) {
76204
76187
  node,
76205
76188
  Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
76206
76189
  );
76190
+ function reportErrorForInvalidReturnType(message, returnTypeNode2, returnTypeErrorLocation2, typeName) {
76191
+ if (returnTypeNode2 === returnTypeErrorLocation2) {
76192
+ error(returnTypeErrorLocation2, message, typeName);
76193
+ } else {
76194
+ const diag2 = error(returnTypeErrorLocation2, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
76195
+ addRelatedInfo(diag2, createDiagnosticForNode(returnTypeNode2, message, typeName));
76196
+ }
76197
+ }
76207
76198
  }
76208
76199
  function checkDecorator(node) {
76209
76200
  const signature = getResolvedSignature(node);