typescript 4.7.0-dev.20220427 → 4.7.0-dev.20220430

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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220427";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220430";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8465,7 +8465,7 @@ var ts;
8465
8465
  Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
8466
8466
  Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."),
8467
8467
  Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
8468
- Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
8468
+ This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."),
8469
8469
  String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
8470
8470
  Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."),
8471
8471
  _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"),
@@ -8852,7 +8852,6 @@ var ts;
8852
8852
  A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."),
8853
8853
  Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."),
8854
8854
  Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"),
8855
- Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."),
8856
8855
  Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"),
8857
8856
  Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
8858
8857
  A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."),
@@ -9066,6 +9065,7 @@ var ts;
9066
9065
  This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
9067
9066
  A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
9068
9067
  Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
9068
+ Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."),
9069
9069
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
9070
9070
  Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
9071
9071
  Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -38156,7 +38156,8 @@ var ts;
38156
38156
  if (!comment) {
38157
38157
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
38158
38158
  }
38159
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
38159
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
38160
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
38160
38161
  }
38161
38162
  function escapedTextsEqual(a, b) {
38162
38163
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -75786,8 +75787,14 @@ var ts;
75786
75787
  var parameterRange = hasRestParameter ? min
75787
75788
  : min < max ? min + "-" + max
75788
75789
  : min;
75789
- var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75790
- : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75790
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
75791
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
75792
+ return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments);
75793
+ }
75794
+ var error = hasRestParameter
75795
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75796
+ : isVoidPromiseError
75797
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75791
75798
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
75792
75799
  if (min < args.length && args.length < max) {
75793
75800
  // between min and max, but with no matching overload
@@ -82839,7 +82846,7 @@ var ts;
82839
82846
  }
82840
82847
  var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined);
82841
82848
  if (yieldType) {
82842
- return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false];
82849
+ return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false];
82843
82850
  }
82844
82851
  if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) {
82845
82852
  return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true];
@@ -86116,7 +86123,7 @@ var ts;
86116
86123
  var symbol = getIntrinsicTagSymbol(name.parent);
86117
86124
  return symbol === unknownSymbol ? undefined : symbol;
86118
86125
  }
86119
- var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name));
86126
+ var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name));
86120
86127
  if (!result && isJSDoc_1) {
86121
86128
  var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration));
86122
86129
  if (container) {
@@ -87973,6 +87980,9 @@ var ts;
87973
87980
  return ts.some(types, checkGrammarExpressionWithTypeArguments);
87974
87981
  }
87975
87982
  function checkGrammarExpressionWithTypeArguments(node) {
87983
+ if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) {
87984
+ return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments);
87985
+ }
87976
87986
  return checkGrammarTypeArguments(node, node.typeArguments);
87977
87987
  }
87978
87988
  function checkGrammarClassDeclarationHeritageClauses(node) {
@@ -88914,7 +88924,7 @@ var ts;
88914
88924
  return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext);
88915
88925
  }
88916
88926
  if (node.typeArguments) {
88917
- return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
88927
+ return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments);
88918
88928
  }
88919
88929
  var nodeArguments = node.arguments;
88920
88930
  if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
@@ -108710,6 +108720,8 @@ var ts;
108710
108720
  var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
108711
108721
  errorFallbackNode = undefined;
108712
108722
  var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
108723
+ preserveJsDoc(statement, input);
108724
+ ts.removeAllComments(input);
108713
108725
  return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
108714
108726
  }
108715
108727
  }
@@ -125094,7 +125106,7 @@ var ts;
125094
125106
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125095
125107
  return;
125096
125108
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125097
- createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
125109
+ createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
125098
125110
  onDeleteValue: ts.closeFileWatcher,
125099
125111
  });
125100
125112
  }
@@ -125839,6 +125851,17 @@ var ts;
125839
125851
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName";
125840
125852
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText";
125841
125853
  })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {}));
