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.
@@ -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.20220428";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -9066,6 +9066,7 @@ var ts;
9066
9066
  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
9067
  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
9068
  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."),
9069
+ 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
9070
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
9070
9071
  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
9072
  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 +38157,8 @@ var ts;
38156
38157
  if (!comment) {
38157
38158
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
38158
38159
  }
38159
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
38160
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
38161
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
38160
38162
  }
38161
38163
  function escapedTextsEqual(a, b) {
38162
38164
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -75786,8 +75788,14 @@ var ts;
75786
75788
  var parameterRange = hasRestParameter ? min
75787
75789
  : min < max ? min + "-" + max
75788
75790
  : 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
75791
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
75792
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
75793
+ 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);
75794
+ }
75795
+ var error = hasRestParameter
75796
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75797
+ : isVoidPromiseError
75798
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75791
75799
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
75792
75800
  if (min < args.length && args.length < max) {
75793
75801
  // between min and max, but with no matching overload
@@ -108710,6 +108718,8 @@ var ts;
108710
108718
  var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
108711
108719
  errorFallbackNode = undefined;
108712
108720
  var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
108721
+ preserveJsDoc(statement, input);
108722
+ ts.removeAllComments(input);
108713
108723
  return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
108714
108724
  }
108715
108725
  }
@@ -125094,7 +125104,7 @@ var ts;
125094
125104
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125095
125105
  return;
125096
125106
  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); },
125107
+ 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
125108
  onDeleteValue: ts.closeFileWatcher,
125099
125109
  });
125100
125110
  }
@@ -125839,6 +125849,17 @@ var ts;
125839
125849
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName";
125840
125850
  SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText";
125841
125851
  })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {}));
125852
+ // Do not change existing values, as they exist in telemetry.
125853
+ var CompletionInfoFlags;
125854
+ (function (CompletionInfoFlags) {
125855
+ CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None";
125856
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports";
125857
+ CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion";
125858
+ CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation";
125859
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers";
125860
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit";
125861
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets";
125862
+ })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {}));
125842
125863
  var OutliningSpanKind;
125843
125864
  (function (OutliningSpanKind) {
125844
125865
  /** Single or multi-line comments */
@@ -127851,6 +127872,14 @@ var ts;
127851
127872
  return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } });
127852
127873
  }
127853
127874
  ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost;
127875
+ function moduleResolutionRespectsExports(moduleResolution) {
127876
+ return moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127877
+ }
127878
+ ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports;
127879
+ function moduleResolutionUsesNodeModules(moduleResolution) {
127880
+ return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node12 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
127881
+ }
127882
+ ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules;
127854
127883
  function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
127855
127884
  return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined;
127856
127885
  }
@@ -129454,8 +129483,8 @@ var ts;
129454
129483
  if (from === to)
129455
129484
  return false;
129456
129485
  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;
129486
+ if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) {
129487
+ return !cachedResult.isBlockedByPackageJsonDependencies;
129459
129488
  }
129460
129489
  var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost);
129461
129490
  var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost);
@@ -129469,7 +129498,7 @@ var ts;
129469
129498
  });
129470
129499
  if (packageJsonFilter) {
129471
129500
  var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost);
129472
- moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable);
129501
+ moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable);
129473
129502
  return isAutoImportable;
129474
129503
  }
129475
129504
  return hasImportablePath;
@@ -131748,15 +131777,26 @@ var ts;
131748
131777
  var _a, _b, _c;
131749
131778
  var start = ts.timestamp();
131750
131779
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131751
- var resolutionLimitExceeded = false;
131780
+ // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
131781
+ // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
131782
+ // relative path into node_modules), and we want to filter those completions out entirely.
131783
+ // Import statement completions always need specifier resolution because the module specifier is
131784
+ // part of their `insertText`, not the `codeActions` creating edits away from the cursor.
131785
+ var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions()));
131786
+ var skippedAny = false;
131752
131787
  var ambientCount = 0;
