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.
package/lib/tsserver.js CHANGED
@@ -257,6 +257,8 @@ __export(server_exports, {
257
257
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
258
258
  canProduceDiagnostics: () => canProduceDiagnostics,
259
259
  canUsePropertyAccess: () => canUsePropertyAccess,
260
+ canWatchAffectingLocation: () => canWatchAffectingLocation,
261
+ canWatchAtTypes: () => canWatchAtTypes,
260
262
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
261
263
  cartesianProduct: () => cartesianProduct,
262
264
  cast: () => cast,
@@ -704,6 +706,8 @@ __export(server_exports, {
704
706
  getDiagnosticText: () => getDiagnosticText,
705
707
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
706
708
  getDirectoryPath: () => getDirectoryPath,
709
+ getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
710
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
707
711
  getDocumentPositionMapper: () => getDocumentPositionMapper,
708
712
  getESModuleInterop: () => getESModuleInterop,
709
713
  getEditsForFileRename: () => getEditsForFileRename,
@@ -973,6 +977,7 @@ __export(server_exports, {
973
977
  getRestParameterElementType: () => getRestParameterElementType,
974
978
  getRightMostAssignedExpression: () => getRightMostAssignedExpression,
975
979
  getRootDeclaration: () => getRootDeclaration,
980
+ getRootDirectoryOfResolutionCache: () => getRootDirectoryOfResolutionCache,
976
981
  getRootLength: () => getRootLength,
977
982
  getScriptKind: () => getScriptKind,
978
983
  getScriptKindFromFileName: () => getScriptKindFromFileName,
@@ -2070,6 +2075,7 @@ __export(server_exports, {
2070
2075
  setValueDeclaration: () => setValueDeclaration,
2071
2076
  shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
2072
2077
  shouldPreserveConstEnums: () => shouldPreserveConstEnums,
2078
+ shouldResolveJsRequire: () => shouldResolveJsRequire,
2073
2079
  shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
2074
2080
  showModuleSpecifier: () => showModuleSpecifier,
2075
2081
  signatureHasLiteralTypes: () => signatureHasLiteralTypes,
@@ -2286,7 +2292,7 @@ module.exports = __toCommonJS(server_exports);
2286
2292
 
2287
2293
  // src/compiler/corePublic.ts
2288
2294
  var versionMajorMinor = "5.1";
2289
- var version = `${versionMajorMinor}.0-dev.20230331`;
2295
+ var version = `${versionMajorMinor}.0-dev.20230402`;
2290
2296
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2291
2297
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2292
2298
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9686,7 +9692,7 @@ var Diagnostics = {
9686
9692
  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."),
9687
9693
  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}'."),
9688
9694
  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."),
9689
- 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."),
9695
+ 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."),
9690
9696
  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."),
9691
9697
  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."),
9692
9698
  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."),
@@ -10126,7 +10132,6 @@ var Diagnostics = {
10126
10132
  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."),
10127
10133
  This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
10128
10134
  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?"),
10129
- 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."),
10130
10135
  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."),
10131
10136
  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}."),
10132
10137
  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}'."),
@@ -20328,6 +20333,9 @@ function getAllowSyntheticDefaultImports(compilerOptions) {
20328
20333
  function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
20329
20334
  return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
20330
20335
  }
20336
+ function shouldResolveJsRequire(compilerOptions) {
20337
+ return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
20338
+ }
20331
20339
  function getResolvePackageJsonExports(compilerOptions) {
20332
20340
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
20333
20341
  if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@@ -38507,7 +38515,8 @@ var commandOptionsWithoutBuild = [
38507
38515
  affectsBuildInfo: true,
38508
38516
  category: Diagnostics.Modules,
38509
38517
  description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
38510
- defaultValueDescription: false
38518
+ defaultValueDescription: false,
38519
+ transpileOptionValue: void 0
38511
38520
  },
38512
38521
  {
38513
38522
  name: "resolvePackageJsonExports",
@@ -45886,7 +45895,7 @@ function createBinder() {
45886
45895
  }
45887
45896
  if (!isBindingPattern(node.name)) {
45888
45897
  const possibleVariableDecl = node.kind === 258 /* VariableDeclaration */ ? node : node.parent.parent;
45889
- if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
45898
+ if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
45890
45899
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
45891
45900
  } else if (isBlockOrCatchScoped(node)) {
45892
45901
  bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@@ -49545,7 +49554,7 @@ function createTypeChecker(host) {
49545
49554
  const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
49546
49555
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
49547
49556
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
49548
- if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
49557
+ if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
49549
49558
  const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
49550
49559
  const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
49551
49560
  const exportAssignment = exportEqualsSymbol.valueDeclaration;
@@ -49713,7 +49722,7 @@ function createTypeChecker(host) {
49713
49722
  if (!isIdentifier(name)) {
49714
49723
  return void 0;
49715
49724
  }
49716
- const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
49725
+ const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
49717
49726
  const targetSymbol = resolveESModuleSymbol(
49718
49727
  moduleSymbol,
49719
49728
  moduleSpecifier,
@@ -54355,7 +54364,7 @@ function createTypeChecker(host) {
54355
54364
  return;
54356
54365
  }
54357
54366
  let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
54358
- if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
54367
+ if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
54359
54368
  verbatimTargetName = "default" /* Default */;
54360
54369
  }
54361
54370
  const targetName = getInternalSymbolName(target, verbatimTargetName);
@@ -58131,7 +58140,7 @@ function createTypeChecker(host) {
58131
58140
  }
58132
58141
  function isConstTypeVariable(type) {
58133
58142
  var _a2;
58134
- 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));
58143
+ 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));
58135
58144
  }
58136
58145
  function getConstraintOfIndexedAccess(type) {
58137
58146
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -75578,7 +75587,7 @@ function createTypeChecker(host) {
75578
75587
  return anyType;
75579
75588
  }
75580
75589
  }
75581
- if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
75590
+ if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
75582
75591
  return resolveExternalModuleTypeByLiteral(node.arguments[0]);
75583
75592
  }
75584
75593
  const returnType = getReturnTypeOfSignature(signature);
@@ -76654,7 +76663,16 @@ function createTypeChecker(host) {
76654
76663
  return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, neverType) : neverType;
76655
76664
  }
76656
76665
  if (types.length === 0) {
76657
- return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, voidType) : voidType;
76666
+ const contextualReturnType = getContextualReturnType(
76667
+ func,
76668
+ /*contextFlags*/
76669
+ void 0
76670
+ );
76671
+ const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
76672
+ return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
76673
+ // Async function
76674
+ returnType2
76675
+ );
76658
76676
  }
76659
76677
  returnType = getUnionType(types, 2 /* Subtype */);
76660
76678
  }
@@ -76876,7 +76894,7 @@ function createTypeChecker(host) {
76876
76894
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
76877
76895
  const functionFlags = getFunctionFlags(func);
76878
76896
  const type = returnType && unwrapReturnType(returnType, functionFlags);
76879
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
76897
+ if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
76880
76898
  return;
76881
76899
  }
76882
76900
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -76887,12 +76905,8 @@ function createTypeChecker(host) {
76887
76905
  if (type && type.flags & 131072 /* Never */) {
76888
76906
  error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
76889
76907
  } else if (type && !hasExplicitReturn) {
76890
- if (strictNullChecks) {
76891
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
76892
- } else {
76893
- error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
76894
- }
76895
- } else if (type && strictNullChecks) {
76908
+ error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
76909
+ } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
76896
76910
  error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
76897
76911
  } else if (compilerOptions.noImplicitReturns) {
76898
76912
  if (!type) {
@@ -76900,7 +76914,7 @@ function createTypeChecker(host) {
76900
76914
  return;
76901
76915
  }
76902
76916
  const inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
76903
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
76917
+ if (isUnwrappedReturnTypeUndefinedVoidOrAny(func, inferredReturnType)) {
76904
76918
  return;
76905
76919
  }
76906
76920
  }
@@ -78366,11 +78380,7 @@ function createTypeChecker(host) {
78366
78380
  }
78367
78381
  function isConstContext(node) {
78368
78382
  const parent2 = node.parent;
78369
- 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);
78370
- }
78371
- function isConstTypeParameterContext(node) {
78372
- const contextualType = getContextualType2(node, 0 /* None */);
78373
- return !!contextualType && someType(contextualType, isConstTypeVariable);
78383
+ 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);
78374
78384
  }
78375
78385
  function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
78376
78386
  const type = checkExpression(node, checkMode, forceTuple);
@@ -82053,9 +82063,9 @@ function createTypeChecker(host) {
82053
82063
  }
82054
82064
  return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
82055
82065
  }
82056
- function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
82057
- const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(func));
82058
- return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */);
82066
+ function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
82067
+ const type = unwrapReturnType(returnType, getFunctionFlags(func));
82068
+ return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
82059
82069
  }
