typescript 5.4.0-dev.20231120 → 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/tsserver.js CHANGED
@@ -724,6 +724,7 @@ __export(server_exports, {
724
724
  getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
725
725
  getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
726
726
  getDocumentPositionMapper: () => getDocumentPositionMapper,
727
+ getDocumentSpansEqualityComparer: () => getDocumentSpansEqualityComparer,
727
728
  getESModuleInterop: () => getESModuleInterop,
728
729
  getEditsForFileRename: () => getEditsForFileRename,
729
730
  getEffectiveBaseTypeNode: () => getEffectiveBaseTypeNode,
@@ -2330,7 +2331,7 @@ module.exports = __toCommonJS(server_exports);
2330
2331
 
2331
2332
  // src/compiler/corePublic.ts
2332
2333
  var versionMajorMinor = "5.4";
2333
- var version = `${versionMajorMinor}.0-dev.20231120`;
2334
+ var version = `${versionMajorMinor}.0-dev.20231121`;
2334
2335
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2335
2336
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2336
2337
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6674,7 +6675,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
6674
6675
  TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
6675
6676
  TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
6676
6677
  TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
6677
- TypeFlags2[TypeFlags2["ObjectFlagsType"] = 138117121] = "ObjectFlagsType";
6678
+ TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
6678
6679
  TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
6679
6680
  TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
6680
6681
  TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
@@ -9484,6 +9485,10 @@ var Diagnostics = {
9484
9485
  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."),
9485
9486
  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."),
9486
9487
  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."),
9488
+ _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."),
9489
+ _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 }'."),
9490
+ _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."),
9491
+ _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 }'."),
9487
9492
  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."),
9488
9493
  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."),
9489
9494
  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."),
@@ -20056,7 +20061,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
20056
20061
  return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
20057
20062
  }
20058
20063
  function getObjectFlags(type) {
20059
- return type.flags & 138117121 /* ObjectFlagsType */ ? type.objectFlags : 0;
20064
+ return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
20060
20065
  }