131753
131788
  var resolvedCount = 0;
131754
131789
  var resolvedFromCacheCount = 0;
131755
131790
  var cacheAttemptCount = 0;
131756
- var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } });
131791
+ var result = cb({
131792
+ tryResolve: tryResolve,
131793
+ skippedAny: function () { return skippedAny; },
131794
+ resolvedAny: function () { return resolvedCount > 0; },
131795
+ resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; },
131796
+ });
131757
131797
  var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : "";
131758
131798
  (_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"));
131799
+ (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete"));
131760
131800
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131761
131801
  return result;
131762
131802
  function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
@@ -131765,22 +131805,22 @@ var ts;
131765
131805
  if (result_1) {
131766
131806
  ambientCount++;
131767
131807
  }
131768
- return result_1;
131808
+ return result_1 || "failed";
131769
131809
  }
131770
- var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131810
+ var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131771
131811
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131772
131812
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131773
131813
  ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131774
131814
  : undefined;
131775
131815
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131776
- resolutionLimitExceeded = true;
131816
+ skippedAny = true;
131777
131817
  }
131778
131818
  resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0;
131779
- resolvedFromCacheCount += exportInfo.length - resolvedCount;
131819
+ resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0);
131780
131820
  if (shouldGetModuleSpecifierFromCache) {
131781
131821
  cacheAttemptCount++;
131782
131822
  }
131783
- return result;
131823
+ return result || (needsFullResolution ? "failed" : "skipped");
131784
131824
  }
131785
131825
  }
131786
131826
  function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
@@ -131878,6 +131918,7 @@ var ts;
131878
131918
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131879
131919
  /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131880
131920
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131921
+ var _a;
131881
131922
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131882
131923
  // Not an auto import or already resolved; keep as is
131883
131924
  return entry;
@@ -131889,8 +131930,12 @@ var ts;
131889
131930
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131890
131931
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131891
131932
  var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131892
- if (!result)
131933
+ if (result === "skipped")
131893
131934
  return entry;
131935
+ if (!result || result === "failed") {
131936
+ (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'");
131937
+ return undefined;
131938
+ }
131894
131939
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
131895
131940
  // Mutating for performance... feels sketchy but nobody else uses the cache,
131896
131941
  // so why bother allocating a bunch of new objects?
@@ -131899,12 +131944,13 @@ var ts;
131899
131944
  entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)];
131900
131945
  return entry;
131901
131946
  });
131902
- if (!context.resolutionLimitExceeded()) {
131947
+ if (!context.skippedAny()) {
131903
131948
  previousResponse.isIncomplete = undefined;
131904
131949
  }
131905
131950
  return entries;
131906
131951
  });
131907
131952
  previousResponse.entries = newEntries;
131953
+ previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */;
131908
131954
  return previousResponse;
131909
131955
  }
131910
131956
  function jsdocCompletionInfo(entries) {
@@ -131986,12 +132032,13 @@ var ts;
131986
132032
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
131987
132033
  }
131988
132034
  return {
132035
+ flags: completionData.flags,
131989
132036
  isGlobalCompletion: isInSnippetScope,
131990
132037
  isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined,
131991
132038
  isMemberCompletion: isMemberCompletionKind(completionKind),
131992
132039
  isNewIdentifierLocation: isNewIdentifierLocation,
131993
132040
  optionalReplacementSpan: getOptionalReplacementSpan(location),
131994
- entries: entries
132041
+ entries: entries,
131995
132042
  };
131996
132043
  }