82060
82070
  function checkReturnStatement(node) {
82061
82071
  var _a2;
@@ -82097,7 +82107,7 @@ function createTypeChecker(host) {
82097
82107
  checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
82098
82108
  }
82099
82109
  }
82100
- } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
82110
+ } else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
82101
82111
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
82102
82112
  }
82103
82113
  }
@@ -119555,7 +119565,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119555
119565
  false
119556
119566
  );
119557
119567
  }
119558
- const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
119568
+ const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
119559
119569
  if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
119560
119570
  collectDynamicImportOrRequireCalls(file);
119561
119571
  }
@@ -123000,6 +123010,79 @@ function canWatchDirectoryOrFile(dirPath) {
123000
123010
  }
123001
123011
  return true;
123002
123012
  }
123013
+ function canWatchAtTypes(atTypes, rootPath) {
123014
+ const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
123015
+ return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
123016
+ }
123017
+ function isInDirectoryPath(dir, file) {
123018
+ if (dir === void 0 || file.length <= dir.length) {
123019
+ return false;
123020
+ }
123021
+ return startsWith(file, dir) && file[dir.length] === directorySeparator;
123022
+ }
123023
+ function canWatchAffectingLocation(filePath) {
123024
+ return canWatchDirectoryOrFile(filePath);
123025
+ }
123026
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
123027
+ if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
123028
+ failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
123029
+ const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
123030
+ const failedLookupSplit = failedLookupLocation.split(directorySeparator);
123031
+ Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
123032
+ if (failedLookupPathSplit.length > rootSplitLength + 1) {
123033
+ return {
123034
+ dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
123035
+ dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
123036
+ };
123037
+ } else {
123038
+ return {
123039
+ dir: rootDir,
123040
+ dirPath: rootPath,
123041
+ nonRecursive: false
123042
+ };
123043
+ }
123044
+ }
123045
+ return getDirectoryToWatchFromFailedLookupLocationDirectory(
123046
+ getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
123047
+ getDirectoryPath(failedLookupLocationPath),
123048
+ rootPath
123049
+ );
123050
+ }
123051
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
123052
+ while (pathContainsNodeModules(dirPath)) {
123053
+ dir = getDirectoryPath(dir);
123054
+ dirPath = getDirectoryPath(dirPath);
123055
+ }
123056
+ if (isNodeModulesDirectory(dirPath)) {
123057
+ return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
123058
+ }
123059
+ let nonRecursive = true;
123060
+ let subDirectoryPath, subDirectory;
123061
+ if (rootPath !== void 0) {
123062
+ while (!isInDirectoryPath(dirPath, rootPath)) {
123063
+ const parentPath = getDirectoryPath(dirPath);
123064
+ if (parentPath === dirPath) {
123065
+ break;
123066
+ }
123067
+ nonRecursive = false;
123068
+ subDirectoryPath = dirPath;
123069
+ subDirectory = dir;
123070
+ dirPath = parentPath;
123071
+ dir = getDirectoryPath(dir);
123072
+ }
123073
+ }
123074
+ return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
123075
+ }
123076
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
123077
+ if (isInDirectoryPath(rootPath, typeRootPath)) {
123078
+ return rootPath;
123079
+ }
123080
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
123081
+ return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
123082
+ }
123083
+ function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
123084
+ return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
123085
+ }
123003
123086
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
123004
123087
  let filesWithChangedSetOfUnresolvedImports;
123005
123088
  let filesWithInvalidatedResolutions;
@@ -123034,7 +123117,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123034
123117
  const customFailedLookupPaths = /* @__PURE__ */ new Map();
123035
123118
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
123036
123119
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
123037
- const rootDir = rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
123120
+ const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
123038
123121
  const rootPath = rootDir && resolutionHost.toPath(rootDir);
123039
123122
  const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
123040
123123
  const typeRootsWatches = /* @__PURE__ */ new Map();
@@ -123067,12 +123150,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123067
123150
  function getResolvedTypeReferenceDirective2(resolution) {
123068
123151
  return resolution.resolvedTypeReferenceDirective;
123069
123152
  }
123070
- function isInDirectoryPath(dir, file) {
123071
- if (dir === void 0 || file.length <= dir.length) {
123072
- return false;
123073
- }
123074
- return startsWith(file, dir) && file[dir.length] === directorySeparator;
123075
- }
123076
123153
  function clear2() {
123077
123154
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
123078
123155
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
@@ -123356,55 +123433,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123356
123433
  function isNodeModulesAtTypesDirectory(dirPath) {
123357
123434
  return endsWith(dirPath, "/node_modules/@types");
123358
123435
  }
123359
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
123360
- if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
123361
- failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
123362
- const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
123363
- const failedLookupSplit = failedLookupLocation.split(directorySeparator);
123364
- Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
123365
- if (failedLookupPathSplit.length > rootSplitLength + 1) {
123366
- return {
123367
- dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
123368
- dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
123369
- };
123370
- } else {
123371
- return {
123372
- dir: rootDir,
123373
- dirPath: rootPath,
123374
- nonRecursive: false
123375
- };
123376
- }
123377
- }
123378
- return getDirectoryToWatchFromFailedLookupLocationDirectory(
123379
- getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
123380
- getDirectoryPath(failedLookupLocationPath)
123381
- );
123382
- }
123383
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
123384
- while (pathContainsNodeModules(dirPath)) {
123385
- dir = getDirectoryPath(dir);
123386
- dirPath = getDirectoryPath(dirPath);
123387
- }
123388
- if (isNodeModulesDirectory(dirPath)) {
123389
- return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
123390
- }
123391
- let nonRecursive = true;
123392
- let subDirectoryPath, subDirectory;
123393
- if (rootPath !== void 0) {
123394
- while (!isInDirectoryPath(dirPath, rootPath)) {
123395
- const parentPath = getDirectoryPath(dirPath);
123396
- if (parentPath === dirPath) {
123397
- break;
123398
- }
123399
- nonRecursive = false;
123400
- subDirectoryPath = dirPath;
123401
- subDirectory = dir;
123402
- dirPath = parentPath;
123403
- dir = getDirectoryPath(dir);
123404
- }
123405
- }
123406
- return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
123407
- }
123408
123436
  function isPathWithDefaultFailedLookupExtension(path) {
123409
123437
  return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
123410
123438
  }
@@ -123443,7 +123471,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123443
123471
  if (failedLookupLocations) {
123444
123472
  for (const failedLookupLocation of failedLookupLocations) {
123445
123473
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
123446
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
123474
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
123475
+ failedLookupLocation,
123476
+ failedLookupLocationPath,
123477
+ rootDir,
123478
+ rootPath,
123479
+ rootSplitLength,
123480
+ getCurrentDirectory
123481
+ );
123447
123482
  if (toWatch) {
123448
123483
  const { dir, dirPath, nonRecursive } = toWatch;
123449
123484
  if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
@@ -123511,7 +123546,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123511
123546
  }
123512
123547
  const paths = /* @__PURE__ */ new Set();
123513
123548
  paths.add(locationToWatch);
123514
- let actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
123549
+ let actualWatcher = canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
123515
123550
  cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
123516
123551
  const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
123517
123552
  paths.forEach((path) => {
@@ -123579,7 +123614,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123579
123614
  let removeAtRoot = false;
123580
123615
  for (const failedLookupLocation of failedLookupLocations) {
123581
123616
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
123582
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
123617
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
123618
+ failedLookupLocation,
123619
+ failedLookupLocationPath,
123620
+ rootDir,
123621
+ rootPath,
123622
+ rootSplitLength,
123623
+ getCurrentDirectory
123624
+ );
123583
123625
  if (toWatch) {
123584
123626
  const { dirPath } = toWatch;
123585
123627
  const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
@@ -123747,13 +123789,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123747
123789
  function closeTypeRootsWatch() {
123748
123790
  clearMap(typeRootsWatches, closeFileWatcher);
123749
123791
  }
123750
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
123751
- if (isInDirectoryPath(rootPath, typeRootPath)) {
123752
- return rootPath;
123753
- }
123754
- const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
123755
- return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
123756
- }
123757
123792
  function createTypeRootsWatch(typeRootPath, typeRoot) {
123758
123793
  return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
123759
123794
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
@@ -123762,7 +123797,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123762
123797
  }
123763
123798
  hasChangedAutomaticTypeDirectiveNames = true;
123764
123799
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
123765
- const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
123800
+ const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
123801
+ typeRoot,
123802
+ typeRootPath,
123803
+ rootPath,
123804
+ (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
123805
+ );
123766
123806
  if (dirPath) {
123767
123807
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
123768
123808
  }
@@ -123788,12 +123828,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123788
123828
  closeTypeRootsWatch();
123789
123829
  }
123790
123830
  }
123791
- function canWatchTypeRootPath(nodeTypesDirectory) {
123831
+ function canWatchTypeRootPath(typeRoot) {
123792
123832
  if (resolutionHost.getCompilationSettings().typeRoots)
123793
123833
  return true;
123794
- const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
123795
- const dirPath = resolutionHost.toPath(dir);
123796
- return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
123834
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
123797
123835
  }
123798
123836
  }
123799
123837
  function resolutionIsSymlink(resolution) {
@@ -130721,7 +130759,7 @@ function createCacheableExportInfoMap(host) {
130721
130759
  // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list.
130722
130760
  typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || // Module agumentation and ambient module changes can add or remove exports available to be auto-imported.
130723
130761
  // Changes elsewhere in the file can change the *type* of an export in a module augmentation,
130724
- // but type info is gathered in getCompletionEntryDetails, which doesnt use the cache.
130762
+ // but type info is gathered in getCompletionEntryDetails, which doesn't use the cache.
130725
130763
  !arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) {
130726
130764
  cache.clear();
130727
130765
  return true;
@@ -139390,7 +139428,7 @@ function getIdentifiersFromErrorSpanExpression(expression, checker) {
139390
139428
  function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) {
139391
139429
  const errorNode = isPropertyAccessExpression(reference.parent) ? reference.parent.name : isBinaryExpression(reference.parent) ? reference.parent : reference;
139392
139430
  const diagnostic = find(diagnostics, (diagnostic2) => diagnostic2.start === errorNode.getStart(sourceFile) && diagnostic2.start + diagnostic2.length === errorNode.getEnd());
139393
- return diagnostic && contains(errorCodes3, diagnostic.code) || // A Promise is usually not correct in a binary expression (its not valid
139431
+ return diagnostic && contains(errorCodes3, diagnostic.code) || // A Promise is usually not correct in a binary expression (it's not valid
139394
139432
  // in an arithmetic expression and an equality comparison seems unusual),
139395
139433
  // but if the other side of the binary expression has an error, the side
139396
139434
  // is typed `any` which will squash the error that would identify this
@@ -143883,7 +143921,6 @@ var fixIdAddReturnStatement = "fixAddReturnStatement";
143883
143921
  var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
143884
143922
  var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
143885
143923
  var errorCodes26 = [
143886
- Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
143887
143924
  Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
143888
143925
  Diagnostics.Type_0_is_not_assignable_to_type_1.code,
143889
143926
  Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
@@ -144035,7 +144072,6 @@ function getInfo6(checker, sourceFile, position, errorCode) {
144035
144072
  return void 0;
144036
144073
  const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
144037
144074
  switch (errorCode) {
144038
- case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
144039
144075
  case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
144040
144076
  if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
144041
144077
  return void 0;
@@ -154636,7 +154672,7 @@ var Core;
154636
154672
  */
154637
154673
  this.markSeenReExportRHS = nodeSeenTracker();
154638
154674
  this.symbolIdToReferences = [];
154639
- // Source file ID symbol ID Whether the symbol has been searched for in the source file.
154675
+ // Source file ID -> symbol ID -> Whether the symbol has been searched for in the source file.
154640
154676
  this.sourceFileToSeenSymbols = [];
154641
154677
  }
154642
154678
  includesSourceFile(sourceFile) {
@@ -163477,7 +163513,7 @@ function getSmartSelectionRange(pos, sourceFile) {
163477
163513
  if (start2 !== end) {
163478
163514
  const textSpan = createTextSpanFromBounds(start2, end);
163479
163515
  if (!selectionRange || // Skip ranges that are identical to the parent
163480
- !textSpansEqual(textSpan, selectionRange.textSpan) && // Skip ranges that dont contain the original position
163516
+ !textSpansEqual(textSpan, selectionRange.textSpan) && // Skip ranges that don't contain the original position
163481
163517
  textSpanIntersectsWithPosition(textSpan, pos)) {
163482
163518
  selectionRange = { textSpan, ...selectionRange && { parent: selectionRange } };
163483
163519
  }
@@ -168528,6 +168564,8 @@ __export(ts_exports2, {
168528
168564
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
168529
168565
  canProduceDiagnostics: () => canProduceDiagnostics,
168530
168566
  canUsePropertyAccess: () => canUsePropertyAccess,
168567
+ canWatchAffectingLocation: () => canWatchAffectingLocation,
168568
+ canWatchAtTypes: () => canWatchAtTypes,
168531
168569
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
168532
168570
  cartesianProduct: () => cartesianProduct,
168533
168571
  cast: () => cast,
@@ -168975,6 +169013,8 @@ __export(ts_exports2, {
168975
169013
  getDiagnosticText: () => getDiagnosticText,
168976
169014
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
168977
169015
  getDirectoryPath: () => getDirectoryPath,
169016
+ getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
169017
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
168978
169018
  getDocumentPositionMapper: () => getDocumentPositionMapper,
168979
169019
  getESModuleInterop: () => getESModuleInterop,
168980
169020
  getEditsForFileRename: () => getEditsForFileRename,
@@ -169244,6 +169284,7 @@ __export(ts_exports2, {
169244
169284
  getRestParameterElementType: () => getRestParameterElementType,
169245
169285
  getRightMostAssignedExpression: () => getRightMostAssignedExpression,
169246
169286
  getRootDeclaration: () => getRootDeclaration,
169287
+ getRootDirectoryOfResolutionCache: () => getRootDirectoryOfResolutionCache,
169247
169288
  getRootLength: () => getRootLength,
169248
169289
  getScriptKind: () => getScriptKind,
169249
169290
  getScriptKindFromFileName: () => getScriptKindFromFileName,
@@ -170341,6 +170382,7 @@ __export(ts_exports2, {
170341
170382
  setValueDeclaration: () => setValueDeclaration,
170342
170383
  shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
170343
170384
  shouldPreserveConstEnums: () => shouldPreserveConstEnums,
170385
+ shouldResolveJsRequire: () => shouldResolveJsRequire,
170344
170386
  shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
170345
170387
  showModuleSpecifier: () => showModuleSpecifier,
170346
170388
  signatureHasLiteralTypes: () => signatureHasLiteralTypes,
@@ -182494,6 +182536,8 @@ start(initializeNodeSystem(), require("os").platform());
182494
182536
  canJsonReportNoInputFiles,
182495
182537
  canProduceDiagnostics,
182496
182538
  canUsePropertyAccess,
182539
+ canWatchAffectingLocation,
182540
+ canWatchAtTypes,
182497
182541
  canWatchDirectoryOrFile,
182498
182542
  cartesianProduct,
182499
182543
  cast,
@@ -182941,6 +182985,8 @@ start(initializeNodeSystem(), require("os").platform());
182941
182985
  getDiagnosticText,
182942
182986
  getDiagnosticsWithinSpan,
182943
182987
  getDirectoryPath,
182988
+ getDirectoryToWatchFailedLookupLocation,
182989
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot,
182944
182990
  getDocumentPositionMapper,
182945
182991
  getESModuleInterop,
182946
182992
  getEditsForFileRename,
@@ -183210,6 +183256,7 @@ start(initializeNodeSystem(), require("os").platform());
183210
183256
  getRestParameterElementType,
183211
183257
  getRightMostAssignedExpression,
183212
183258
  getRootDeclaration,
183259
+ getRootDirectoryOfResolutionCache,
183213
183260
  getRootLength,
183214
183261
  getScriptKind,
183215
183262
  getScriptKindFromFileName,
@@ -184307,6 +184354,7 @@ start(initializeNodeSystem(), require("os").platform());
184307
184354
  setValueDeclaration,
184308
184355
  shouldAllowImportingTsExtension,
184309
184356
  shouldPreserveConstEnums,
184357
+ shouldResolveJsRequire,
184310
184358
  shouldUseUriStyleNodeCoreModules,
184311
184359
  showModuleSpecifier,
184312
184360
  signatureHasLiteralTypes,