20061
20066
  function forSomeAncestorDirectory(directory, callback) {
20062
20067
  return !!forEachAncestorDirectory(directory, (d) => callback(d) ? true : void 0);
@@ -58922,7 +58927,12 @@ function createTypeChecker(host) {
58922
58927
  const checkType = type.checkType;
58923
58928
  const constraint = getLowerBoundOfKeyType(checkType);
58924
58929
  if (constraint !== checkType) {
58925
- return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
58930
+ return getConditionalTypeInstantiation(
58931
+ type,
58932
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
58933
+ /*forConstraint*/
58934
+ false
58935
+ );
58926
58936
  }
58927
58937
  }
58928
58938
  return type;
@@ -59274,7 +59284,12 @@ function createTypeChecker(host) {
59274
59284
  );
59275
59285
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
59276
59286
  if (constraint && constraint !== type.checkType) {
59277
- const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
59287
+ const instantiated = getConditionalTypeInstantiation(
59288
+ type,
59289
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
59290
+ /*forConstraint*/
59291
+ true
59292
+ );
59278
59293
  if (!(instantiated.flags & 131072 /* Never */)) {
59279
59294
  type.resolvedConstraintOfDistributive = instantiated;
59280
59295
  return instantiated;
@@ -61708,7 +61723,7 @@ function createTypeChecker(host) {
61708
61723
  }
61709
61724
  }
61710
61725
  function removeStringLiteralsMatchedByTemplateLiterals(types) {
61711
- const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t) && t.types.every((t2) => !(t2.flags & 2097152 /* Intersection */) || !areIntersectedTypesAvoidingPrimitiveReduction(t2.types)));
61726
+ const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t));
61712
61727
  if (templates.length) {
61713
61728
  let i = types.length;
61714
61729
  while (i > 0) {
@@ -62108,19 +62123,14 @@ function createTypeChecker(host) {
62108
62123
  function getConstituentCountOfTypes(types) {
62109
62124
  return reduceLeft(types, (n, t) => n + getConstituentCount(t), 0);
62110
62125
  }
62111
- function areIntersectedTypesAvoidingPrimitiveReduction(types, primitiveFlags = 4 /* String */ | 8 /* Number */ | 64 /* BigInt */) {
62112
- if (types.length !== 2) {
62113
- return false;
62114
- }
62115
- const [t1, t2] = types;
62116
- return !!(t1.flags & primitiveFlags) && t2 === emptyTypeLiteralType || !!(t2.flags & primitiveFlags) && t1 === emptyTypeLiteralType;
62117
- }
62118
62126
  function getTypeFromIntersectionTypeNode(node) {
62119
62127
  const links = getNodeLinks(node);
62120
62128
  if (!links.resolvedType) {
62121
62129
  const aliasSymbol = getAliasSymbolForTypeNode(node);
62122
62130
  const types = map(node.types, getTypeFromTypeNode);
62123
- const noSupertypeReduction = areIntersectedTypesAvoidingPrimitiveReduction(types);
62131
+ const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
62132
+ const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
62133
+ const noSupertypeReduction = !!(t.flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
62124
62134
  links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
62125
62135
  }
62126
62136
  return links.resolvedType;
@@ -62147,19 +62157,17 @@ function createTypeChecker(host) {
62147
62157
  return constraintType;
62148
62158
  }
62149
62159
  const keyTypes = [];
62150
- if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
62151
- if (!isGenericIndexType(constraintType)) {
62152
- const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
62153
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
62154
- } else {
62160
+ if (isGenericIndexType(constraintType)) {
62161
+ if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
62155
62162
  return getIndexTypeForGenericType(type, indexFlags);
62156
62163
  }
62164
+ forEachType(constraintType, addMemberForKeyType);
62165
+ } else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
62166
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
62167
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
62157
62168
  } else {
62158
62169
  forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
62159
62170
  }
62160
- if (isGenericIndexType(constraintType)) {
62161
- forEachType(constraintType, addMemberForKeyType);
62162
- }
62163
62171
  const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 4 /* String */))) : getUnionType(keyTypes);
62164
62172
  if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
62165
62173
  return constraintType;
@@ -62332,11 +62340,6 @@ function createTypeChecker(host) {
62332
62340
  }
62333
62341
  function createTemplateLiteralType(texts, types) {
62334
62342
  const type = createType(134217728 /* TemplateLiteral */);
62335
- type.objectFlags = getPropagatingFlagsOfTypes(
62336
- types,
62337
- /*excludeKinds*/
62338
- 98304 /* Nullable */
62339
- );
62340
62343
  type.texts = texts;
62341
62344
  type.types = types;
62342
62345
  return type;
@@ -62631,7 +62634,15 @@ function createTypeChecker(host) {
62631
62634
  }
62632
62635
  function isPatternLiteralPlaceholderType(type) {
62633
62636
  if (type.flags & 2097152 /* Intersection */) {
62634
- return !isGenericType(type) && some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 98304 /* Nullable */)) || isPatternLiteralPlaceholderType(t));
62637
+ let seenPlaceholder = false;
62638
+ for (const t of type.types) {
62639
+ if (t.flags & (2944 /* Literal */ | 98304 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
62640
+ seenPlaceholder = true;
62641
+ } else if (!(t.flags & 524288 /* Object */)) {
62642
+ return false;
62643
+ }
62644
+ }
62645
+ return seenPlaceholder;
62635
62646
  }
62636
62647
  return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
62637
62648
  }
@@ -62648,7 +62659,7 @@ function createTypeChecker(host) {
62648
62659
  return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */);
62649
62660
  }
