typescript 4.7.0-dev.20220427 → 4.7.0-dev.20220428

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/protocol.d.ts CHANGED
@@ -1825,6 +1825,7 @@ declare namespace ts.server.protocol {
1825
1825
  body?: CompletionInfo;
1826
1826
  }
1827
1827
  interface CompletionInfo {
1828
+ readonly flags?: number;
1828
1829
  readonly isGlobalCompletion: boolean;
1829
1830
  readonly isMemberCompletion: boolean;
1830
1831
  readonly isNewIdentifierLocation: boolean;
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220427";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220428";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -6057,6 +6057,7 @@ var ts;
6057
6057
  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}'."),
6058
6058
  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"),
6059
6059
  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."),
6060
+ 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."),
6060
6061
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
6061
6062
  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'."),
6062
6063
  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}'."),
@@ -30687,7 +30688,8 @@ var ts;
30687
30688
  if (!comment) {
30688
30689
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
30689
30690
  }
30690
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
30691
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
30692
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
30691
30693
  }
30692
30694
  function escapedTextsEqual(a, b) {
30693
30695
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -63146,8 +63148,14 @@ var ts;
63146
63148
  var parameterRange = hasRestParameter ? min
63147
63149
  : min < max ? min + "-" + max
63148
63150
  : min;
63149
- var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
63150
- : 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
63151
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
63152
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
63153
+ 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);
63154
+ }
63155
+ var error = hasRestParameter
63156
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
63157
+ : isVoidPromiseError
63158
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
63151
63159
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
63152
63160
  if (min < args.length && args.length < max) {
63153
63161
  return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove);
@@ -88954,6 +88962,8 @@ var ts;
88954
88962
  var varDecl = factory.createVariableDeclaration(newId, undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
88955
88963
  errorFallbackNode = undefined;
88956
88964
  var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135)] : [], factory.createVariableDeclarationList([varDecl], 2));
88965
+ preserveJsDoc(statement, input);
88966
+ ts.removeAllComments(input);
88957
88967
  return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
88958
88968
  }
88959
88969
  }
@@ -103523,7 +103533,7 @@ var ts;
103523
103533
  if (!state.watch || !state.lastCachedPackageJsonLookups)
103524
103534
  return;
103525
103535
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
103526
- 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); },
103536
+ 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); },
103527
103537
  onDeleteValue: ts.closeFileWatcher,
103528
103538
  });
103529
103539
  }
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.20220428";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -8872,6 +8872,7 @@ var ts;
8872
8872
  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
8873
  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
8874
  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."),
8875
+ 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
8876
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8876
8877
  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
8878
  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 +37963,8 @@ var ts;
37962
37963
  if (!comment) {
37963
37964
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
37964
37965
  }
37965
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
37966
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
37967
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
37966
37968
  }
37967
37969
  function escapedTextsEqual(a, b) {
37968
37970
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -75592,8 +75594,14 @@ var ts;
75592
75594
  var parameterRange = hasRestParameter ? min
75593
75595
  : min < max ? min + "-" + max
75594
75596
  : 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
75597
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
75598
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
75599
+ 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);
75600
+ }
75601
+ var error = hasRestParameter
75602
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75603
+ : isVoidPromiseError
75604
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75597
75605
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
75598
75606
  if (min < args.length && args.length < max) {
75599
75607
  // between min and max, but with no matching overload
@@ -108516,6 +108524,8 @@ var ts;
108516
108524
  var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
108517
108525
  errorFallbackNode = undefined;
108518
108526
  var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
108527
+ preserveJsDoc(statement, input);
108528
+ ts.removeAllComments(input);
108519
108529
  return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
108520
108530
  }
108521
108531
  }
@@ -124900,7 +124910,7 @@ var ts;
124900
124910
  if (!state.watch || !state.lastCachedPackageJsonLookups)
124901
124911
  return;
124902
124912
  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); },
124913
+ 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
124914
  onDeleteValue: ts.closeFileWatcher,
124905
124915
  });
124906
124916
  }
@@ -125228,6 +125238,17 @@ var ts;
125228
125238
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName";
125229
125239
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText";
125230
125240
  })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {}));
125241
+ // Do not change existing values, as they exist in telemetry.
125242
+ var CompletionInfoFlags;
125243
+ (function (CompletionInfoFlags) {
125244
+ CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None";
125245
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports";
125246
+ CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion";
125247
+ CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation";
125248
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers";
125249
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit";
125250
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets";
125251
+ })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {}));
125231
125252
  var OutliningSpanKind;