131997
132044
  function isUncheckedFile(sourceFile, compilerOptions) {
@@ -133048,6 +133095,7 @@ var ts;
133048
133095
  var location = ts.getTouchingPropertyName(sourceFile, position);
133049
133096
  var keywordFilters = 0 /* None */;
133050
133097
  var isNewIdentifierLocation = false;
133098
+ var flags = 0 /* None */;
133051
133099
  if (contextToken) {
133052
133100
  var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
133053
133101
  isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
@@ -133067,6 +133115,7 @@ var ts;
133067
133115
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
133068
133116
  // to opt in with the `includeCompletionsForImportStatements` user preference.
133069
133117
  importCompletionNode = importStatementCompletion.replacementNode;
133118
+ flags |= 2 /* IsImportStatementCompletion */;
133070
133119
  }
133071
133120
  // Bail out if this is a known invalid completion location
133072
133121
  if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
@@ -133259,6 +133308,7 @@ var ts;
133259
133308
  isRightOfOpenTag: isRightOfOpenTag,
133260
133309
  importCompletionNode: importCompletionNode,
133261
133310
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
133311
+ flags: flags,
133262
133312
  };
133263
133313
  function isTagWithTypeExpression(tag) {
133264
133314
  switch (tag.kind) {
@@ -133668,6 +133718,7 @@ var ts;
133668
133718
  // Asking for completion details for an item that is not an auto-import
133669
133719
  return;
133670
133720
  }
133721
+ flags |= 1 /* MayIncludeAutoImports */;
133671
133722
  // import { type | -> token text should be blank
133672
133723
  var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
133673
133724
  && importCompletionNode
@@ -133698,16 +133749,36 @@ var ts;
133698
133749
  return true;
133699
133750
  return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
133700
133751
  }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
133752
+ var _a;
133701
133753
  if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
133702
133754
  return;
133703
133755
  }
133704
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
133705
- if (!defaultExportInfo) {
133756
+ // Do a relatively cheap check to bail early if all re-exports are non-importable
133757
+ // due to file location or package.json dependency filtering. For non-node12+
133758
+ // module resolution modes, getting past this point guarantees that we'll be
133759
+ // able to generate a suitable module specifier, so we can safely show a completion,
133760
+ // even if we defer computing the module specifier.
133761
+ var firstImportableExportInfo = ts.find(info, isImportableExportInfo);
133762
+ if (!firstImportableExportInfo) {
133763
+ return;
133764
+ }
133765
+ // In node12+, module specifier resolution can fail due to modules being blocked
133766
+ // by package.json `exports`. If that happens, don't show a completion item.
133767
+ // N.B. in this resolution mode we always try to resolve module specifiers here,
133768
+ // because we have to know now if it's going to fail so we can omit the completion
133769
+ // from the list.
133770
+ var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {};
133771
+ if (result === "failed")
133706
133772
  return;
133773
+ // If we skipped resolving module specifiers, our selection of which ExportInfo
133774
+ // to use here is arbitrary, since the info shown in the completion list derived from
133775
+ // it should be identical regardless of which one is used. During the subsequent
133776
+ // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick
133777
+ // the best one based on the module specifier it produces.
133778
+ var exportInfo = firstImportableExportInfo, moduleSpecifier;
133779
+ if (result !== "skipped") {
133780
+ (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier);
133707
133781
  }
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;
133711
133782
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
133712
133783
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
133713
133784
  pushAutoImportSymbol(symbol, {
@@ -133722,7 +133793,9 @@ var ts;
133722
133793
  isFromPackageJson: exportInfo.isFromPackageJson,
133723
133794
  });
133724
133795
  });
133725
- hasUnresolvedAutoImports = context.resolutionLimitExceeded();
133796
+ hasUnresolvedAutoImports = context.skippedAny();
133797
+ flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0;
133798
+ flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0;
133726
133799
  });
133727
133800
  function isImportableExportInfo(info) {
133728
133801
  var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile);
@@ -133770,6 +133843,7 @@ var ts;
133770
133843
  return;
133771
133844
  }
133772
133845
  var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
133846
+ flags |= 32 /* MayIncludeMethodSnippets */;
133773
133847
  symbolToOriginInfoMap[symbols.length] = origin;
133774
133848
  symbols.push(member);
133775
133849
  });
@@ -133966,7 +134040,7 @@ var ts;
133966
134040
  // through type declaration or inference.