62650
62661
  function getGenericObjectFlags(type) {
62651
- if (type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */)) {
62662
+ if (type.flags & 3145728 /* UnionOrIntersection */) {
62652
62663
  if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) {
62653
62664
  type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | reduceLeft(type.types, (flags, t) => flags | getGenericObjectFlags(t), 0);
62654
62665
  }
@@ -62660,7 +62671,7 @@ function createTypeChecker(host) {
62660
62671
  }
62661
62672
  return type.objectFlags & 12582912 /* IsGenericType */;
62662
62673
  }
62663
- 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);
62674
+ 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);
62664
62675
  }
62665
62676
  function getSimplifiedType(type, writing) {
62666
62677
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -62841,7 +62852,7 @@ function createTypeChecker(host) {
62841
62852
  function isDeferredType(type, checkTuples) {
62842
62853
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
62843
62854
  }
62844
- function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
62855
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
62845
62856
  let result;
62846
62857
  let extraTypes;
62847
62858
  let tailCount = 0;
@@ -62887,7 +62898,7 @@ function createTypeChecker(host) {
62887
62898
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
62888
62899
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
62889
62900
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
62890
- if (checkType.flags & 1 /* Any */) {
62901
+ if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
62891
62902
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
62892
62903
  }
62893
62904
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -62997,7 +63008,9 @@ function createTypeChecker(host) {
62997
63008
  links.resolvedType = getConditionalType(
62998
63009
  root,
62999
63010
  /*mapper*/
63000
- void 0
63011
+ void 0,
63012
+ /*forConstraint*/
63013
+ false
63001
63014
  );
63002
63015
  if (outerTypeParameters) {
63003
63016
  root.instantiations = /* @__PURE__ */ new Map();
@@ -63686,7 +63699,7 @@ function createTypeChecker(host) {
63686
63699
  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);
63687
63700
  target.instantiations.set(id, result);
63688
63701
  const resultObjectFlags = getObjectFlags(result);
63689
- if (result.flags & 138117121 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
63702
+ if (result.flags & 3899393 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
63690
63703
  const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
63691
63704
  if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
63692
63705
  if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
@@ -63852,17 +63865,17 @@ function createTypeChecker(host) {
63852
63865
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
63853
63866
  return result;
63854
63867
  }
63855
- function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
63868
+ function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
63856
63869
  const root = type.root;
63857
63870
  if (root.outerTypeParameters) {
63858
63871
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
63859
- const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63872
+ const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63860
63873
  let result = root.instantiations.get(id);
63861
63874
  if (!result) {
63862
63875
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
63863
63876
  const checkType = root.checkType;
63864
63877
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
63865
- 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);
63878
+ 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);
63866
63879
  root.instantiations.set(id, result);
63867
63880
  }
63868
63881
  return result;
@@ -63950,7 +63963,14 @@ function createTypeChecker(host) {
63950
63963
  );
63951
63964
  }
63952
63965
  if (flags & 16777216 /* Conditional */) {
63953
- return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
63966
+ return getConditionalTypeInstantiation(
63967
+ type,
63968
+ combineTypeMappers(type.mapper, mapper),
63969
+ /*forConstraint*/
63970
+ false,
63971
+ aliasSymbol,
63972
+ aliasTypeArguments
63973
+ );
63954
63974
  }
63955
63975
  if (flags & 33554432 /* Substitution */) {
63956
63976
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -65594,7 +65614,7 @@ function createTypeChecker(host) {
65594
65614
  return relation === comparableRelation ? someTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState) : eachTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState);
65595
65615
  }
65596
65616
  if (target2.flags & 1048576 /* Union */) {
65597
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */));
65617
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */), intersectionState);
65598
65618
  }
