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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220427";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220430";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -8271,7 +8271,7 @@ var ts;
8271
8271
  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'."),
8272
8272
  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'."),
8273
8273
  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."),
8274
- Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
8274
+ 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."),
8275
8275
  String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
8276
8276
  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."),
8277
8277
  _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}()'?"),
@@ -8658,7 +8658,6 @@ var ts;
8658
8658
  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."),
8659
8659
  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."),
8660
8660
  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}'?"),
8661
- 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."),
8662
8661
  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}'?"),
8663
8662
  Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
8664
8663
  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."),
@@ -8872,6 +8871,7 @@ var ts;
8872
8871
  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}'."),
8873
8872
  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"),
8874
8873
  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."),
8874
+ 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."),
8875
8875
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8876
8876
  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'."),
8877
8877
  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}'."),
@@ -37962,7 +37962,8 @@ var ts;
37962
37962
  if (!comment) {
37963
37963
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
37964
37964
  }
37965
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
37965
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
37966
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
37966
37967
  }
37967
37968
  function escapedTextsEqual(a, b) {
37968
37969
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -75592,8 +75593,14 @@ var ts;
75592
75593
  var parameterRange = hasRestParameter ? min
75593
75594
  : min < max ? min + "-" + max
75594
75595
  : min;
75595
- var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75596
- : 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
75596
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
75597
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
75598
+ 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);
75599
+ }
75600
+ var error = hasRestParameter
75601
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75602
+ : isVoidPromiseError
75603
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75597
75604
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
75598
75605
  if (min < args.length && args.length < max) {
75599
75606
  // between min and max, but with no matching overload
@@ -82645,7 +82652,7 @@ var ts;
82645
82652
  }
82646
82653
  var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined);
82647
82654
  if (yieldType) {
82648
- return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false];
82655
+ return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false];
82649
82656
  }
82650
82657
  if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) {
82651
82658
  return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true];
@@ -85922,7 +85929,7 @@ var ts;
85922
85929
  var symbol = getIntrinsicTagSymbol(name.parent);
85923
85930
  return symbol === unknownSymbol ? undefined : symbol;
85924
85931
  }
85925
- var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name));
85932
+ var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name));
85926
85933
  if (!result && isJSDoc_1) {
85927
85934
  var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration));
85928
85935
  if (container) {
@@ -87779,6 +87786,9 @@ var ts;
87779
87786
  return ts.some(types, checkGrammarExpressionWithTypeArguments);
87780
87787
  }
87781
87788
  function checkGrammarExpressionWithTypeArguments(node) {
87789
+ if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) {
87790
+ 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);
87791
+ }
87782
87792
  return checkGrammarTypeArguments(node, node.typeArguments);
87783
87793
  }
87784
87794
  function checkGrammarClassDeclarationHeritageClauses(node) {
@@ -88720,7 +88730,7 @@ var ts;
88720
88730
  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);
88721
88731
  }
88722
88732
  if (node.typeArguments) {
88723
- return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
88733
+ 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);
88724
88734
  }
88725
88735
  var nodeArguments = node.arguments;
88726
88736
  if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
@@ -108516,6 +108526,8 @@ var ts;
108516
108526
  var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
108517
108527
  errorFallbackNode = undefined;
108518
108528
  var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
108529
+ preserveJsDoc(statement, input);
108530
+ ts.removeAllComments(input);
108519
108531
  return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
108520
108532
  }
108521
108533
  }
@@ -124900,7 +124912,7 @@ var ts;
124900
124912
  if (!state.watch || !state.lastCachedPackageJsonLookups)
124901
124913
  return;
124902
124914
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
124903
- 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); },
124915
+ 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); },
124904
124916
  onDeleteValue: ts.closeFileWatcher,
124905
124917
  });
124906
124918
  }
@@ -125228,6 +125240,17 @@ var ts;
125228
125240
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName";
125229
125241
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText";
125230
125242
  })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {}));
125243
+ // Do not change existing values, as they exist in telemetry.
125244
+ var CompletionInfoFlags;
125245
+ (function (CompletionInfoFlags) {
125246
+ CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None";
125247
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports";
125248
+ CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion";
125249
+ CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation";
125250
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers";
125251
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit";
125252
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets";
125253
+ })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {}));
125231
125254
  var OutliningSpanKind;
125232
125255
  (function (OutliningSpanKind) {
125233
125256
  /** Single or multi-line comments */
@@ -127240,6 +127263,14 @@ var ts;
127240
127263
  return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } });
127241
127264
  }
127242
127265
  ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost;
127266
+ function moduleResolutionRespectsExports(moduleResolution) {
127267
+ return moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127268
+ }
127269
+ ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports;
127270
+ function moduleResolutionUsesNodeModules(moduleResolution) {
127271
+ return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127272
+ }
127273
+ ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules;
127243
127274
  function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
127244
127275
  return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined;
127245
127276
  }
@@ -128843,8 +128874,8 @@ var ts;
128843
128874
  if (from === to)
128844
128875
  return false;
128845
128876
  var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences, {});
128846
- if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) {
128847
- return cachedResult.isAutoImportable;
128877
+ if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) {
128878
+ return !cachedResult.isBlockedByPackageJsonDependencies;
128848
128879
  }
128849
128880
  var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost);
128850
128881
  var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost);
@@ -128858,7 +128889,7 @@ var ts;
128858
128889
  });
128859
128890
  if (packageJsonFilter) {
128860
128891
  var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost);
128861
- moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable);
128892
+ moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable);
128862
128893
  return isAutoImportable;
128863
128894
  }
128864
128895
  return hasImportablePath;
@@ -131137,15 +131168,26 @@ var ts;
131137
131168
  var _a, _b, _c;
131138
131169
  var start = ts.timestamp();
131139
131170
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131140
- var resolutionLimitExceeded = false;
131171
+ // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
131172
+ // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
131173
+ // relative path into node_modules), and we want to filter those completions out entirely.
131174
+ // Import statement completions always need specifier resolution because the module specifier is
131175
+ // part of their `insertText`, not the `codeActions` creating edits away from the cursor.
131176
+ var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions()));
131177
+ var skippedAny = false;
131141
131178
  var ambientCount = 0;
131142
131179
  var resolvedCount = 0;
131143
131180
  var resolvedFromCacheCount = 0;
131144
131181
  var cacheAttemptCount = 0;
131145
- var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } });
131182
+ var result = cb({
131183
+ tryResolve: tryResolve,
131184
+ skippedAny: function () { return skippedAny; },
131185
+ resolvedAny: function () { return resolvedCount > 0; },
131186
+ resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; },
131187
+ });
131146
131188
  var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : "";
131147
131189
  (_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);
131148
- (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete"));
131190
+ (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete"));
131149
131191
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131150
131192
  return result;
131151
131193
  function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
@@ -131154,22 +131196,22 @@ var ts;
131154
131196
  if (result_1) {
131155
131197
  ambientCount++;
131156
131198
  }
131157
- return result_1;
131199
+ return result_1 || "failed";
131158
131200
  }
131159
- var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131201
+ var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131160
131202
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131161
131203
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131162
131204
  ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131163
131205
  : undefined;
131164
131206
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131165
- resolutionLimitExceeded = true;
131207
+ skippedAny = true;
131166
131208
  }
131167
131209
  resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0;
131168
- resolvedFromCacheCount += exportInfo.length - resolvedCount;
131210
+ resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0);
131169
131211
  if (shouldGetModuleSpecifierFromCache) {
131170
131212
  cacheAttemptCount++;
131171
131213
  }
131172
- return result;
131214
+ return result || (needsFullResolution ? "failed" : "skipped");
131173
131215
  }
131174
131216
  }
131175
131217
  function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
@@ -131267,6 +131309,7 @@ var ts;
131267
131309
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131268
131310
  /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131269
131311
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131312
+ var _a;
131270
131313
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131271
131314
  // Not an auto import or already resolved; keep as is
131272
131315
  return entry;
@@ -131278,8 +131321,12 @@ var ts;
131278
131321
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131279
131322
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131280
131323
  var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131281
- if (!result)
131324
+ if (result === "skipped")
131282
131325
  return entry;
131326
+ if (!result || result === "failed") {
131327
+ (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'");
131328
+ return undefined;
131329
+ }
131283
131330
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
131284
131331
  // Mutating for performance... feels sketchy but nobody else uses the cache,
131285
131332
  // so why bother allocating a bunch of new objects?
@@ -131288,12 +131335,13 @@ var ts;
131288
131335
  entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)];
131289
131336
  return entry;
131290
131337
  });
131291
- if (!context.resolutionLimitExceeded()) {
131338
+ if (!context.skippedAny()) {
131292
131339
  previousResponse.isIncomplete = undefined;
131293
131340
  }
131294
131341
  return entries;
131295
131342
  });
131296
131343
  previousResponse.entries = newEntries;
131344
+ previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */;
131297
131345
  return previousResponse;
131298
131346
  }
131299
131347
  function jsdocCompletionInfo(entries) {
@@ -131375,12 +131423,13 @@ var ts;
131375
131423
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
131376
131424
  }
131377
131425
  return {
131426
+ flags: completionData.flags,
131378
131427
  isGlobalCompletion: isInSnippetScope,
131379
131428
  isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined,
131380
131429
  isMemberCompletion: isMemberCompletionKind(completionKind),
131381
131430
  isNewIdentifierLocation: isNewIdentifierLocation,
131382
131431
  optionalReplacementSpan: getOptionalReplacementSpan(location),
131383
- entries: entries
131432
+ entries: entries,
131384
131433
  };
131385
131434
  }
131386
131435
  function isUncheckedFile(sourceFile, compilerOptions) {
@@ -132437,6 +132486,7 @@ var ts;
132437
132486
  var location = ts.getTouchingPropertyName(sourceFile, position);
132438
132487
  var keywordFilters = 0 /* None */;
132439
132488
  var isNewIdentifierLocation = false;
132489
+ var flags = 0 /* None */;
132440
132490
  if (contextToken) {
132441
132491
  var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
132442
132492
  isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
@@ -132456,6 +132506,7 @@ var ts;
132456
132506
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
132457
132507
  // to opt in with the `includeCompletionsForImportStatements` user preference.
132458
132508
  importCompletionNode = importStatementCompletion.replacementNode;
132509
+ flags |= 2 /* IsImportStatementCompletion */;
132459
132510
  }
132460
132511
  // Bail out if this is a known invalid completion location
132461
132512
  if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
@@ -132648,6 +132699,7 @@ var ts;
132648
132699
  isRightOfOpenTag: isRightOfOpenTag,
132649
132700
  importCompletionNode: importCompletionNode,
132650
132701
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
132702
+ flags: flags,
132651
132703
  };
132652
132704
  function isTagWithTypeExpression(tag) {
132653
132705
  switch (tag.kind) {
@@ -133057,6 +133109,7 @@ var ts;
133057
133109
  // Asking for completion details for an item that is not an auto-import
133058
133110
  return;
133059
133111
  }
133112
+ flags |= 1 /* MayIncludeAutoImports */;
133060
133113
  // import { type | -> token text should be blank
133061
133114
  var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
133062
133115
  && importCompletionNode
@@ -133087,16 +133140,36 @@ var ts;
133087
133140
  return true;
133088
133141
  return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
133089
133142
  }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
133143
+ var _a;
133090
133144
  if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
133091
133145
  return;
133092
133146
  }
133093
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
133094
- if (!defaultExportInfo) {
133147
+ // Do a relatively cheap check to bail early if all re-exports are non-importable
133148
+ // due to file location or package.json dependency filtering. For non-node12+
133149
+ // module resolution modes, getting past this point guarantees that we'll be
133150
+ // able to generate a suitable module specifier, so we can safely show a completion,
133151
+ // even if we defer computing the module specifier.
133152
+ var firstImportableExportInfo = ts.find(info, isImportableExportInfo);
133153
+ if (!firstImportableExportInfo) {
133095
133154
  return;
133096
133155
  }
133097
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
133098
- // (We need to ensure that at least one is importable to show a completion.)
133099
- var _a = context.tryResolve(info, symbolName, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
133156
+ // In node12+, module specifier resolution can fail due to modules being blocked
133157
+ // by package.json `exports`. If that happens, don't show a completion item.
133158
+ // N.B. in this resolution mode we always try to resolve module specifiers here,
133159
+ // because we have to know now if it's going to fail so we can omit the completion
133160
+ // from the list.
133161
+ var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {};
133162
+ if (result === "failed")
133163
+ return;
133164
+ // If we skipped resolving module specifiers, our selection of which ExportInfo
133165
+ // to use here is arbitrary, since the info shown in the completion list derived from
133166
+ // it should be identical regardless of which one is used. During the subsequent
133167
+ // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick
133168
+ // the best one based on the module specifier it produces.
133169
+ var exportInfo = firstImportableExportInfo, moduleSpecifier;
133170
+ if (result !== "skipped") {
133171
+ (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier);
133172
+ }
133100
133173
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
133101
133174
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
133102
133175
  pushAutoImportSymbol(symbol, {
@@ -133111,7 +133184,9 @@ var ts;
133111
133184
  isFromPackageJson: exportInfo.isFromPackageJson,
133112
133185
  });
133113
133186
  });
133114
- hasUnresolvedAutoImports = context.resolutionLimitExceeded();
133187
+ hasUnresolvedAutoImports = context.skippedAny();
133188
+ flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0;
133189
+ flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0;
133115
133190
  });
133116
133191
  function isImportableExportInfo(info) {
133117
133192
  var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile);
@@ -133159,6 +133234,7 @@ var ts;
133159
133234
  return;
133160
133235
  }
133161
133236
  var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
133237
+ flags |= 32 /* MayIncludeMethodSnippets */;
133162
133238
  symbolToOriginInfoMap[symbols.length] = origin;
133163
133239
  symbols.push(member);
133164
133240
  });
@@ -133355,7 +133431,7 @@ var ts;
133355
133431
  // through type declaration or inference.
133356
133432
  // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
133357
133433
  // type of parameter will flow in from the contextual type of the function
133358
- var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */;
133434
+ var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */;
133359
133435
  if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) {
133360
133436
  if (ts.isExpression(rootDeclaration.parent)) {
133361
133437
  canGetType = !!typeChecker.getContextualType(rootDeclaration.parent);
@@ -134630,6 +134706,8 @@ var ts;
134630
134706
  return highlightSpans(getAsyncAndAwaitOccurrences(node));
134631
134707
  case 125 /* YieldKeyword */:
134632
134708
  return highlightSpans(getYieldOccurrences(node));
134709
+ case 101 /* InKeyword */:
134710
+ return undefined;
134633
134711
  default:
134634
134712
  return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent))
134635
134713
  ? highlightSpans(getModifierOccurrences(node.kind, node.parent))
@@ -149398,7 +149476,7 @@ var ts;
149398
149476
  ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code,
149399
149477
  ts.Diagnostics.Type_0_is_not_an_array_type.code,
149400
149478
  ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code,
149401
- ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code,
149479
+ ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code,
149402
149480
  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,
149403
149481
  ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
149404
149482
  ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
@@ -152352,6 +152430,7 @@ var ts;
152352
152430
  var compilerOptions = program.getCompilerOptions();
152353
152431
  var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
152354
152432
  var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
152433
+ var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions));
152355
152434
  var getModuleSpecifiers = fromCacheOnly
152356
152435
  ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
152357
152436
  : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
@@ -152362,19 +152441,19 @@ var ts;
152362
152441
  var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
152363
152442
  var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions);
152364
152443
  computedWithoutCacheCount += computedWithoutCache ? 1 : 0;
152365
- return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
152366
- // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
152367
- return !importedSymbolHasValueMeaning && isJs && position !== undefined
152368
- ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
152369
- : {
152370
- kind: 3 /* AddNew */,
152371
- moduleSpecifier: moduleSpecifier,
152372
- importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
152373
- useRequire: useRequire,
152374
- addAsTypeOnly: addAsTypeOnly,
152375
- exportInfo: exportInfo,
152376
- isReExport: i > 0,
152377
- };
152444
+ return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) {
152445
+ return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined :
152446
+ // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
152447
+ !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } :
152448
+ {
152449
+ kind: 3 /* AddNew */,
152450
+ moduleSpecifier: moduleSpecifier,
152451
+ importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
152452
+ useRequire: useRequire,
152453
+ addAsTypeOnly: addAsTypeOnly,
152454
+ exportInfo: exportInfo,
152455
+ isReExport: i > 0,
152456
+ };
152378
152457
  });
152379
152458
  });
152380
152459
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
@@ -157947,6 +158026,7 @@ var ts;
157947
158026
  var fixName = "addVoidToPromise";
157948
158027
  var fixId = "addVoidToPromise";
157949
158028
  var errorCodes = [
158029
+ 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,
157950
158030
  ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
157951
158031
  ];
157952
158032
  codefix.registerCodeFix({
@@ -173930,7 +174010,7 @@ var ts;
173930
174010
  return cache.get(toFileName);
173931
174011
  },
173932
174012
  set: function (fromFileName, toFileName, preferences, options, modulePaths, moduleSpecifiers) {
173933
- ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isAutoImportable*/ true));
174013
+ ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false));
173934
174014
  // If any module specifiers were generated based off paths in node_modules,
173935
174015
  // a package.json file in that package was read and is an input to the cached.
173936
174016
  // Instead of watching each individual package.json file, set up a wildcard
@@ -173956,17 +174036,17 @@ var ts;
173956
174036
  info.modulePaths = modulePaths;
173957
174037
  }
173958
174038
  else {
173959
- cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isAutoImportable*/ undefined));
174039
+ cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined));
173960
174040
  }
173961
174041
  },
173962
- setIsAutoImportable: function (fromFileName, toFileName, preferences, options, isAutoImportable) {
174042
+ setBlockedByPackageJsonDependencies: function (fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) {
173963
174043
  var cache = ensureCache(fromFileName, preferences, options);
173964
174044
  var info = cache.get(toFileName);
173965
174045
  if (info) {
173966
- info.isAutoImportable = isAutoImportable;
174046
+ info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies;
173967
174047
  }
173968
174048
  else {
173969
- cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isAutoImportable));
174049
+ cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies));
173970
174050
  }
173971
174051
  },
173972
174052
  clear: function () {
@@ -173994,8 +174074,8 @@ var ts;
173994
174074
  function key(fromFileName, preferences, options) {
173995
174075
  return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode;
173996
174076
  }
173997
- function createInfo(modulePaths, moduleSpecifiers, isAutoImportable) {
173998
- return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isAutoImportable: isAutoImportable };
174077
+ function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) {
174078
+ return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies };
173999
174079
  }
174000
174080
  }
174001
174081
  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;
@@ -8823,6 +8834,7 @@ declare namespace ts.server.protocol {
8823
8834
  body?: CompletionInfo;
8824
8835
  }
8825
8836
  interface CompletionInfo {
8837
+ readonly flags?: number;
8826
8838
  readonly isGlobalCompletion: boolean;
8827
8839
  readonly isMemberCompletion: boolean;
8828
8840
  readonly isNewIdentifierLocation: boolean;