125854
+ // Do not change existing values, as they exist in telemetry.
125855
+ var CompletionInfoFlags;
125856
+ (function (CompletionInfoFlags) {
125857
+ CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None";
125858
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports";
125859
+ CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion";
125860
+ CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation";
125861
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers";
125862
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit";
125863
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets";
125864
+ })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {}));
125842
125865
  var OutliningSpanKind;
125843
125866
  (function (OutliningSpanKind) {
125844
125867
  /** Single or multi-line comments */
@@ -127851,6 +127874,14 @@ var ts;
127851
127874
  return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } });
127852
127875
  }
127853
127876
  ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost;
127877
+ function moduleResolutionRespectsExports(moduleResolution) {
127878
+ return moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127879
+ }
127880
+ ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports;
127881
+ function moduleResolutionUsesNodeModules(moduleResolution) {
127882
+ return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127883
+ }
127884
+ ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules;
127854
127885
  function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
127855
127886
  return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined;
127856
127887
  }
@@ -129454,8 +129485,8 @@ var ts;
129454
129485
  if (from === to)
129455
129486
  return false;
129456
129487
  var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences, {});
129457
- if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) {
129458
- return cachedResult.isAutoImportable;
129488
+ if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) {
129489
+ return !cachedResult.isBlockedByPackageJsonDependencies;
129459
129490
  }
129460
129491
  var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost);
129461
129492
  var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost);
@@ -129469,7 +129500,7 @@ var ts;
129469
129500
  });
129470
129501
  if (packageJsonFilter) {
129471
129502
  var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost);
129472
- moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable);
129503
+ moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable);
129473
129504
  return isAutoImportable;
129474
129505
  }
129475
129506
  return hasImportablePath;
@@ -131748,15 +131779,26 @@ var ts;
131748
131779
  var _a, _b, _c;
131749
131780
  var start = ts.timestamp();
131750
131781
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131751
- var resolutionLimitExceeded = false;
131782
+ // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
131783
+ // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
131784
+ // relative path into node_modules), and we want to filter those completions out entirely.
131785
+ // Import statement completions always need specifier resolution because the module specifier is
131786
+ // part of their `insertText`, not the `codeActions` creating edits away from the cursor.
131787
+ var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions()));
131788
+ var skippedAny = false;
131752
131789
  var ambientCount = 0;
131753
131790
  var resolvedCount = 0;
131754
131791
  var resolvedFromCacheCount = 0;
131755
131792
  var cacheAttemptCount = 0;
131756
- var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } });
131793
+ var result = cb({
131794
+ tryResolve: tryResolve,
131795
+ skippedAny: function () { return skippedAny; },
131796
+ resolvedAny: function () { return resolvedCount > 0; },
131797
+ resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; },
131798
+ });
131757
131799
  var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : "";
131758
131800
  (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage);
131759
- (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete"));
131801
+ (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete"));
131760
131802
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131761
131803
  return result;
131762
131804
  function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
@@ -131765,22 +131807,22 @@ var ts;
131765
131807
  if (result_1) {
131766
131808
  ambientCount++;
131767
131809
  }
131768
- return result_1;
131810
+ return result_1 || "failed";
131769
131811
  }
131770
- var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131812
+ var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131771
131813
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131772
131814
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131773
131815
  ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131774
131816
  : undefined;
131775
131817
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131776
- resolutionLimitExceeded = true;
131818
+ skippedAny = true;
131777
131819
  }
131778
131820
  resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0;
131779
- resolvedFromCacheCount += exportInfo.length - resolvedCount;
131821
+ resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0);
131780
131822
  if (shouldGetModuleSpecifierFromCache) {
131781
131823
  cacheAttemptCount++;
131782
131824
  }
131783
- return result;
131825
+ return result || (needsFullResolution ? "failed" : "skipped");
131784
131826
  }
131785
131827
  }
131786
131828
  function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
@@ -131878,6 +131920,7 @@ var ts;
131878
131920
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131879
131921
  /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131880
131922
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131923
+ var _a;
131881
131924
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131882
131925
  // Not an auto import or already resolved; keep as is
131883
131926
  return entry;