65599
65619
  if (target2.flags & 2097152 /* Intersection */) {
65600
65620
  return typeRelatedToEachType(source2, target2, reportErrors2, 2 /* Target */);
@@ -65639,7 +65659,8 @@ function createTypeChecker(host) {
65639
65659
  sourceType,
65640
65660
  target2,
65641
65661
  /*reportErrors*/
65642
- false
65662
+ false,
65663
+ 0 /* None */
65643
65664
  );
65644
65665
  if (!related) {
65645
65666
  return 0 /* False */;
@@ -65648,7 +65669,7 @@ function createTypeChecker(host) {
65648
65669
  }
65649
65670
  return result2;
65650
65671
  }
65651
- function typeRelatedToSomeType(source2, target2, reportErrors2) {
65672
+ function typeRelatedToSomeType(source2, target2, reportErrors2, intersectionState) {
65652
65673
  const targetTypes = target2.types;
65653
65674
  if (target2.flags & 1048576 /* Union */) {
65654
65675
  if (containsType(targetTypes, source2)) {
@@ -65666,7 +65687,10 @@ function createTypeChecker(host) {
65666
65687
  match,
65667
65688
  2 /* Target */,
65668
65689
  /*reportErrors*/
65669
- false
65690
+ false,
65691
+ /*headMessage*/
65692
+ void 0,
65693
+ intersectionState
65670
65694
  );
65671
65695
  if (related) {
65672
65696
  return related;
@@ -65679,7 +65703,10 @@ function createTypeChecker(host) {
65679
65703
  type,
65680
65704
  2 /* Target */,
65681
65705
  /*reportErrors*/
65682
- false
65706
+ false,
65707
+ /*headMessage*/
65708
+ void 0,
65709
+ intersectionState
65683
65710
  );
65684
65711
  if (related) {
65685
65712
  return related;
@@ -65693,7 +65720,10 @@ function createTypeChecker(host) {
65693
65720
  bestMatchingType,
65694
65721
  2 /* Target */,
65695
65722
  /*reportErrors*/
65696
- true
65723
+ true,
65724
+ /*headMessage*/
65725
+ void 0,
65726
+ intersectionState
65697
65727
  );
65698
65728
  }
65699
65729
  }
@@ -66491,13 +66521,6 @@ function createTypeChecker(host) {
66491
66521
  return result2;
66492
66522
  }
66493
66523
  }
66494
- } else {
66495
- const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
66496
- if (distributiveConstraint) {
66497
- if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
66498
- return result2;
66499
- }
66500
- }
66501
66524
  }
66502
66525
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
66503
66526
  if (defaultConstraint) {
@@ -66505,6 +66528,13 @@ function createTypeChecker(host) {
66505
66528
  return result2;
66506
66529
  }
66507
66530
  }
66531
+ const distributiveConstraint = !(targetFlags & 16777216 /* Conditional */) && hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
66532
+ if (distributiveConstraint) {
66533
+ resetErrorInfo(saveErrorInfo);
66534
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
66535
+ return result2;
66536
+ }
66537
+ }
66508
66538
  } else {
66509
66539
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
66510
66540
  return -1 /* True */;
@@ -68402,8 +68432,8 @@ function createTypeChecker(host) {
68402
68432
  if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
68403
68433
  return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
68404
68434
  }
68405
- 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));
68406
- if (type.flags & 138117121 /* ObjectFlagsType */) {
68435
+ 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));
68436
+ if (type.flags & 3899393 /* ObjectFlagsType */) {
68407
68437
  type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
68408
68438
  }
68409
68439
  return result;
@@ -85376,10 +85406,11 @@ function createTypeChecker(host) {
85376
85406
  node
85377
85407
  ));
