typescript 5.1.0-dev.20230331 → 5.1.0-dev.20230402

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.
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230331`;
38
+ version = `${versionMajorMinor}.0-dev.20230402`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -7509,7 +7509,7 @@ ${lanes.join("\n")}
7509
7509
  Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, 1 /* Error */, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
7510
7510
  Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, 1 /* Error */, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
7511
7511
  This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, 1 /* Error */, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
7512
- A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
7512
+ A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
7513
7513
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
7514
7514
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
7515
7515
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
@@ -7949,7 +7949,6 @@ ${lanes.join("\n")}
7949
7949
  Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
7950
7950
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
7951
7951
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
7952
- A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
7953
7952
  The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
7954
7953
  Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
7955
7954
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
@@ -18055,6 +18054,9 @@ ${lanes.join("\n")}
18055
18054
  function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
18056
18055
  return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
18057
18056
  }
18057
+ function shouldResolveJsRequire(compilerOptions) {
18058
+ return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
18059
+ }
18058
18060
  function getResolvePackageJsonExports(compilerOptions) {
18059
18061
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
18060
18062
  if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@@ -38030,7 +38032,8 @@ ${lanes.join("\n")}
38030
38032
  affectsBuildInfo: true,
38031
38033
  category: Diagnostics.Modules,
38032
38034
  description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
38033
- defaultValueDescription: false
38035
+ defaultValueDescription: false,
38036
+ transpileOptionValue: void 0
38034
38037
  },
38035
38038
  {
38036
38039
  name: "resolvePackageJsonExports",
@@ -43786,7 +43789,7 @@ ${lanes.join("\n")}
43786
43789
  }
43787
43790
  if (!isBindingPattern(node.name)) {
43788
43791
  const possibleVariableDecl = node.kind === 258 /* VariableDeclaration */ ? node : node.parent.parent;
43789
- if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
43792
+ if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
43790
43793
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
43791
43794
  } else if (isBlockOrCatchScoped(node)) {
43792
43795
  bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@@ -47353,7 +47356,7 @@ ${lanes.join("\n")}
47353
47356
  const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
47354
47357
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
47355
47358
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
47356
- if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
47359
+ if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
47357
47360
  const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
47358
47361
  const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
47359
47362
  const exportAssignment = exportEqualsSymbol.valueDeclaration;
@@ -47521,7 +47524,7 @@ ${lanes.join("\n")}
47521
47524
  if (!isIdentifier(name)) {
47522
47525
  return void 0;
47523
47526
  }
47524
- const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
47527
+ const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
47525
47528
  const targetSymbol = resolveESModuleSymbol(
47526
47529
  moduleSymbol,
47527
47530
  moduleSpecifier,
@@ -52163,7 +52166,7 @@ ${lanes.join("\n")}
52163
52166
  return;
52164
52167
  }
52165
52168
  let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
52166
- if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
52169
+ if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
52167
52170
  verbatimTargetName = "default" /* Default */;
52168
52171
  }
52169
52172
  const targetName = getInternalSymbolName(target, verbatimTargetName);
@@ -55939,7 +55942,7 @@ ${lanes.join("\n")}
55939
55942
  }
55940
55943
  function isConstTypeVariable(type) {
55941
55944
  var _a2;
55942
- return !!(type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0 || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType));
55945
+ return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
55943
55946
  }
55944
55947
  function getConstraintOfIndexedAccess(type) {
55945
55948
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -73386,7 +73389,7 @@ ${lanes.join("\n")}
73386
73389
  return anyType;
73387
73390
  }
73388
73391
  }
73389
- if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
73392
+ if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
73390
73393
  return resolveExternalModuleTypeByLiteral(node.arguments[0]);
73391
73394
  }
73392
73395
  const returnType = getReturnTypeOfSignature(signature);
@@ -74462,7 +74465,16 @@ ${lanes.join("\n")}
74462
74465
  return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, neverType) : neverType;
74463
74466
  }
74464
74467
  if (types.length === 0) {
74465
- return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, voidType) : voidType;
74468
+ const contextualReturnType = getContextualReturnType(
74469
+ func,
74470
+ /*contextFlags*/
74471
+ void 0
74472
+ );
74473
+ const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
74474
+ return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
74475
+ // Async function
74476
+ returnType2
74477
+ );
74466
74478
  }
74467
74479
  returnType = getUnionType(types, 2 /* Subtype */);
74468
74480
  }
@@ -74684,7 +74696,7 @@ ${lanes.join("\n")}
74684
74696
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
74685
74697
  const functionFlags = getFunctionFlags(func);
74686
74698
  const type = returnType && unwrapReturnType(returnType, functionFlags);
74687
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
74699
+ if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
74688
74700
  return;
74689
74701
  }
74690
74702
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -74695,12 +74707,8 @@ ${lanes.join("\n")}
74695
74707
  if (type && type.flags & 131072 /* Never */) {
74696
74708
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
74697
74709
  } else if (type && !hasExplicitReturn) {
74698
- if (strictNullChecks) {
74699
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74700
- } else {
74701
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
74702
- }
74703
- } else if (type && strictNullChecks) {
74710
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
74711
+ } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
74704
74712
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
74705
74713
  } else if (compilerOptions.noImplicitReturns) {
74706
74714
  if (!type) {
@@ -74708,7 +74716,7 @@ ${lanes.join("\n")}
74708
74716
  return;
74709
74717
  }
74710
74718
  const inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
74711
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
74719
+ if (isUnwrappedReturnTypeUndefinedVoidOrAny(func, inferredReturnType)) {
74712
74720
  return;
74713
74721
  }
74714
74722
  }
@@ -76174,11 +76182,7 @@ ${lanes.join("\n")}
76174
76182
  }
76175
76183
  function isConstContext(node) {
76176
76184
  const parent2 = node.parent;
76177
- return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeParameterContext(node) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
76178
- }
76179
- function isConstTypeParameterContext(node) {
76180
- const contextualType = getContextualType2(node, 0 /* None */);
76181
- return !!contextualType && someType(contextualType, isConstTypeVariable);
76185
+ return isAssertionExpression(parent2) && isConstTypeReference(parent2.type) || isJSDocTypeAssertion(parent2) && isConstTypeReference(getJSDocTypeAssertionType(parent2)) || isValidConstAssertionArgument(node) && isConstTypeVariable(getContextualType2(node, 0 /* None */)) || (isParenthesizedExpression(parent2) || isArrayLiteralExpression(parent2) || isSpreadElement(parent2)) && isConstContext(parent2) || (isPropertyAssignment(parent2) || isShorthandPropertyAssignment(parent2) || isTemplateSpan(parent2)) && isConstContext(parent2.parent);
76182
76186
  }
76183
76187
  function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
76184
76188
  const type = checkExpression(node, checkMode, forceTuple);
@@ -79861,9 +79865,9 @@ ${lanes.join("\n")}
79861
79865
  }
79862
79866
  return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
79863
79867
  }
79864
- function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
79865
- const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(func));
79866
- return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */);
79868
+ function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
79869
+ const type = unwrapReturnType(returnType, getFunctionFlags(func));
79870
+ return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
79867
79871
  }
79868
79872
  function checkReturnStatement(node) {
79869
79873
  var _a2;
@@ -79905,7 +79909,7 @@ ${lanes.join("\n")}
79905
79909
  checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
79906
79910
  }
79907
79911
  }
79908
- } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
79912
+ } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
79909
79913
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
79910
79914
  }
79911
79915
  }
@@ -117571,7 +117575,7 @@ ${lanes.join("\n")}
117571
117575
  false
117572
117576
  );
117573
117577
  }
117574
- const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
117578
+ const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
117575
117579
  if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
117576
117580
  collectDynamicImportOrRequireCalls(file);
117577
117581
  }
@@ -121171,6 +121175,79 @@ ${lanes.join("\n")}
121171
121175
  }
121172
121176
  return true;
121173
121177
  }
121178
+ function canWatchAtTypes(atTypes, rootPath) {
121179
+ const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
121180
+ return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
121181
+ }
121182
+ function isInDirectoryPath(dir, file) {
121183
+ if (dir === void 0 || file.length <= dir.length) {
121184
+ return false;
121185
+ }
121186
+ return startsWith(file, dir) && file[dir.length] === directorySeparator;
121187
+ }
121188
+ function canWatchAffectingLocation(filePath) {
121189
+ return canWatchDirectoryOrFile(filePath);
121190
+ }
121191
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
121192
+ if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
121193
+ failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
121194
+ const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
121195
+ const failedLookupSplit = failedLookupLocation.split(directorySeparator);
121196
+ Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
121197
+ if (failedLookupPathSplit.length > rootSplitLength + 1) {
121198
+ return {
121199
+ dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
121200
+ dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
121201
+ };
121202
+ } else {
121203
+ return {
121204
+ dir: rootDir,
121205
+ dirPath: rootPath,
121206
+ nonRecursive: false
121207
+ };
121208
+ }
121209
+ }
121210
+ return getDirectoryToWatchFromFailedLookupLocationDirectory(
121211
+ getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
121212
+ getDirectoryPath(failedLookupLocationPath),
121213
+ rootPath
121214
+ );
121215
+ }
121216
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
121217
+ while (pathContainsNodeModules(dirPath)) {
121218
+ dir = getDirectoryPath(dir);
121219
+ dirPath = getDirectoryPath(dirPath);
121220
+ }
121221
+ if (isNodeModulesDirectory(dirPath)) {
121222
+ return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
121223
+ }
121224
+ let nonRecursive = true;
121225
+ let subDirectoryPath, subDirectory;
121226
+ if (rootPath !== void 0) {
121227
+ while (!isInDirectoryPath(dirPath, rootPath)) {
121228
+ const parentPath = getDirectoryPath(dirPath);
121229
+ if (parentPath === dirPath) {
121230
+ break;
121231
+ }
121232
+ nonRecursive = false;
121233
+ subDirectoryPath = dirPath;
121234
+ subDirectory = dir;
121235
+ dirPath = parentPath;
121236
+ dir = getDirectoryPath(dir);
121237
+ }
121238
+ }
121239
+ return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
121240
+ }
121241
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
121242
+ if (isInDirectoryPath(rootPath, typeRootPath)) {
121243
+ return rootPath;
121244
+ }
121245
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
121246
+ return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
121247
+ }
121248
+ function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
121249
+ return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121250
+ }
121174
121251
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
121175
121252
  let filesWithChangedSetOfUnresolvedImports;
121176
121253
  let filesWithInvalidatedResolutions;
@@ -121205,7 +121282,7 @@ ${lanes.join("\n")}
121205
121282
  const customFailedLookupPaths = /* @__PURE__ */ new Map();
121206
121283
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
121207
121284
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
121208
- const rootDir = rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121285
+ const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
121209
121286
  const rootPath = rootDir && resolutionHost.toPath(rootDir);
121210
121287
  const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
121211
121288
  const typeRootsWatches = /* @__PURE__ */ new Map();
@@ -121238,12 +121315,6 @@ ${lanes.join("\n")}
121238
121315
  function getResolvedTypeReferenceDirective2(resolution) {
121239
121316
  return resolution.resolvedTypeReferenceDirective;
121240
121317
  }
121241
- function isInDirectoryPath(dir, file) {
121242
- if (dir === void 0 || file.length <= dir.length) {
121243
- return false;
121244
- }
121245
- return startsWith(file, dir) && file[dir.length] === directorySeparator;
121246
- }
121247
121318
  function clear2() {
121248
121319
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
121249
121320
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
@@ -121527,55 +121598,6 @@ ${lanes.join("\n")}
121527
121598
  function isNodeModulesAtTypesDirectory(dirPath) {
121528
121599
  return endsWith(dirPath, "/node_modules/@types");
121529
121600
  }
121530
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
121531
- if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
121532
- failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
121533
- const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
121534
- const failedLookupSplit = failedLookupLocation.split(directorySeparator);
121535
- Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
121536
- if (failedLookupPathSplit.length > rootSplitLength + 1) {
121537
- return {
121538
- dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
121539
- dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
121540
- };
121541
- } else {
121542
- return {
121543
- dir: rootDir,
121544
- dirPath: rootPath,
121545
- nonRecursive: false
121546
- };
121547
- }
121548
- }
121549
- return getDirectoryToWatchFromFailedLookupLocationDirectory(
121550
- getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
121551
- getDirectoryPath(failedLookupLocationPath)
121552
- );
121553
- }
121554
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
121555
- while (pathContainsNodeModules(dirPath)) {
121556
- dir = getDirectoryPath(dir);
121557
- dirPath = getDirectoryPath(dirPath);
121558
- }
121559
- if (isNodeModulesDirectory(dirPath)) {
121560
- return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
121561
- }
121562
- let nonRecursive = true;
121563
- let subDirectoryPath, subDirectory;
121564
- if (rootPath !== void 0) {
121565
- while (!isInDirectoryPath(dirPath, rootPath)) {
121566
- const parentPath = getDirectoryPath(dirPath);
121567
- if (parentPath === dirPath) {
121568
- break;
121569
- }
121570
- nonRecursive = false;
121571
- subDirectoryPath = dirPath;
121572
- subDirectory = dir;
121573
- dirPath = parentPath;
121574
- dir = getDirectoryPath(dir);
121575
- }
121576
- }
121577
- return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
121578
- }
121579
121601
  function isPathWithDefaultFailedLookupExtension(path) {
121580
121602
  return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
121581
121603
  }
@@ -121614,7 +121636,14 @@ ${lanes.join("\n")}
121614
121636
  if (failedLookupLocations) {
121615
121637
  for (const failedLookupLocation of failedLookupLocations) {
121616
121638
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
121617
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
121639
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
121640
+ failedLookupLocation,
121641
+ failedLookupLocationPath,
121642
+ rootDir,
121643
+ rootPath,
121644
+ rootSplitLength,
121645
+ getCurrentDirectory
121646
+ );
121618
121647
  if (toWatch) {
121619
121648
  const { dir, dirPath, nonRecursive } = toWatch;
121620
121649
  if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
@@ -121682,7 +121711,7 @@ ${lanes.join("\n")}
121682
121711
  }
121683
121712
  const paths = /* @__PURE__ */ new Set();
121684
121713
  paths.add(locationToWatch);
121685
- let actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
121714
+ let actualWatcher = canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
121686
121715
  cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
121687
121716
  const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
121688
121717
  paths.forEach((path) => {
@@ -121750,7 +121779,14 @@ ${lanes.join("\n")}
121750
121779
  let removeAtRoot = false;
121751
121780
  for (const failedLookupLocation of failedLookupLocations) {
121752
121781
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
121753
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
121782
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
121783
+ failedLookupLocation,
121784
+ failedLookupLocationPath,
121785
+ rootDir,
121786
+ rootPath,
121787
+ rootSplitLength,
121788
+ getCurrentDirectory
121789
+ );
121754
121790
  if (toWatch) {
121755
121791
  const { dirPath } = toWatch;
121756
121792
  const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
@@ -121918,13 +121954,6 @@ ${lanes.join("\n")}
121918
121954
  function closeTypeRootsWatch() {
121919
121955
  clearMap(typeRootsWatches, closeFileWatcher);
121920
121956
  }
121921
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
121922
- if (isInDirectoryPath(rootPath, typeRootPath)) {
121923
- return rootPath;
121924
- }
121925
- const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
121926
- return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
121927
- }
121928
121957
  function createTypeRootsWatch(typeRootPath, typeRoot) {
121929
121958
  return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
121930
121959
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
@@ -121933,7 +121962,12 @@ ${lanes.join("\n")}
121933
121962
  }
121934
121963
  hasChangedAutomaticTypeDirectiveNames = true;
121935
121964
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
121936
- const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
121965
+ const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
121966
+ typeRoot,
121967
+ typeRootPath,
121968
+ rootPath,
121969
+ (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
121970
+ );
121937
121971
  if (dirPath) {
121938
121972
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
121939
121973
  }
@@ -121959,12 +121993,10 @@ ${lanes.join("\n")}
121959
121993
  closeTypeRootsWatch();
121960
121994
  }
121961
121995
  }
121962
- function canWatchTypeRootPath(nodeTypesDirectory) {
121996
+ function canWatchTypeRootPath(typeRoot) {
121963
121997
  if (resolutionHost.getCompilationSettings().typeRoots)
121964
121998
  return true;
121965
- const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
121966
- const dirPath = resolutionHost.toPath(dir);
121967
- return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
121999
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
121968
122000
  }
121969
122001
  }
121970
122002
  function resolutionIsSymlink(resolution) {
@@ -129047,7 +129079,7 @@ ${lanes.join("\n")}
129047
129079
  // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list.
129048
129080
  typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || // Module agumentation and ambient module changes can add or remove exports available to be auto-imported.
129049
129081
  // Changes elsewhere in the file can change the *type* of an export in a module augmentation,
129050
- // but type info is gathered in getCompletionEntryDetails, which doesnt use the cache.
129082
+ // but type info is gathered in getCompletionEntryDetails, which doesn't use the cache.
129051
129083
  !arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) {
129052
129084
  cache.clear();
129053
129085
  return true;
@@ -137812,7 +137844,7 @@ ${lanes.join("\n")}
137812
137844
  function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) {
137813
137845
  const errorNode = isPropertyAccessExpression(reference.parent) ? reference.parent.name : isBinaryExpression(reference.parent) ? reference.parent : reference;
137814
137846
  const diagnostic = find(diagnostics, (diagnostic2) => diagnostic2.start === errorNode.getStart(sourceFile) && diagnostic2.start + diagnostic2.length === errorNode.getEnd());
137815
- return diagnostic && contains(errorCodes3, diagnostic.code) || // A Promise is usually not correct in a binary expression (its not valid
137847
+ return diagnostic && contains(errorCodes3, diagnostic.code) || // A Promise is usually not correct in a binary expression (it's not valid
137816
137848
  // in an arithmetic expression and an equality comparison seems unusual),
137817
137849
  // but if the other side of the binary expression has an error, the side
137818
137850
  // is typed `any` which will squash the error that would identify this
@@ -142645,7 +142677,6 @@ ${lanes.join("\n")}
142645
142677
  return void 0;
142646
142678
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
142647
142679
  switch (errorCode) {
142648
- case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
142649
142680
  case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
142650
142681
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
142651
142682
  return void 0;
@@ -142753,7 +142784,6 @@ ${lanes.join("\n")}
142753
142784
  fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
142754
142785
  fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
142755
142786
  errorCodes26 = [
142756
- Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
142757
142787
  Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
142758
142788
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
142759
142789
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
@@ -153769,7 +153799,7 @@ ${lanes.join("\n")}
153769
153799
  */
153770
153800
  this.markSeenReExportRHS = nodeSeenTracker();
153771
153801
  this.symbolIdToReferences = [];
153772
- // Source file ID symbol ID Whether the symbol has been searched for in the source file.
153802
+ // Source file ID -> symbol ID -> Whether the symbol has been searched for in the source file.
153773
153803
  this.sourceFileToSeenSymbols = [];
153774
153804
  }
153775
153805
  includesSourceFile(sourceFile) {
@@ -162913,7 +162943,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162913
162943
  if (start !== end) {
162914
162944
  const textSpan = createTextSpanFromBounds(start, end);
162915
162945
  if (!selectionRange || // Skip ranges that are identical to the parent
162916
- !textSpansEqual(textSpan, selectionRange.textSpan) && // Skip ranges that dont contain the original position
162946
+ !textSpansEqual(textSpan, selectionRange.textSpan) && // Skip ranges that don't contain the original position
162917
162947
  textSpanIntersectsWithPosition(textSpan, pos)) {
162918
162948
  selectionRange = { textSpan, ...selectionRange && { parent: selectionRange } };
162919
162949
  }
@@ -179132,6 +179162,8 @@ ${e.message}`;
179132
179162
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
179133
179163
  canProduceDiagnostics: () => canProduceDiagnostics,