125232
125253
  (function (OutliningSpanKind) {
125233
125254
  /** Single or multi-line comments */
@@ -127240,6 +127261,14 @@ var ts;
127240
127261
  return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } });
127241
127262
  }
127242
127263
  ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost;
127264
+ function moduleResolutionRespectsExports(moduleResolution) {
127265
+ return moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127266
+ }
127267
+ ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports;
127268
+ function moduleResolutionUsesNodeModules(moduleResolution) {
127269
+ return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127270
+ }
127271
+ ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules;
127243
127272
  function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
127244
127273
  return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined;
127245
127274
  }
@@ -128843,8 +128872,8 @@ var ts;
128843
128872
  if (from === to)
128844
128873
  return false;
128845
128874
  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;
128875
+ if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) {
128876
+ return !cachedResult.isBlockedByPackageJsonDependencies;
128848
128877
  }
128849
128878
  var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost);
128850
128879
  var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost);
@@ -128858,7 +128887,7 @@ var ts;
128858
128887
  });
128859
128888
  if (packageJsonFilter) {
128860
128889
  var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost);
128861
- moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable);
128890
+ moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable);
128862
128891
  return isAutoImportable;
128863
128892
  }
128864
128893
  return hasImportablePath;
@@ -131137,15 +131166,26 @@ var ts;
131137
131166
  var _a, _b, _c;
131138
131167
  var start = ts.timestamp();
131139
131168
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131140
- var resolutionLimitExceeded = false;
131169
+ // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
131170
+ // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
131171
+ // relative path into node_modules), and we want to filter those completions out entirely.
131172
+ // Import statement completions always need specifier resolution because the module specifier is
131173
+ // part of their `insertText`, not the `codeActions` creating edits away from the cursor.
131174
+ var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions()));
131175
+ var skippedAny = false;
131141
131176
  var ambientCount = 0;
131142
131177
  var resolvedCount = 0;
131143
131178
  var resolvedFromCacheCount = 0;
131144
131179
  var cacheAttemptCount = 0;
131145
- var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } });
131180
+ var result = cb({
131181
+ tryResolve: tryResolve,
131182
+ skippedAny: function () { return skippedAny; },
131183
+ resolvedAny: function () { return resolvedCount > 0; },
131184
+ resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; },
131185
+ });
131146
131186
  var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : "";
131147
131187
  (_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"));
131188
+ (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete"));
131149
131189
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131150
131190
  return result;
131151
131191
  function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
@@ -131154,22 +131194,22 @@ var ts;
131154
131194
  if (result_1) {
131155
131195
  ambientCount++;
131156
131196
  }
131157
- return result_1;
131197
+ return result_1 || "failed";
131158
131198
  }
131159
- var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131199
+ var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131160
131200
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131161
131201
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131162
131202
  ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131163
131203
  : undefined;
131164
131204
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131165
- resolutionLimitExceeded = true;
131205
+ skippedAny = true;
131166
131206
  }
131167
131207
  resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0;
131168
- resolvedFromCacheCount += exportInfo.length - resolvedCount;
131208
+ resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0);
131169
131209
  if (shouldGetModuleSpecifierFromCache) {
131170
131210
  cacheAttemptCount++;
131171
131211
  }
131172
- return result;
131212
+ return result || (needsFullResolution ? "failed" : "skipped");
131173
131213
  }
131174
131214
  }
131175
131215
  function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
@@ -131267,6 +131307,7 @@ var ts;
131267
131307
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131268
131308
  /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131269
131309
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131310
+ var _a;
131270
131311
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131271
131312
  // Not an auto import or already resolved; keep as is
131272
131313
  return entry;
@@ -131278,8 +131319,12 @@ var ts;
131278
131319
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131279
131320
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131280
131321
  var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131281
- if (!result)
131322
+ if (result === "skipped")
131282
131323
  return entry;
131324
+ if (!result || result === "failed") {
131325
+ (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'");
131326
+ return undefined;
131327
+ }
131283
131328
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
131284
131329
  // Mutating for performance... feels sketchy but nobody else uses the cache,
131285
131330
  // so why bother allocating a bunch of new objects?
@@ -131288,12 +131333,13 @@ var ts;
131288
131333
  entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)];
131289
131334
  return entry;
131290
131335
  });
131291
- if (!context.resolutionLimitExceeded()) {
131336
+ if (!context.skippedAny()) {
131292
131337
  previousResponse.isIncomplete = undefined;
131293
131338
  }
131294
131339
  return entries;
131295
131340
  });
131296
131341
  previousResponse.entries = newEntries;
131342
+ previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */;
131297
131343
  return previousResponse;
131298
131344
  }
131299
131345
  function jsdocCompletionInfo(entries) {
@@ -131375,12 +131421,13 @@ var ts;
131375
131421
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
131376
131422
  }
131377
131423
  return {
131424
+ flags: completionData.flags,
131378
131425
  isGlobalCompletion: isInSnippetScope,
131379
131426
  isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined,
131380
131427
  isMemberCompletion: isMemberCompletionKind(completionKind),
131381
131428
  isNewIdentifierLocation: isNewIdentifierLocation,
131382
131429
  optionalReplacementSpan: getOptionalReplacementSpan(location),
131383
- entries: entries
131430
+ entries: entries,
131384
131431
  };
131385
131432
  }
131386
131433
  function isUncheckedFile(sourceFile, compilerOptions) {
@@ -132437,6 +132484,7 @@ var ts;
132437
132484
  var location = ts.getTouchingPropertyName(sourceFile, position);
132438
132485
  var keywordFilters = 0 /* None */;
132439
132486
  var isNewIdentifierLocation = false;
132487
+ var flags = 0 /* None */;
132440
132488
  if (contextToken) {
132441
132489
  var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
132442
132490
  isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
@@ -132456,6 +132504,7 @@ var ts;
132456
132504
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
132457
132505
  // to opt in with the `includeCompletionsForImportStatements` user preference.
132458
132506
  importCompletionNode = importStatementCompletion.replacementNode;
132507
+ flags |= 2 /* IsImportStatementCompletion */;
132459
132508
  }
132460
132509
  // Bail out if this is a known invalid completion location
132461
132510
  if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
@@ -132648,6 +132697,7 @@ var ts;
132648
132697
  isRightOfOpenTag: isRightOfOpenTag,
132649
132698
  importCompletionNode: importCompletionNode,
132650
132699
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
132700
+ flags: flags,
132651
132701
  };
132652
132702
  function isTagWithTypeExpression(tag) {
132653
132703
  switch (tag.kind) {
@@ -133057,6 +133107,7 @@ var ts;
133057
133107
  // Asking for completion details for an item that is not an auto-import
133058
133108
  return;
133059
133109
  }
133110
+ flags |= 1 /* MayIncludeAutoImports */;
133060
133111
  // import { type | -> token text should be blank
133061
133112
  var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
133062
133113
  && importCompletionNode
@@ -133087,16 +133138,36 @@ var ts;
133087
133138
  return true;
133088
133139
  return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
133089
133140
  }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
133141
+ var _a;
133090
133142
  if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
133091
133143
  return;
133092
133144
  }
133093
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
133094
- if (!defaultExportInfo) {
133145
+ // Do a relatively cheap check to bail early if all re-exports are non-importable
133146
+ // due to file location or package.json dependency filtering. For non-node12+
133147
+ // module resolution modes, getting past this point guarantees that we'll be
133148
+ // able to generate a suitable module specifier, so we can safely show a completion,
133149
+ // even if we defer computing the module specifier.
133150
+ var firstImportableExportInfo = ts.find(info, isImportableExportInfo);
133151
+ if (!firstImportableExportInfo) {
133152
+ return;
133153
+ }
133154
+ // In node12+, module specifier resolution can fail due to modules being blocked
133155
+ // by package.json `exports`. If that happens, don't show a completion item.
133156
+ // N.B. in this resolution mode we always try to resolve module specifiers here,
133157
+ // because we have to know now if it's going to fail so we can omit the completion
133158
+ // from the list.
133159
+ var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {};
133160
+ if (result === "failed")
133095
133161
  return;
133162
+ // If we skipped resolving module specifiers, our selection of which ExportInfo
133163
+ // to use here is arbitrary, since the info shown in the completion list derived from
133164
+ // it should be identical regardless of which one is used. During the subsequent
133165
+ // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick
133166
+ // the best one based on the module specifier it produces.
133167
+ var exportInfo = firstImportableExportInfo, moduleSpecifier;
133168
+ if (result !== "skipped") {
133169
+ (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier);
133096
133170
  }
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;
133100
133171
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
133101
133172
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
133102
133173
  pushAutoImportSymbol(symbol, {
@@ -133111,7 +133182,9 @@ var ts;
133111
133182
  isFromPackageJson: exportInfo.isFromPackageJson,
133112
133183
  });
133113
133184
  });
133114
- hasUnresolvedAutoImports = context.resolutionLimitExceeded();
133185
+ hasUnresolvedAutoImports = context.skippedAny();
133186
+ flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0;
133187
+ flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0;
133115
133188
  });
133116
133189
  function isImportableExportInfo(info) {
133117
133190
  var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile);
@@ -133159,6 +133232,7 @@ var ts;
133159
133232
  return;
133160
133233
  }
133161
133234
  var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
133235
+ flags |= 32 /* MayIncludeMethodSnippets */;
133162
133236
  symbolToOriginInfoMap[symbols.length] = origin;
133163
133237
  symbols.push(member);
133164
133238
  });
@@ -133355,7 +133429,7 @@ var ts;
133355
133429
  // through type declaration or inference.
133356
133430
  // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
133357
133431
  // 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 */;
133432
+ var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */;
133359
133433
  if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) {
133360
133434
  if (ts.isExpression(rootDeclaration.parent)) {
133361
133435
  canGetType = !!typeChecker.getContextualType(rootDeclaration.parent);
@@ -134630,6 +134704,8 @@ var ts;
134630
134704
  return highlightSpans(getAsyncAndAwaitOccurrences(node));
134631
134705
  case 125 /* YieldKeyword */:
134632
134706
  return highlightSpans(getYieldOccurrences(node));
134707
+ case 101 /* InKeyword */:
134708
+ return undefined;
134633
134709
  default:
134634
134710
  return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent))
134635
134711
  ? highlightSpans(getModifierOccurrences(node.kind, node.parent))
@@ -152352,6 +152428,7 @@ var ts;
152352
152428
  var compilerOptions = program.getCompilerOptions();
152353
152429
  var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
152354
152430
  var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
152431
+ var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions));
152355
152432
  var getModuleSpecifiers = fromCacheOnly
152356
152433
  ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
152357
152434
  : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
@@ -152362,19 +152439,19 @@ var ts;
152362
152439
  var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
152363
152440
  var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions);
152364
152441
  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
- };
152442
+ return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) {
152443
+ return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined :
152444
+ // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
152445
+ !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } :
152446
+ {
152447
+ kind: 3 /* AddNew */,
152448
+ moduleSpecifier: moduleSpecifier,
152449
+ importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
152450
+ useRequire: useRequire,
152451
+ addAsTypeOnly: addAsTypeOnly,
152452
+ exportInfo: exportInfo,
152453
+ isReExport: i > 0,
152454
+ };
152378
152455
  });
152379
152456
  });
152380
152457
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
@@ -157947,6 +158024,7 @@ var ts;
157947
158024
  var fixName = "addVoidToPromise";
157948
158025
  var fixId = "addVoidToPromise";
157949
158026
  var errorCodes = [
158027
+ 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
158028
  ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
157951
158029
  ];
157952
158030
  codefix.registerCodeFix({
@@ -173930,7 +174008,7 @@ var ts;
173930
174008
  return cache.get(toFileName);
173931
174009
  },
173932
174010
  set: function (fromFileName, toFileName, preferences, options, modulePaths, moduleSpecifiers) {
173933
- ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isAutoImportable*/ true));
174011
+ ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false));
173934
174012
  // If any module specifiers were generated based off paths in node_modules,
173935
174013
  // a package.json file in that package was read and is an input to the cached.
173936
174014
  // Instead of watching each individual package.json file, set up a wildcard
@@ -173956,17 +174034,17 @@ var ts;
173956
174034
  info.modulePaths = modulePaths;
173957
174035
  }
173958
174036
  else {
173959
- cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isAutoImportable*/ undefined));
174037
+ cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined));
173960
174038
  }
173961
174039
  },
173962
- setIsAutoImportable: function (fromFileName, toFileName, preferences, options, isAutoImportable) {
174040
+ setBlockedByPackageJsonDependencies: function (fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) {
173963
174041
  var cache = ensureCache(fromFileName, preferences, options);
173964
174042
  var info = cache.get(toFileName);
173965
174043
  if (info) {
173966
- info.isAutoImportable = isAutoImportable;
174044
+ info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies;
173967
174045
  }
173968
174046
  else {
173969
- cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isAutoImportable));
174047
+ cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies));
173970
174048
  }
173971
174049
  },
173972
174050
  clear: function () {
@@ -173994,8 +174072,8 @@ var ts;
173994
174072
  function key(fromFileName, preferences, options) {
173995
174073
  return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode;
173996
174074
  }
173997
- function createInfo(modulePaths, moduleSpecifiers, isAutoImportable) {
173998
- return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isAutoImportable: isAutoImportable };
174075
+ function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) {
174076
+ return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies };
173999
174077
  }
174000
174078
  }
174001
174079
  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;