@@ -131889,8 +131932,12 @@ var ts;
131889
131932
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131890
131933
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131891
131934
  var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131892
- if (!result)
131935
+ if (result === "skipped")
131893
131936
  return entry;
131937
+ if (!result || result === "failed") {
131938
+ (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'");
131939
+ return undefined;
131940
+ }
131894
131941
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
131895
131942
  // Mutating for performance... feels sketchy but nobody else uses the cache,
131896
131943
  // so why bother allocating a bunch of new objects?
@@ -131899,12 +131946,13 @@ var ts;
131899
131946
  entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)];
131900
131947
  return entry;
131901
131948
  });
131902
- if (!context.resolutionLimitExceeded()) {
131949
+ if (!context.skippedAny()) {
131903
131950
  previousResponse.isIncomplete = undefined;
131904
131951
  }
131905
131952
  return entries;
131906
131953
  });
131907
131954
  previousResponse.entries = newEntries;
131955
+ previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */;
131908
131956
  return previousResponse;
131909
131957
  }
131910
131958
  function jsdocCompletionInfo(entries) {
@@ -131986,12 +132034,13 @@ var ts;
131986
132034
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
131987
132035
  }
131988
132036
  return {
132037
+ flags: completionData.flags,
131989
132038
  isGlobalCompletion: isInSnippetScope,
131990
132039
  isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined,
131991
132040
  isMemberCompletion: isMemberCompletionKind(completionKind),
131992
132041
  isNewIdentifierLocation: isNewIdentifierLocation,
131993
132042
  optionalReplacementSpan: getOptionalReplacementSpan(location),
131994
- entries: entries
132043
+ entries: entries,
131995
132044
  };
131996
132045
  }
131997
132046
  function isUncheckedFile(sourceFile, compilerOptions) {
@@ -133048,6 +133097,7 @@ var ts;
133048
133097
  var location = ts.getTouchingPropertyName(sourceFile, position);
133049
133098
  var keywordFilters = 0 /* None */;
133050
133099
  var isNewIdentifierLocation = false;
133100
+ var flags = 0 /* None */;
133051
133101
  if (contextToken) {
133052
133102
  var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
133053
133103
  isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
@@ -133067,6 +133117,7 @@ var ts;
133067
133117
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
133068
133118
  // to opt in with the `includeCompletionsForImportStatements` user preference.
133069
133119
  importCompletionNode = importStatementCompletion.replacementNode;
133120
+ flags |= 2 /* IsImportStatementCompletion */;
133070
133121
  }
133071
133122
  // Bail out if this is a known invalid completion location
133072
133123
  if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
@@ -133259,6 +133310,7 @@ var ts;
133259
133310
  isRightOfOpenTag: isRightOfOpenTag,
133260
133311
  importCompletionNode: importCompletionNode,
133261
133312
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
133313
+ flags: flags,
133262
133314
  };
133263
133315
  function isTagWithTypeExpression(tag) {
133264
133316
  switch (tag.kind) {
@@ -133668,6 +133720,7 @@ var ts;
133668
133720
  // Asking for completion details for an item that is not an auto-import
133669
133721
  return;
133670
133722
  }
133723
+ flags |= 1 /* MayIncludeAutoImports */;
133671
133724
  // import { type | -> token text should be blank
133672
133725
  var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
133673
133726
  && importCompletionNode
@@ -133698,16 +133751,36 @@ var ts;
133698
133751
  return true;
133699
133752
  return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
133700
133753
  }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
133754
+ var _a;
133701
133755
  if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
133702
133756
  return;
133703
133757
  }