179134
179164
  canUsePropertyAccess: () => canUsePropertyAccess,
179165
+ canWatchAffectingLocation: () => canWatchAffectingLocation,
179166
+ canWatchAtTypes: () => canWatchAtTypes,
179135
179167
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
179136
179168
  cartesianProduct: () => cartesianProduct,
179137
179169
  cast: () => cast,
@@ -179579,6 +179611,8 @@ ${e.message}`;
179579
179611
  getDiagnosticText: () => getDiagnosticText,
179580
179612
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
179581
179613
  getDirectoryPath: () => getDirectoryPath,
179614
+ getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
179615
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
179582
179616
  getDocumentPositionMapper: () => getDocumentPositionMapper,
179583
179617
  getESModuleInterop: () => getESModuleInterop,
179584
179618
  getEditsForFileRename: () => getEditsForFileRename,
@@ -179848,6 +179882,7 @@ ${e.message}`;
179848
179882
  getRestParameterElementType: () => getRestParameterElementType,
179849
179883
  getRightMostAssignedExpression: () => getRightMostAssignedExpression,
179850
179884
  getRootDeclaration: () => getRootDeclaration,
179885
+ getRootDirectoryOfResolutionCache: () => getRootDirectoryOfResolutionCache,
179851
179886
  getRootLength: () => getRootLength,
