typescript 5.4.0-dev.20231119 → 5.4.0-dev.20231121

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.4";
21
- var version = `${versionMajorMinor}.0-dev.20231119`;
21
+ var version = `${versionMajorMinor}.0-dev.20231121`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -972,23 +972,6 @@ function compareStringsCaseSensitive(a, b) {
972
972
  function getStringComparer(ignoreCase) {
973
973
  return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
974
974
  }
975
- var createUIStringComparer = (() => {
976
- return createIntlCollatorStringComparer;
977
- function compareWithCallback(a, b, comparer) {
978
- if (a === b)
979
- return 0 /* EqualTo */;
980
- if (a === void 0)
981
- return -1 /* LessThan */;
982
- if (b === void 0)
983
- return 1 /* GreaterThan */;
984
- const value = comparer(a, b);
985
- return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */;
986
- }
987
- function createIntlCollatorStringComparer(locale) {
988
- const comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
989
- return (a, b) => compareWithCallback(a, b, comparer);
990
- }
991
- })();
992
975
  var uiComparerCaseSensitive;
993
976
  var uiLocale;
994
977
  function setUILocale(value) {
@@ -3678,7 +3661,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3678
3661
  TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
3679
3662
  TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
3680
3663
  TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
3681
- TypeFlags2[TypeFlags2["ObjectFlagsType"] = 138117121] = "ObjectFlagsType";
3664
+ TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
3682
3665
  TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
3683
3666
  TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
3684
3667
  TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
@@ -5952,6 +5935,10 @@ var Diagnostics = {
5952
5935
  ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled: diag(1286, 1 /* Error */, "ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled_1286", "ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled."),
5953
5936
  A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled: diag(1287, 1 /* Error */, "A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimM_1287", "A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled."),
5954
5937
  An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabled: diag(1288, 1 /* Error */, "An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabl_1288", "An import alias cannot resolve to a type or type-only declaration when 'verbatimModuleSyntax' is enabled."),
5938
+ _0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1289, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1289", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
5939
+ _0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1290, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1290", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
5940
+ _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1291, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
5941
+ _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1292, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
5955
5942
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
5956
5943
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
5957
5944
  The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
@@ -15987,7 +15974,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
15987
15974
  return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
15988
15975
  }
15989
15976
  function getObjectFlags(type) {
15990
- return type.flags & 138117121 /* ObjectFlagsType */ ? type.objectFlags : 0;
15977
+ return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
15991
15978
  }
15992
15979
  function isUMDExportSymbol(symbol) {
15993
15980
  return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
@@ -54214,7 +54201,12 @@ function createTypeChecker(host) {
54214
54201
  const checkType = type.checkType;
54215
54202
  const constraint = getLowerBoundOfKeyType(checkType);
54216
54203
  if (constraint !== checkType) {
54217
- return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54204
+ return getConditionalTypeInstantiation(
54205
+ type,
54206
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
54207
+ /*forConstraint*/
54208
+ false
54209
+ );
54218
54210
  }
54219
54211
  }
54220
54212
  return type;
@@ -54566,7 +54558,12 @@ function createTypeChecker(host) {
54566
54558
  );
54567
54559
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
54568
54560
  if (constraint && constraint !== type.checkType) {
54569
- const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54561
+ const instantiated = getConditionalTypeInstantiation(
54562
+ type,
54563
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
54564
+ /*forConstraint*/
54565
+ true
54566
+ );
54570
54567
  if (!(instantiated.flags & 131072 /* Never */)) {
54571
54568
  type.resolvedConstraintOfDistributive = instantiated;
54572
54569
  return instantiated;
@@ -57000,7 +56997,7 @@ function createTypeChecker(host) {
57000
56997
  }
57001
56998
  }
57002
56999
  function removeStringLiteralsMatchedByTemplateLiterals(types) {
57003
- const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t) && t.types.every((t2) => !(t2.flags & 2097152 /* Intersection */) || !areIntersectedTypesAvoidingPrimitiveReduction(t2.types)));
57000
+ const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t));
57004
57001
  if (templates.length) {
57005
57002
  let i = types.length;
57006
57003
  while (i > 0) {
@@ -57400,19 +57397,14 @@ function createTypeChecker(host) {
57400
57397
  function getConstituentCountOfTypes(types) {
57401
57398
  return reduceLeft(types, (n, t) => n + getConstituentCount(t), 0);
57402
57399
  }
57403
- function areIntersectedTypesAvoidingPrimitiveReduction(types, primitiveFlags = 4 /* String */ | 8 /* Number */ | 64 /* BigInt */) {
57404
- if (types.length !== 2) {
57405
- return false;
57406
- }
57407
- const [t1, t2] = types;
57408
- return !!(t1.flags & primitiveFlags) && t2 === emptyTypeLiteralType || !!(t2.flags & primitiveFlags) && t1 === emptyTypeLiteralType;
57409
- }
57410
57400
  function getTypeFromIntersectionTypeNode(node) {
57411
57401
  const links = getNodeLinks(node);
57412
57402
  if (!links.resolvedType) {
57413
57403
  const aliasSymbol = getAliasSymbolForTypeNode(node);
57414
57404
  const types = map(node.types, getTypeFromTypeNode);
57415
- const noSupertypeReduction = areIntersectedTypesAvoidingPrimitiveReduction(types);
57405
+ const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
57406
+ const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
57407
+ const noSupertypeReduction = !!(t.flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
57416
57408
  links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
57417
57409
  }
57418
57410
  return links.resolvedType;
@@ -57439,19 +57431,17 @@ function createTypeChecker(host) {
57439
57431
  return constraintType;
57440
57432
  }
57441
57433
  const keyTypes = [];
57442
- if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
57443
- if (!isGenericIndexType(constraintType)) {
57444
- const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
57445
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
57446
- } else {
57434
+ if (isGenericIndexType(constraintType)) {
57435
+ if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
57447
57436
  return getIndexTypeForGenericType(type, indexFlags);
57448
57437
  }
57438
+ forEachType(constraintType, addMemberForKeyType);
57439
+ } else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
57440
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
57441
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
57449
57442
  } else {
57450
57443
  forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
57451
57444
  }
57452
- if (isGenericIndexType(constraintType)) {
57453
- forEachType(constraintType, addMemberForKeyType);
57454
- }
57455
57445
  const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 4 /* String */))) : getUnionType(keyTypes);
57456
57446
  if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
57457
57447
  return constraintType;
@@ -57624,11 +57614,6 @@ function createTypeChecker(host) {
57624
57614
  }
57625
57615
  function createTemplateLiteralType(texts, types) {
57626
57616
  const type = createType(134217728 /* TemplateLiteral */);
57627
- type.objectFlags = getPropagatingFlagsOfTypes(
57628
- types,
57629
- /*excludeKinds*/
57630
- 98304 /* Nullable */
57631
- );
57632
57617
  type.texts = texts;
57633
57618
  type.types = types;
57634
57619
  return type;
@@ -57923,7 +57908,15 @@ function createTypeChecker(host) {
57923
57908
  }
57924
57909
  function isPatternLiteralPlaceholderType(type) {
57925
57910
  if (type.flags & 2097152 /* Intersection */) {
57926
- return !isGenericType(type) && some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 98304 /* Nullable */)) || isPatternLiteralPlaceholderType(t));
57911
+ let seenPlaceholder = false;
57912
+ for (const t of type.types) {
57913
+ if (t.flags & (2944 /* Literal */ | 98304 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
57914
+ seenPlaceholder = true;
57915
+ } else if (!(t.flags & 524288 /* Object */)) {
57916
+ return false;
57917
+ }
57918
+ }
57919
+ return seenPlaceholder;
57927
57920
  }
57928
57921
  return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
57929
57922
  }
@@ -57940,7 +57933,7 @@ function createTypeChecker(host) {
57940
57933
  return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */);
57941
57934
  }