133967
134041
  // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
133968
134042
  // 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 */;
134043
+ var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */;
133970
134044
  if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) {
133971
134045
  if (ts.isExpression(rootDeclaration.parent)) {
133972
134046
  canGetType = !!typeChecker.getContextualType(rootDeclaration.parent);
@@ -135241,6 +135315,8 @@ var ts;
135241
135315
  return highlightSpans(getAsyncAndAwaitOccurrences(node));
135242
135316
  case 125 /* YieldKeyword */:
135243
135317
  return highlightSpans(getYieldOccurrences(node));
135318
+ case 101 /* InKeyword */:
135319
+ return undefined;
135244
135320
  default:
135245
135321
  return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent))
135246
135322
  ? highlightSpans(getModifierOccurrences(node.kind, node.parent))
@@ -152963,6 +153039,7 @@ var ts;
152963
153039
  var compilerOptions = program.getCompilerOptions();
152964
153040
  var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
152965
153041
  var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
153042
+ var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions));
152966
153043
  var getModuleSpecifiers = fromCacheOnly
152967
153044
  ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
152968
153045
  : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
@@ -152973,19 +153050,19 @@ var ts;
152973
153050
  var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
152974
153051
  var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions);
152975
153052
  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
- };
153053
+ return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) {
153054
+ return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined :
153055
+ // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
153056
+ !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } :
153057
+ {
153058
+ kind: 3 /* AddNew */,
153059
+ moduleSpecifier: moduleSpecifier,
153060
+ importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
153061
+ useRequire: useRequire,
153062
+ addAsTypeOnly: addAsTypeOnly,
153063
+ exportInfo: exportInfo,
153064
+ isReExport: i > 0,
153065
+ };
152989
153066
  });
152990
153067
  });
152991
153068
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
@@ -158558,6 +158635,7 @@ var ts;
158558
158635
  var fixName = "addVoidToPromise";
158559
158636
  var fixId = "addVoidToPromise";
158560
158637
  var errorCodes = [
158638
+ 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
158639
  ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
158562
158640
  ];
158563
158641
  codefix.registerCodeFix({
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220427";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220428";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -8861,6 +8861,7 @@ var ts;
8861
8861
  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}'."),
8862
8862
  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"),
8863
8863
  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."),
8864
+ 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."),
8864
8865
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8865
8866
  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'."),
8866
8867
  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}'."),
@@ -37951,7 +37952,8 @@ var ts;
37951
37952
  if (!comment) {
37952
37953
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
37953
37954
  }
37954
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
37955
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
37956
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
37955
37957
  }
37956
37958
  function escapedTextsEqual(a, b) {
37957
37959
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -75581,8 +75583,14 @@ var ts;
75581
75583
  var parameterRange = hasRestParameter ? min
75582
75584
  : min < max ? min + "-" + max
75583
75585
  : min;
75584
- var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75585
- : 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
75586
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
75587
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
75588
+ 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);
75589
+ }
75590
+ var error = hasRestParameter
75591
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75592
+ : isVoidPromiseError
75593
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75586
75594
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
75587
75595
  if (min < args.length && args.length < max) {
75588
75596
  // between min and max, but with no matching overload
@@ -108505,6 +108513,8 @@ var ts;
108505
108513
  var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
108506
108514
  errorFallbackNode = undefined;
108507
108515
  var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
108516
+ preserveJsDoc(statement, input);
108517
+ ts.removeAllComments(input);
108508
108518
  return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
108509
108519
  }
108510
108520
  }
@@ -124889,7 +124899,7 @@ var ts;
124889
124899
  if (!state.watch || !state.lastCachedPackageJsonLookups)
124890
124900
  return;
124891
124901
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
124892
- 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); },
124902
+ 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); },
124893
124903
  onDeleteValue: ts.closeFileWatcher,
124894
124904
  });
124895
124905
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.7.0-dev.20220427",
5
+ "version": "4.7.0-dev.20220428",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [