typescript 5.1.0-dev.20230301 → 5.1.0-dev.20230302

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.1";
26
- var version = `${versionMajorMinor}.0-dev.20230301`;
26
+ var version = `${versionMajorMinor}.0-dev.20230302`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -899,10 +899,6 @@ function cast(value, test) {
899
899
  }
900
900
  function noop(_) {
901
901
  }
902
- var noopPush = {
903
- push: noop,
904
- length: 0
905
- };
906
902
  function returnFalse() {
907
903
  return false;
908
904
  }
@@ -7172,6 +7168,7 @@ var Diagnostics = {
7172
7168
  File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
7173
7169
  Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
7174
7170
  Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
7171
+ Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder: diag(6265, 3 /* Message */, "Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_no_6265", "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder."),
7175
7172
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
7176
7173
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
7177
7174
  Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
@@ -7567,6 +7564,8 @@ var Diagnostics = {
7567
7564
  This_may_be_converted_to_an_async_function: diag(80006, 2 /* Suggestion */, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."),
7568
7565
  await_has_no_effect_on_the_type_of_this_expression: diag(80007, 2 /* Suggestion */, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."),
7569
7566
  Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, 2 /* Suggestion */, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."),
7567
+ JSDoc_typedef_may_be_converted_to_TypeScript_type: diag(80009, 2 /* Suggestion */, "JSDoc_typedef_may_be_converted_to_TypeScript_type_80009", "JSDoc typedef may be converted to TypeScript type."),
7568
+ JSDoc_typedefs_may_be_converted_to_TypeScript_types: diag(80010, 2 /* Suggestion */, "JSDoc_typedefs_may_be_converted_to_TypeScript_types_80010", "JSDoc typedefs may be converted to TypeScript types."),
7570
7569
  Add_missing_super_call: diag(90001, 3 /* Message */, "Add_missing_super_call_90001", "Add missing 'super()' call"),
7571
7570
  Make_super_call_the_first_statement_in_the_constructor: diag(90002, 3 /* Message */, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"),
7572
7571
  Change_extends_to_implements: diag(90003, 3 /* Message */, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
@@ -7781,6 +7780,8 @@ var Diagnostics = {
7781
7780
  Rename_param_tag_name_0_to_1: diag(95173, 3 /* Message */, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
7782
7781
  Use_0: diag(95174, 3 /* Message */, "Use_0_95174", "Use `{0}`."),
7783
7782
  Use_Number_isNaN_in_all_conditions: diag(95175, 3 /* Message */, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
7783
+ Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
7784
+ Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
7784
7785
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
7785
7786
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
7786
7787
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -36539,20 +36540,14 @@ function getEffectiveTypeRoots(options, host) {
36539
36540
  currentDirectory = host.getCurrentDirectory();
36540
36541
  }
36541
36542
  if (currentDirectory !== void 0) {
36542
- return getDefaultTypeRoots(currentDirectory, host);
36543
+ return getDefaultTypeRoots(currentDirectory);
36543
36544
  }
36544
36545
  }
36545
- function getDefaultTypeRoots(currentDirectory, host) {
36546
- if (!host.directoryExists) {
36547
- return [combinePaths(currentDirectory, nodeModulesAtTypes)];
36548
- }
36546
+ function getDefaultTypeRoots(currentDirectory) {
36549
36547
  let typeRoots;
36550
36548
  forEachAncestorDirectory(normalizePath(currentDirectory), (directory) => {
36551
36549
  const atTypes = combinePaths(directory, nodeModulesAtTypes);
36552
- if (host.directoryExists(atTypes)) {
36553
- (typeRoots || (typeRoots = [])).push(atTypes);
36554
- }
36555
- return void 0;
36550
+ (typeRoots != null ? typeRoots : typeRoots = []).push(atTypes);
36556
36551
  });
36557
36552
  return typeRoots;
36558
36553
  }
@@ -36689,10 +36684,22 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
36689
36684
  }
36690
36685
  return firstDefined(typeRoots, (typeRoot) => {
36691
36686
  const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
36692
- const candidateDirectory = getDirectoryPath(candidate);
36693
- const directoryExists = directoryProbablyExists(candidateDirectory, host);
36687
+ const directoryExists = directoryProbablyExists(typeRoot, host);
36694
36688
  if (!directoryExists && traceEnabled) {
36695
- trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
36689
+ trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
36690
+ }
36691
+ if (options.typeRoots) {
36692
+ const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, moduleResolutionState);
36693
+ if (resolvedFromFile) {
36694
+ const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
36695
+ const packageInfo = packageDirectory ? getPackageJsonInfo(
36696
+ packageDirectory,
36697
+ /*onlyRecordFailures*/
36698
+ false,
36699
+ moduleResolutionState
36700
+ ) : void 0;
36701
+ return resolvedTypeScriptOnly(withPackageId(packageInfo, resolvedFromFile));
36702
+ }
36696
36703
  }
36697
36704
  return resolvedTypeScriptOnly(
36698
36705
  loadNodeModuleFromDirectory(
@@ -36712,33 +36719,37 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
36712
36719
  function secondaryLookup() {
36713
36720
  const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
36714
36721
  if (initialLocationForSecondaryLookup !== void 0) {
36715
- if (traceEnabled) {
36716
- trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
36717
- }
36718
36722
  let result2;
36719
- if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
36720
- const searchResult = loadModuleFromNearestNodeModulesDirectory(
36721
- 4 /* Declaration */,
36722
- typeReferenceDirectiveName,
36723
- initialLocationForSecondaryLookup,
36724
- moduleResolutionState,
36725
- /*cache*/
36726
- void 0,
36727
- /*redirectedReference*/
36728
- void 0
36729
- );
36730
- result2 = searchResult && searchResult.value;
36731
- } else {
36732
- const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
36733
- result2 = nodeLoadModuleByRelativeName(
36734
- 4 /* Declaration */,
36735
- candidate,
36736
- /*onlyRecordFailures*/
36737
- false,
36738
- moduleResolutionState,
36739
- /*considerPackageJson*/
36740
- true
36741
- );
36723
+ if (!options.typeRoots || !endsWith(containingFile, inferredTypesContainingFile)) {
36724
+ if (traceEnabled) {
36725
+ trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
36726
+ }
36727
+ if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
36728
+ const searchResult = loadModuleFromNearestNodeModulesDirectory(
36729
+ 4 /* Declaration */,
36730
+ typeReferenceDirectiveName,
36731
+ initialLocationForSecondaryLookup,
36732
+ moduleResolutionState,
36733
+ /*cache*/
36734
+ void 0,
36735
+ /*redirectedReference*/
36736
+ void 0
36737
+ );
36738
+ result2 = searchResult && searchResult.value;
36739
+ } else {
36740
+ const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
36741
+ result2 = nodeLoadModuleByRelativeName(
36742
+ 4 /* Declaration */,
36743
+ candidate,
36744
+ /*onlyRecordFailures*/
36745
+ false,
36746
+ moduleResolutionState,
36747
+ /*considerPackageJson*/
36748
+ true
36749
+ );
36750
+ }
36751
+ } else if (traceEnabled) {
36752
+ trace(host, Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder);
36742
36753
  }
36743
36754
  return resolvedTypeScriptOnly(result2);
36744
36755
  } else {
@@ -37532,6 +37543,9 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
37532
37543
  }
37533
37544
  resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
37534
37545
  }
37546
+ if (extensions2 & 4 /* Declaration */) {
37547
+ resolved2 != null ? resolved2 : resolved2 = resolveFromTypeRoot(moduleName, state2);
37548
+ }
37535
37549
  return resolved2 && { value: resolved2.value && { resolved: resolved2.value, isExternalLibraryImport: true } };
37536
37550
  } else {
37537
37551
  const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName);
@@ -37712,6 +37726,7 @@ function tryFile(fileName, onlyRecordFailures, state) {
37712
37726
  return forEach(state.compilerOptions.moduleSuffixes, (suffix) => tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state));
37713
37727
  }
37714
37728
  function tryFileLookup(fileName, onlyRecordFailures, state) {
37729
+ var _a2;
37715
37730
  if (!onlyRecordFailures) {
37716
37731
  if (state.host.fileExists(fileName)) {
37717
37732
  if (state.traceEnabled) {
@@ -37724,7 +37739,7 @@ function tryFileLookup(fileName, onlyRecordFailures, state) {
37724
37739
  }
37725
37740
  }
37726
37741
  }
37727
- state.failedLookupLocations.push(fileName);
37742
+ (_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(fileName);
37728
37743
  return void 0;
37729
37744
  }
37730
37745
  function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson = true) {
@@ -37738,8 +37753,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
37738
37753
  host,
37739
37754
  compilerOptions: options,
37740
37755
  traceEnabled: isTraceEnabled(options, host),
37741
- failedLookupLocations: noopPush,
37742
- affectingLocations: noopPush,
37756
+ failedLookupLocations: void 0,
37757
+ affectingLocations: void 0,
37743
37758
  packageJsonInfoCache,
37744
37759
  features: 0 /* None */,
37745
37760
  conditions: emptyArray,
@@ -37773,24 +37788,24 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) {
37773
37788
  return packageJsonInfo.contents.versionPaths || void 0;
37774
37789
  }
37775
37790
  function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
37776
- var _a2, _b, _c;
37791
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
37777
37792
  const { host, traceEnabled } = state;
37778
37793
  const packageJsonPath = combinePaths(packageDirectory, "package.json");
37779
37794
  if (onlyRecordFailures) {
37780
- state.failedLookupLocations.push(packageJsonPath);
37795
+ (_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(packageJsonPath);
37781
37796
  return void 0;
37782
37797
  }
37783
- const existing = (_a2 = state.packageJsonInfoCache) == null ? void 0 : _a2.getPackageJsonInfo(packageJsonPath);
37798
+ const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
37784
37799
  if (existing !== void 0) {
37785
37800
  if (typeof existing !== "boolean") {
37786
37801
  if (traceEnabled)
37787
37802
  trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
37788
- state.affectingLocations.push(packageJsonPath);
37803
+ (_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
37789
37804
  return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
37790
37805
  } else {
37791
37806
  if (existing && traceEnabled)
37792
37807
  trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
37793
- state.failedLookupLocations.push(packageJsonPath);
37808
+ (_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
37794
37809
  return void 0;
37795
37810
  }
37796
37811
  }
@@ -37801,15 +37816,15 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
37801
37816
  trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
37802
37817
  }
37803
37818
  const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
37804
- (_b = state.packageJsonInfoCache) == null ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
37805
- state.affectingLocations.push(packageJsonPath);
37819
+ (_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
37820
+ (_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
37806
37821
  return result;
37807
37822
  } else {
37808
37823
  if (directoryExists && traceEnabled) {
37809
37824
  trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
37810
37825
  }
37811
- (_c = state.packageJsonInfoCache) == null ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists);
37812
- state.failedLookupLocations.push(packageJsonPath);
37826
+ (_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
37827
+ (_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
37813
37828
  }
37814
37829
  }
37815
37830
  function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
@@ -38630,11 +38645,13 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
38630
38645
  state
38631
38646
  ));
38632
38647
  });
38633
- if (resolved2) {
38648
+ if (resolved2)
38634
38649
  return resolved2;
38635
- }
38636
38650
  if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
38637
- return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
38651
+ let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
38652
+ if (extensions & 4 /* Declaration */)
38653
+ resolved3 != null ? resolved3 : resolved3 = resolveFromTypeRoot(moduleName, state);
38654
+ return resolved3;
38638
38655
  }
38639
38656
  } else {
38640
38657
  const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
@@ -38648,6 +38665,31 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
38648
38665
  }
38649
38666
  }
38650
38667
  }
38668
+ function resolveFromTypeRoot(moduleName, state) {
38669
+ if (!state.compilerOptions.typeRoots)
38670
+ return;
38671
+ for (const typeRoot of state.compilerOptions.typeRoots) {
38672
+ const candidate = combinePaths(typeRoot, moduleName);
38673
+ const directoryExists = directoryProbablyExists(typeRoot, state.host);
38674
+ if (!directoryExists && state.traceEnabled) {
38675
+ trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
38676
+ }
38677
+ const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, state);
38678
+ if (resolvedFromFile) {
38679
+ const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
38680
+ const packageInfo = packageDirectory ? getPackageJsonInfo(
38681
+ packageDirectory,
38682
+ /*onlyRecordFailures*/
38683
+ false,
38684
+ state
38685
+ ) : void 0;
38686
+ return toSearchResult(withPackageId(packageInfo, resolvedFromFile));
38687
+ }
38688
+ const resolved = loadNodeModuleFromDirectory(4 /* Declaration */, candidate, !directoryExists, state);
38689
+ if (resolved)
38690
+ return toSearchResult(resolved);
38691
+ }
38692
+ }
38651
38693
  function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
38652
38694
  return !!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName);
38653
38695
  }
@@ -51592,7 +51634,11 @@ function createTypeChecker(host) {
51592
51634
  const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
51593
51635
  return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
51594
51636
  } else {
51595
- return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type;
51637
+ return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
51638
+ type,
51639
+ /*isProperty*/
51640
+ true
51641
+ ) : type;
51596
51642
  }
51597
51643
  }
51598
51644
  function getTypeOfEnumMember(symbol) {
@@ -60293,6 +60339,7 @@ function createTypeChecker(host) {
60293
60339
  } else if (targetFlags & 8388608 /* IndexedAccess */) {
60294
60340
  if (sourceFlags & 8388608 /* IndexedAccess */) {
60295
60341
  if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
60342
+ instantiateType(source2.objectType, reportUnreliableMapper);
60296
60343
  result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
60297
60344
  }
60298
60345
  if (result2) {
@@ -63438,7 +63485,7 @@ function createTypeChecker(host) {
63438
63485
  );
63439
63486
  }
63440
63487
  function isInAmbientOrTypeNode(node) {
63441
- return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeLiteralNode(n)));
63488
+ return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeAliasDeclaration(n) || isTypeLiteralNode(n)));
63442
63489
  }
63443
63490
  function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
63444
63491
  switch (node.kind) {
@@ -66586,6 +66633,16 @@ function createTypeChecker(host) {
66586
66633
  const symbol = getSymbolOfDeclaration(element);
66587
66634
  return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
66588
66635
  }
66636
+ if (hasDynamicName(element)) {
66637
+ const name = getNameOfDeclaration(element);
66638
+ if (name && isComputedPropertyName(name)) {
66639
+ const exprType = checkExpression(name.expression);
66640
+ const propType = isTypeUsableAsPropertyName(exprType) && getTypeOfPropertyOfContextualType(type, getPropertyNameFromType(exprType));
66641
+ if (propType) {
66642
+ return propType;
66643
+ }
66644
+ }
66645
+ }
66589
66646
  if (element.name) {
66590
66647
  const nameType = getLiteralTypeFromPropertyName(element.name);
66591
66648
  return mapType(
@@ -71359,7 +71416,7 @@ function createTypeChecker(host) {
71359
71416
  }
71360
71417
  function getNonArrayRestType(signature) {
71361
71418
  const restType = getEffectiveRestType(signature);
71362
- return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : void 0;
71419
+ return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : void 0;
71363
71420
  }
71364
71421
  function getTypeOfFirstParameterOfSignature(signature) {
71365
71422
  return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
@@ -76173,6 +76230,9 @@ function createTypeChecker(host) {
76173
76230
  return;
76174
76231
  }
76175
76232
  if (isBindingPattern(node.name)) {
76233
+ if (isInAmbientOrTypeNode(node)) {
76234
+ return;
76235
+ }
76176
76236
  const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 246 /* ForInStatement */;
76177
76237
  const needCheckWidenedType = !some(node.name.elements, not(isOmittedExpression));
76178
76238
  if (needCheckInitializer || needCheckWidenedType) {
@@ -118524,7 +118584,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118524
118584
  return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
118525
118585
  }
118526
118586
  function createTypeRootsWatch(typeRootPath, typeRoot) {
118527
- return resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
118587
+ return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
118528
118588
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
118529
118589
  if (cachedDirectoryStructureHost) {
118530
118590
  cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
@@ -118535,7 +118595,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118535
118595
  if (dirPath) {
118536
118596
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
118537
118597
  }
118538
- }, 1 /* Recursive */);
118598
+ }, 1 /* Recursive */) : noopFileWatcher;
118539
118599
  }
118540
118600
  function updateTypeRootsWatch() {
118541
118601
  const options = resolutionHost.getCompilationSettings();
@@ -118543,7 +118603,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118543
118603
  closeTypeRootsWatch();
118544
118604
  return;
118545
118605
  }
118546
- const typeRoots = getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory });
118606
+ const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory });
118547
118607
  if (typeRoots) {
118548
118608
  mutateMap(
118549
118609
  typeRootsWatches,
@@ -118557,7 +118617,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118557
118617
  closeTypeRootsWatch();
118558
118618
  }
118559
118619
  }
118560
- function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
118620
+ function canWatchTypeRootPath(nodeTypesDirectory) {
118621
+ if (resolutionHost.getCompilationSettings().typeRoots)
118622
+ return true;
118561
118623
  const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
118562
118624
  const dirPath = resolutionHost.toPath(dir);
118563
118625
  return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);