133704
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
133705
- if (!defaultExportInfo) {
133758
+ // Do a relatively cheap check to bail early if all re-exports are non-importable
133759
+ // due to file location or package.json dependency filtering. For non-node12+
133760
+ // module resolution modes, getting past this point guarantees that we'll be
133761
+ // able to generate a suitable module specifier, so we can safely show a completion,
133762
+ // even if we defer computing the module specifier.
133763
+ var firstImportableExportInfo = ts.find(info, isImportableExportInfo);
133764
+ if (!firstImportableExportInfo) {
133706
133765
  return;
133707
133766
  }
133708
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
133709
- // (We need to ensure that at least one is importable to show a completion.)
133710
- var _a = context.tryResolve(info, symbolName, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
133767
+ // In node12+, module specifier resolution can fail due to modules being blocked
133768
+ // by package.json `exports`. If that happens, don't show a completion item.
133769
+ // N.B. in this resolution mode we always try to resolve module specifiers here,
133770
+ // because we have to know now if it's going to fail so we can omit the completion
133771
+ // from the list.
133772
+ var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {};
133773
+ if (result === "failed")
133774
+ return;
133775
+ // If we skipped resolving module specifiers, our selection of which ExportInfo
133776
+ // to use here is arbitrary, since the info shown in the completion list derived from
133777
+ // it should be identical regardless of which one is used. During the subsequent
133778
+ // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick
133779
+ // the best one based on the module specifier it produces.
133780
+ var exportInfo = firstImportableExportInfo, moduleSpecifier;
133781
+ if (result !== "skipped") {
133782
+ (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier);
133783
+ }
133711
133784
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
133712
133785
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
133713
133786
  pushAutoImportSymbol(symbol, {
@@ -133722,7 +133795,9 @@ var ts;
133722
133795
  isFromPackageJson: exportInfo.isFromPackageJson,
133723
133796
  });
133724
133797
  });
133725
- hasUnresolvedAutoImports = context.resolutionLimitExceeded();
133798
+ hasUnresolvedAutoImports = context.skippedAny();
133799
+ flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0;
133800
+ flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0;
133726
133801
  });
133727
133802
  function isImportableExportInfo(info) {
133728
133803
  var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile);
@@ -133770,6 +133845,7 @@ var ts;
133770
133845
  return;
133771
133846
  }
133772
133847
  var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
133848
+ flags |= 32 /* MayIncludeMethodSnippets */;
133773
133849
  symbolToOriginInfoMap[symbols.length] = origin;
133774
133850
  symbols.push(member);
133775
133851
  });
@@ -133966,7 +134042,7 @@ var ts;
133966
134042
  // through type declaration or inference.
133967
134043
  // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
133968
134044
  // type of parameter will flow in from the contextual type of the function
133969
- var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */;
134045
+ var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */;
133970
134046
  if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) {
133971
134047
  if (ts.isExpression(rootDeclaration.parent)) {
133972
134048
  canGetType = !!typeChecker.getContextualType(rootDeclaration.parent);
@@ -135241,6 +135317,8 @@ var ts;
135241
135317
  return highlightSpans(getAsyncAndAwaitOccurrences(node));
135242
135318
  case 125 /* YieldKeyword */:
135243
135319
  return highlightSpans(getYieldOccurrences(node));
135320
+ case 101 /* InKeyword */:
135321
+ return undefined;
135244
135322
  default:
135245
135323
  return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent))
135246
135324
  ? highlightSpans(getModifierOccurrences(node.kind, node.parent))
@@ -150009,7 +150087,7 @@ var ts;
150009
150087
  ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code,
150010
150088
  ts.Diagnostics.Type_0_is_not_an_array_type.code,
150011
150089
  ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code,
150012
- ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code,
150090
+ ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code,
150013
150091
  ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
150014
150092
  ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
150015
150093
  ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
@@ -152963,6 +153041,7 @@ var ts;
152963
153041
  var compilerOptions = program.getCompilerOptions();
152964
153042
  var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
152965
153043
  var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
153044
+ var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions));
152966
153045
  var getModuleSpecifiers = fromCacheOnly
152967
153046
  ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
152968
153047
  : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
@@ -152973,19 +153052,19 @@ var ts;
152973
153052
  var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
152974
153053
  var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions);
152975
153054
  computedWithoutCacheCount += computedWithoutCache ? 1 : 0;