85378
85408
  if (sym) {
85409
+ const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(sym, 111551 /* Value */);
85379
85410
  markAliasReferenced(sym, id);
85380
85411
  if (getSymbolFlags(sym) & 111551 /* Value */) {
85381
85412
  checkExpressionCached(id);
85382
- if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
85413
+ if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && typeOnlyDeclaration) {
85383
85414
  error2(
85384
85415
  id,
85385
85416
  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,
@@ -85393,6 +85424,33 @@ function createTypeChecker(host) {
85393
85424
  idText(id)
85394
85425
  );
85395
85426
  }
85427
+ if (!isIllegalExportDefaultInCJS && getIsolatedModules(compilerOptions) && !(sym.flags & 111551 /* Value */)) {
85428
+ if (sym.flags & 2097152 /* Alias */ && resolveAlias(sym) !== unknownSymbol && getSymbolFlags(
85429
+ sym,
85430
+ /*excludeTypeOnlyMeanings*/
85431
+ false,
85432
+ /*excludeLocalMeanings*/
85433
+ true
85434
+ ) & 788968 /* Type */ && (!typeOnlyDeclaration || getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node))) {
85435
+ error2(
85436
+ id,
85437
+ 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,
85438
+ idText(id),
85439
+ isolatedModulesLikeFlagName
85440
+ );
85441
+ } else if (typeOnlyDeclaration && getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node)) {
85442
+ addTypeOnlyDeclarationRelatedInfo(
85443
+ error2(
85444
+ id,
85445
+ 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,
85446
+ idText(id),
85447
+ isolatedModulesLikeFlagName
85448
+ ),
85449
+ typeOnlyDeclaration,
85450
+ idText(id)
85451
+ );
85452
+ }
85453
+ }
85396
85454
  } else {
85397
85455
  checkExpressionCached(id);
85398
85456
  }
@@ -86787,7 +86845,11 @@ function createTypeChecker(host) {
86787
86845
  const exportClause = node.exportClause;
86788
86846
  return !!exportClause && (isNamespaceExport(exportClause) || some(exportClause.elements, isValueAliasDeclaration));
86789
86847
  case 277 /* ExportAssignment */:
86790
- return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfDeclaration(node)) : true;
86848
+ return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(
86849
+ getSymbolOfDeclaration(node),
86850
+ /*excludeTypeOnlyValues*/
86851
+ true
86852
+ ) : true;
86791
86853
  }
86792
86854
  return false;
86793
86855
  }
@@ -133172,8 +133234,11 @@ function getTypeKeywordOfTypeOnlyImport(importClause, sourceFile) {
133172
133234
  function textSpansEqual(a, b) {
133173
133235
  return !!a && !!b && a.start === b.start && a.length === b.length;
133174
133236
  }
133175
- function documentSpansEqual(a, b) {
133176
- return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan);
133237
+ function documentSpansEqual(a, b, useCaseSensitiveFileNames2) {
133238
+ return (useCaseSensitiveFileNames2 ? equateStringsCaseSensitive : equateStringsCaseInsensitive)(a.fileName, b.fileName) && textSpansEqual(a.textSpan, b.textSpan);
133239
+ }
133240
+ function getDocumentSpansEqualityComparer(useCaseSensitiveFileNames2) {
133241
+ return (a, b) => documentSpansEqual(a, b, useCaseSensitiveFileNames2);
133177
133242
  }
133178
133243
  function forEachUnique(array, callback) {
133179
133244
  if (array) {
@@ -160414,6 +160479,9 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
160414
160479
  }
160415
160480
  return void 0;
160416
160481
  }
160482
+ function isInDifferentLineThanContextToken(contextToken2, position2) {
160483
+ return sourceFile.getLineEndOfPosition(contextToken2.getEnd()) < position2;
160484
+ }
160417
160485
  function isSolelyIdentifierDefinitionLocation(contextToken2) {
160418
160486
  const parent2 = contextToken2.parent;
160419
160487
  const containingNodeKind = parent2.kind;
@@ -160455,11 +160523,19 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
160455
160523
  case 139 /* GetKeyword */:
160456
160524
  case 153 /* SetKeyword */:
160457
160525
  return !isFromObjectTypeDeclaration(contextToken2);
160458
- case 80 /* Identifier */:
160526
+ case 80 /* Identifier */: {
160459
160527
  if (containingNodeKind === 276 /* ImportSpecifier */ && contextToken2 === parent2.name && contextToken2.text === "type") {
160460
160528
  return false;
160461
160529
  }
160530
+ const ancestorVariableDeclaration = findAncestor(
160531
+ contextToken2.parent,
160532
+ isVariableDeclaration
160533
+ );
160534
+ if (ancestorVariableDeclaration && isInDifferentLineThanContextToken(contextToken2, position)) {
160535
+ return false;
160536
+ }
160462
160537
  break;
160538
+ }
160463
160539
  case 86 /* ClassKeyword */:
160464
160540
  case 94 /* EnumKeyword */:
160465
160541
  case 120 /* InterfaceKeyword */:
@@ -173509,6 +173585,7 @@ __export(ts_exports2, {
173509
173585
  getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
173510
173586
  getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
173511
173587
  getDocumentPositionMapper: () => getDocumentPositionMapper,
173588
+ getDocumentSpansEqualityComparer: () => getDocumentSpansEqualityComparer,
173512
173589
  getESModuleInterop: () => getESModuleInterop,
173513
173590
  getEditsForFileRename: () => getEditsForFileRename,
173514
173591
  getEffectiveBaseTypeNode: () => getEffectiveBaseTypeNode,
@@ -182833,10 +182910,10 @@ function combineProjectOutput(defaultValue, getValue, projects, action) {
182833
182910
  }
182834
182911
  return deduplicate(outputs, equateValues);
182835
182912
  }
182836
- function createDocumentSpanSet() {
182837
- return createSet(({ textSpan }) => textSpan.start + 100003 * textSpan.length, documentSpansEqual);
182913
+ function createDocumentSpanSet(useCaseSensitiveFileNames2) {
182914
+ return createSet(({ textSpan }) => textSpan.start + 100003 * textSpan.length, getDocumentSpansEqualityComparer(useCaseSensitiveFileNames2));
182838
182915
  }
182839
- function getRenameLocationsWorker(projects, defaultProject, initialLocation, findInStrings, findInComments, preferences) {
182916
+ function getRenameLocationsWorker(projects, defaultProject, initialLocation, findInStrings, findInComments, preferences, useCaseSensitiveFileNames2) {
182840
182917
  const perProjectResults = getPerProjectReferences(
182841
182918
  projects,
182842
182919
  defaultProject,
@@ -182850,7 +182927,7 @@ function getRenameLocationsWorker(projects, defaultProject, initialLocation, fin
182850
182927
  return perProjectResults;
182851
182928
  }
182852
182929
  const results = [];
182853
- const seen = createDocumentSpanSet();
182930
+ const seen = createDocumentSpanSet(useCaseSensitiveFileNames2);
182854
182931
  perProjectResults.forEach((projectResults, project) => {
182855
182932
  for (const result of projectResults) {
182856
182933
  if (!seen.has(result) && !getMappedLocationForProject(documentSpanLocation(result), project)) {
@@ -182873,7 +182950,7 @@ function getDefinitionLocation(defaultProject, initialLocation, isForRename) {
182873
182950
  const info = infos && firstOrUndefined(infos);
182874
182951
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : void 0;
182875
182952
  }
182876
- function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
182953
+ function getReferencesWorker(projects, defaultProject, initialLocation, useCaseSensitiveFileNames2, logger) {
182877
182954
  var _a, _b;
182878
182955
  const perProjectResults = getPerProjectReferences(
182879
182956
  projects,
@@ -182905,7 +182982,7 @@ function getReferencesWorker(projects, defaultProject, initialLocation, logger)
182905
182982
  }
182906
182983
  });
182907
182984
  } else {
182908
- const knownSymbolSpans = createDocumentSpanSet();
182985
+ const knownSymbolSpans = createDocumentSpanSet(useCaseSensitiveFileNames2);
182909
182986
  for (const referencedSymbol of defaultProjectResults) {
182910
182987
  for (const ref of referencedSymbol.references) {
182911
182988
  if (ref.isDefinition) {
@@ -182940,7 +183017,7 @@ function getReferencesWorker(projects, defaultProject, initialLocation, logger)
182940
183017
  });
182941
183018
  }
182942
183019
  const results = [];
182943
- const seenRefs = createDocumentSpanSet();
183020
+ const seenRefs = createDocumentSpanSet(useCaseSensitiveFileNames2);
182944
183021
  perProjectResults.forEach((projectResults, project) => {
182945
183022
  for (const referencedSymbol of projectResults) {
182946
183023
  const mappedDefinitionFile = getMappedLocationForProject(documentSpanLocation(referencedSymbol.definition), project);
@@ -182951,7 +183028,7 @@ function getReferencesWorker(projects, defaultProject, initialLocation, logger)
182951
183028
  fileName: mappedDefinitionFile.fileName,
182952
183029
  contextSpan: getMappedContextSpanForProject(referencedSymbol.definition, project)
182953
183030
  };
182954
- let symbolToAddTo = find(results, (o) => documentSpansEqual(o.definition, definition));
183031
+ let symbolToAddTo = find(results, (o) => documentSpansEqual(o.definition, definition, useCaseSensitiveFileNames2));
182955
183032
  if (!symbolToAddTo) {
182956
183033
  symbolToAddTo = { definition, references: [] };
182957
183034
  results.push(symbolToAddTo);
@@ -184311,7 +184388,10 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
184311
184388
  let definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || emptyArray2, project).slice();
184312
184389
  const needsJsResolution = this.projectService.serverMode === 0 /* Semantic */ && (!some(definitions, (d) => toNormalizedPath(d.fileName) !== file && !d.isAmbient) || some(definitions, (d) => !!d.failedAliasResolution));
184313
184390
  if (needsJsResolution) {
184314
- const definitionSet = createSet((d) => d.textSpan.start, documentSpansEqual);
184391
+ const definitionSet = createSet(
184392
+ (d) => d.textSpan.start,
184393
+ getDocumentSpansEqualityComparer(this.host.useCaseSensitiveFileNames)
184394
+ );
184315
184395
  definitions == null ? void 0 : definitions.forEach((d) => definitionSet.add(d));
184316
184396
  const noDtsProject = project.getNoDtsResolutionProject(file);
184317
184397
  const ls = noDtsProject.getLanguageService();
@@ -184752,7 +184832,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
184752
184832
  { fileName: args.file, pos: position },
184753
184833
  !!args.findInStrings,
184754
184834
  !!args.findInComments,
184755
- preferences
184835
+ preferences,
184836
+ this.host.useCaseSensitiveFileNames
184756
184837
  );
184757
184838
  if (!simplifiedResult)
184758
184839
  return locations;
@@ -184787,6 +184868,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
184787
184868
  projects,
184788
184869
  this.getDefaultProject(args),
184789
184870
  { fileName: args.file, pos: position },
184871
+ this.host.useCaseSensitiveFileNames,
184790
184872
  this.logger
184791
184873
  );
184792
184874
  if (!simplifiedResult)
@@ -184809,7 +184891,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
184809
184891
  const fileName = args.file;
184810
184892
  const preferences = this.getPreferences(toNormalizedPath(fileName));
184811
184893
  const references = [];
184812
- const seen = createDocumentSpanSet();
184894
+ const seen = createDocumentSpanSet(this.host.useCaseSensitiveFileNames);
184813
184895
  forEachProjectInProjects(
184814
184896
  projects,
184815
184897
  /*path*/
@@ -188266,6 +188348,7 @@ start(initializeNodeSystem(), require("os").platform());
188266
188348
  getDirectoryToWatchFailedLookupLocation,
188267
188349
  getDirectoryToWatchFailedLookupLocationFromTypeRoot,
188268
188350
  getDocumentPositionMapper,
188351
+ getDocumentSpansEqualityComparer,
188269
188352
  getESModuleInterop,
188270
188353
  getEditsForFileRename,
188271
188354
  getEffectiveBaseTypeNode,