179852
179887
  getScriptKind: () => getScriptKind,
179853
179888
  getScriptKindFromFileName: () => getScriptKindFromFileName,
@@ -180945,6 +180980,7 @@ ${e.message}`;
180945
180980
  setValueDeclaration: () => setValueDeclaration,
180946
180981
  shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
180947
180982
  shouldPreserveConstEnums: () => shouldPreserveConstEnums,
180983
+ shouldResolveJsRequire: () => shouldResolveJsRequire,
180948
180984
  shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
180949
180985
  showModuleSpecifier: () => showModuleSpecifier,
180950
180986
  signatureHasLiteralTypes: () => signatureHasLiteralTypes,
@@ -181491,6 +181527,8 @@ ${e.message}`;
181491
181527
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
181492
181528
  canProduceDiagnostics: () => canProduceDiagnostics,
181493
181529
  canUsePropertyAccess: () => canUsePropertyAccess,
181530
+ canWatchAffectingLocation: () => canWatchAffectingLocation,
181531
+ canWatchAtTypes: () => canWatchAtTypes,
181494
181532
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
181495
181533
  cartesianProduct: () => cartesianProduct,
181496
181534
  cast: () => cast,
@@ -181938,6 +181976,8 @@ ${e.message}`;
181938
181976
  getDiagnosticText: () => getDiagnosticText,
181939
181977
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
181940
181978
  getDirectoryPath: () => getDirectoryPath,
181979
+ getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
181980
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
181941
181981
  getDocumentPositionMapper: () => getDocumentPositionMapper,
181942
181982
  getESModuleInterop: () => getESModuleInterop,
181943
181983
  getEditsForFileRename: () => getEditsForFileRename,
@@ -182207,6 +182247,7 @@ ${e.message}`;
182207
182247
  getRestParameterElementType: () => getRestParameterElementType,
182208
182248
  getRightMostAssignedExpression: () => getRightMostAssignedExpression,
182209
182249
  getRootDeclaration: () => getRootDeclaration,
182250
+ getRootDirectoryOfResolutionCache: () => getRootDirectoryOfResolutionCache,
182210
182251
  getRootLength: () => getRootLength,
182211
182252
  getScriptKind: () => getScriptKind,
182212
182253
  getScriptKindFromFileName: () => getScriptKindFromFileName,
@@ -183304,6 +183345,7 @@ ${e.message}`;
183304
183345
  setValueDeclaration: () => setValueDeclaration,
183305
183346
  shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
183306
183347
  shouldPreserveConstEnums: () => shouldPreserveConstEnums,
183348
+ shouldResolveJsRequire: () => shouldResolveJsRequire,
183307
183349
  shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
183308
183350
  showModuleSpecifier: () => showModuleSpecifier,
183309
183351
  signatureHasLiteralTypes: () => signatureHasLiteralTypes,