152976
- return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
152977
- // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
152978
- return !importedSymbolHasValueMeaning && isJs && position !== undefined
152979
- ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
152980
- : {
152981
- kind: 3 /* AddNew */,
152982
- moduleSpecifier: moduleSpecifier,
152983
- importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
152984
- useRequire: useRequire,
152985
- addAsTypeOnly: addAsTypeOnly,
152986
- exportInfo: exportInfo,
152987
- isReExport: i > 0,
152988
- };
153055
+ return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) {
153056
+ return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined :
153057
+ // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
153058
+ !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } :
153059
+ {
153060
+ kind: 3 /* AddNew */,
153061
+ moduleSpecifier: moduleSpecifier,
153062
+ importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
153063
+ useRequire: useRequire,
153064
+ addAsTypeOnly: addAsTypeOnly,
153065
+ exportInfo: exportInfo,
153066
+ isReExport: i > 0,
153067
+ };
152989
153068
  });
152990
153069
  });
152991
153070
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
@@ -158558,6 +158637,7 @@ var ts;
158558
158637
  var fixName = "addVoidToPromise";
158559
158638
  var fixId = "addVoidToPromise";
158560
158639
  var errorCodes = [
158640
+ ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
158561
158641
  ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
158562
158642
  ];
158563
158643
  codefix.registerCodeFix({
@@ -174124,7 +174204,7 @@ var ts;
174124
174204
  return cache.get(toFileName);
174125
174205
  },
174126
174206
  set: function (fromFileName, toFileName, preferences, options, modulePaths, moduleSpecifiers) {
174127
- ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isAutoImportable*/ true));
174207
+ ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false));
174128
174208
  // If any module specifiers were generated based off paths in node_modules,
174129
174209
  // a package.json file in that package was read and is an input to the cached.
174130
174210
  // Instead of watching each individual package.json file, set up a wildcard
@@ -174150,17 +174230,17 @@ var ts;
174150
174230
  info.modulePaths = modulePaths;
174151
174231
  }
174152
174232
  else {
174153
- cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isAutoImportable*/ undefined));
174233
+ cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined));
174154
174234
  }
174155
174235
  },
174156
- setIsAutoImportable: function (fromFileName, toFileName, preferences, options, isAutoImportable) {
174236
+ setBlockedByPackageJsonDependencies: function (fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) {
174157
174237
  var cache = ensureCache(fromFileName, preferences, options);
174158
174238
  var info = cache.get(toFileName);
174159
174239
  if (info) {
174160
- info.isAutoImportable = isAutoImportable;
174240
+ info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies;
174161
174241
  }
174162
174242
  else {
174163
- cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isAutoImportable));
174243
+ cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies));
174164
174244
  }
174165
174245
  },
174166
174246
  clear: function () {
@@ -174188,8 +174268,8 @@ var ts;
174188
174268
  function key(fromFileName, preferences, options) {
174189
174269
  return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode;
174190
174270
  }
174191
- function createInfo(modulePaths, moduleSpecifiers, isAutoImportable) {
174192
- return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isAutoImportable: isAutoImportable };
174271
+ function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) {
174272
+ return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies };
174193
174273
  }
174194
174274
  }
174195
174275
  server.createModuleSpecifierCache = createModuleSpecifierCache;
@@ -6435,7 +6435,18 @@ declare namespace ts {
6435
6435
  argumentIndex: number;
6436
6436
  argumentCount: number;
6437
6437
  }
6438
+ enum CompletionInfoFlags {
6439
+ None = 0,
6440
+ MayIncludeAutoImports = 1,
6441
+ IsImportStatementCompletion = 2,
6442
+ IsContinuation = 4,
6443
+ ResolvedModuleSpecifiers = 8,
6444
+ ResolvedModuleSpecifiersBeyondLimit = 16,
6445
+ MayIncludeMethodSnippets = 32
6446
+ }
6438
6447
  interface CompletionInfo {
6448
+ /** For performance telemetry. */
6449
+ flags?: CompletionInfoFlags;
6439
6450
  /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */
6440
6451
  isGlobalCompletion: boolean;
6441
6452
  isMemberCompletion: boolean;