57942
57935
  function getGenericObjectFlags(type) {
57943
- if (type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */)) {
57936
+ if (type.flags & 3145728 /* UnionOrIntersection */) {
57944
57937
  if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) {
57945
57938
  type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | reduceLeft(type.types, (flags, t) => flags | getGenericObjectFlags(t), 0);
57946
57939
  }
@@ -57952,7 +57945,7 @@ function createTypeChecker(host) {
57952
57945
  }
57953
57946
  return type.objectFlags & 12582912 /* IsGenericType */;
57954
57947
  }
57955
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
57948
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
57956
57949
  }
57957
57950
  function getSimplifiedType(type, writing) {
57958
57951
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -58133,7 +58126,7 @@ function createTypeChecker(host) {
58133
58126
  function isDeferredType(type, checkTuples) {
58134
58127
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
58135
58128
  }
58136
- function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
58129
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
58137
58130
  let result;
58138
58131
  let extraTypes;
58139
58132
  let tailCount = 0;
@@ -58179,7 +58172,7 @@ function createTypeChecker(host) {
58179
58172
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
58180
58173
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
58181
58174
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
58182
- if (checkType.flags & 1 /* Any */) {
58175
+ if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
58183
58176
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
58184
58177
  }
58185
58178
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -58289,7 +58282,9 @@ function createTypeChecker(host) {
58289
58282
  links.resolvedType = getConditionalType(
58290
58283
  root,
58291
58284
  /*mapper*/
58292
- void 0
58285
+ void 0,
58286
+ /*forConstraint*/
58287
+ false
58293
58288
  );
58294
58289
  if (outerTypeParameters) {
58295
58290
  root.instantiations = /* @__PURE__ */ new Map();
@@ -58978,7 +58973,7 @@ function createTypeChecker(host) {
58978
58973
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
58979
58974
  target.instantiations.set(id, result);
58980
58975
  const resultObjectFlags = getObjectFlags(result);
58981
- if (result.flags & 138117121 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
58976
+ if (result.flags & 3899393 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
58982
58977
  const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
58983
58978
  if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
58984
58979
  if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
@@ -59144,17 +59139,17 @@ function createTypeChecker(host) {
59144
59139
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
59145
59140
  return result;
59146
59141
  }
59147
- function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
59142
+ function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
59148
59143
  const root = type.root;
59149
59144
  if (root.outerTypeParameters) {
59150
59145
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
59151
- const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
59146
+ const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
59152
59147
  let result = root.instantiations.get(id);
59153
59148
  if (!result) {
59154
59149
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
59155
59150
  const checkType = root.checkType;
59156
59151
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
59157
- result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments);
59152
+ result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
59158
59153
  root.instantiations.set(id, result);
59159
59154
  }
59160
59155
  return result;
@@ -59242,7 +59237,14 @@ function createTypeChecker(host) {
59242
59237
  );
59243
59238
  }
59244
59239
  if (flags & 16777216 /* Conditional */) {
59245
- return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
59240
+ return getConditionalTypeInstantiation(
59241
+ type,
59242
+ combineTypeMappers(type.mapper, mapper),
59243
+ /*forConstraint*/
59244
+ false,
59245
+ aliasSymbol,
59246
+ aliasTypeArguments
59247
+ );
59246
59248
  }
59247
59249
  if (flags & 33554432 /* Substitution */) {
59248
59250
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -60886,7 +60888,7 @@ function createTypeChecker(host) {
60886
60888
  return relation === comparableRelation ? someTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState) : eachTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState);
60887
60889
  }
60888
60890
  if (target2.flags & 1048576 /* Union */) {
60889
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */));
60891
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */), intersectionState);
60890
60892
  }
60891
60893
  if (target2.flags & 2097152 /* Intersection */) {
60892
60894
  return typeRelatedToEachType(source2, target2, reportErrors2, 2 /* Target */);
@@ -60931,7 +60933,8 @@ function createTypeChecker(host) {
60931
60933
  sourceType,
60932
60934
  target2,
60933
60935
  /*reportErrors*/
60934
- false
60936
+ false,
60937
+ 0 /* None */
60935
60938
  );
60936
60939
  if (!related) {
60937
60940
  return 0 /* False */;
@@ -60940,7 +60943,7 @@ function createTypeChecker(host) {
60940
60943
  }
60941
60944
  return result2;
60942
60945
  }
60943
- function typeRelatedToSomeType(source2, target2, reportErrors2) {
60946
+ function typeRelatedToSomeType(source2, target2, reportErrors2, intersectionState) {
60944
60947
  const targetTypes = target2.types;
60945
60948
  if (target2.flags & 1048576 /* Union */) {
60946
60949
  if (containsType(targetTypes, source2)) {
@@ -60958,7 +60961,10 @@ function createTypeChecker(host) {
60958
60961
  match,
60959
60962
  2 /* Target */,
60960
60963
  /*reportErrors*/
60961
- false
60964
+ false,
60965
+ /*headMessage*/
60966
+ void 0,
60967
+ intersectionState
60962
60968
  );
60963
60969
  if (related) {
60964
60970
  return related;
@@ -60971,7 +60977,10 @@ function createTypeChecker(host) {
60971
60977
  type,
60972
60978
  2 /* Target */,
60973
60979
  /*reportErrors*/
60974
- false
60980
+ false,
60981
+ /*headMessage*/
60982
+ void 0,
60983
+ intersectionState
60975
60984
  );
60976
60985
  if (related) {
60977
60986
  return related;
@@ -60985,7 +60994,10 @@ function createTypeChecker(host) {
60985
60994
  bestMatchingType,
60986
60995
  2 /* Target */,
60987
60996
  /*reportErrors*/
60988
- true
60997
+ true,
60998
+ /*headMessage*/
60999
+ void 0,
61000
+ intersectionState
60989
61001
  );
60990
61002
  }
60991
61003
  }
@@ -61783,13 +61795,6 @@ function createTypeChecker(host) {
61783
61795
  return result2;
61784
61796
  }
61785
61797
  }
61786
- } else {
61787
- const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61788
- if (distributiveConstraint) {
61789
- if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61790
- return result2;
61791
- }
61792
- }
61793
61798
  }
61794
61799
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
61795
61800
  if (defaultConstraint) {
@@ -61797,6 +61802,13 @@ function createTypeChecker(host) {
61797
61802
  return result2;
61798
61803
  }
61799
61804
  }
61805
+ const distributiveConstraint = !(targetFlags & 16777216 /* Conditional */) && hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61806
+ if (distributiveConstraint) {
61807
+ resetErrorInfo(saveErrorInfo);
61808
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61809
+ return result2;
61810
+ }
61811
+ }
61800
61812
  } else {
61801
61813
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
61802
61814
  return -1 /* True */;
@@ -63694,8 +63706,8 @@ function createTypeChecker(host) {
63694
63706
  if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
63695
63707
  return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
63696
63708
  }
63697
- const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
63698
- if (type.flags & 138117121 /* ObjectFlagsType */) {
63709
+ const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
63710
+ if (type.flags & 3899393 /* ObjectFlagsType */) {
63699
63711
  type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
63700
63712
  }
63701
63713
  return result;
@@ -80668,10 +80680,11 @@ function createTypeChecker(host) {
80668
80680
  node
80669
80681
  ));
80670
80682
  if (sym) {
80683
+ const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(sym, 111551 /* Value */);
80671
80684
  markAliasReferenced(sym, id);
80672
80685
  if (getSymbolFlags(sym) & 111551 /* Value */) {
80673
80686
  checkExpressionCached(id);
80674
- if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
80687
+ if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && typeOnlyDeclaration) {
80675
80688
  error(
80676
80689
  id,
80677
80690
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
@@ -80685,6 +80698,33 @@ function createTypeChecker(host) {
80685
80698
  idText(id)
80686
80699
  );
80687
80700
  }
80701
+ if (!isIllegalExportDefaultInCJS && getIsolatedModules(compilerOptions) && !(sym.flags & 111551 /* Value */)) {
80702
+ if (sym.flags & 2097152 /* Alias */ && resolveAlias(sym) !== unknownSymbol && getSymbolFlags(
80703
+ sym,
80704
+ /*excludeTypeOnlyMeanings*/
80705
+ false,
80706
+ /*excludeLocalMeanings*/
80707
+ true
80708
+ ) & 788968 /* Type */ && (!typeOnlyDeclaration || getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node))) {
80709
+ error(
80710
+ id,
80711
+ node.isExportEquals ? Diagnostics._0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported : Diagnostics._0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default,
80712
+ idText(id),
80713
+ isolatedModulesLikeFlagName
80714
+ );
80715
+ } else if (typeOnlyDeclaration && getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node)) {
80716
+ addTypeOnlyDeclarationRelatedInfo(
80717
+ error(
80718
+ id,
80719
+ node.isExportEquals ? Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported : Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default,
80720
+ idText(id),
80721
+ isolatedModulesLikeFlagName
80722
+ ),
80723
+ typeOnlyDeclaration,
80724
+ idText(id)
80725
+ );
80726
+ }
80727
+ }
80688
80728
  } else {
80689
80729
  checkExpressionCached(id);
80690
80730
  }
@@ -82079,7 +82119,11 @@ function createTypeChecker(host) {
82079
82119
  const exportClause = node.exportClause;
82080
82120
  return !!exportClause && (isNamespaceExport(exportClause) || some(exportClause.elements, isValueAliasDeclaration));
82081
82121
  case 277 /* ExportAssignment */:
82082
- return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfDeclaration(node)) : true;
82122
+ return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(
82123
+ getSymbolOfDeclaration(node),
82124
+ /*excludeTypeOnlyValues*/
82125
+ true
82126
+ ) : true;
82083
82127
  }
82084
82128
  return false;
82085
82129
  }