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 +1 -0
- package/lib/tsc.js +15 -5
- package/lib/tsserver.js +124 -46
- package/lib/tsserverlibrary.d.ts +12 -0
- package/lib/tsserverlibrary.js +124 -46
- package/lib/typescript.d.ts +11 -0
- package/lib/typescript.js +117 -39
- package/lib/typescriptServices.d.ts +11 -0
- package/lib/typescriptServices.js +117 -39
- package/lib/typingsInstaller.js +15 -5
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
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
|
|
75790
|
-
|
|
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.
|
|
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.
|
|
129458
|
-
return cachedResult.
|
|
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.
|
|
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
|
-
|
|
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({
|
|
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 " + (
|
|
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 =
|
|
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
|
-
|
|
131816
|
+
skippedAny = true;
|
|
131777
131817
|
}
|
|
131778
131818
|
resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0;
|
|
131779
|
-
resolvedFromCacheCount += exportInfo.length -
|
|
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 (
|
|
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.
|
|
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
|
-
|
|
133705
|
-
|
|
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.
|
|
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.
|
|
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
|
|
152977
|
-
|
|
152978
|
-
|
|
152979
|
-
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
|
|
152980
|
-
|
|
152981
|
-
|
|
152982
|
-
|
|
152983
|
-
|
|
152984
|
-
|
|
152985
|
-
|
|
152986
|
-
|
|
152987
|
-
|
|
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({
|
|
@@ -174124,7 +174202,7 @@ var ts;
|
|
|
174124
174202
|
return cache.get(toFileName);
|
|
174125
174203
|
},
|
|
174126
174204
|
set: function (fromFileName, toFileName, preferences, options, modulePaths, moduleSpecifiers) {
|
|
174127
|
-
ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*
|
|
174205
|
+
ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false));
|
|
174128
174206
|
// If any module specifiers were generated based off paths in node_modules,
|
|
174129
174207
|
// a package.json file in that package was read and is an input to the cached.
|
|
174130
174208
|
// Instead of watching each individual package.json file, set up a wildcard
|
|
@@ -174150,17 +174228,17 @@ var ts;
|
|
|
174150
174228
|
info.modulePaths = modulePaths;
|
|
174151
174229
|
}
|
|
174152
174230
|
else {
|
|
174153
|
-
cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*
|
|
174231
|
+
cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined));
|
|
174154
174232
|
}
|
|
174155
174233
|
},
|
|
174156
|
-
|
|
174234
|
+
setBlockedByPackageJsonDependencies: function (fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) {
|
|
174157
174235
|
var cache = ensureCache(fromFileName, preferences, options);
|
|
174158
174236
|
var info = cache.get(toFileName);
|
|
174159
174237
|
if (info) {
|
|
174160
|
-
info.
|
|
174238
|
+
info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies;
|
|
174161
174239
|
}
|
|
174162
174240
|
else {
|
|
174163
|
-
cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined,
|
|
174241
|
+
cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies));
|
|
174164
174242
|
}
|
|
174165
174243
|
},
|
|
174166
174244
|
clear: function () {
|
|
@@ -174188,8 +174266,8 @@ var ts;
|
|
|
174188
174266
|
function key(fromFileName, preferences, options) {
|
|
174189
174267
|
return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode;
|
|
174190
174268
|
}
|
|
174191
|
-
function createInfo(modulePaths, moduleSpecifiers,
|
|
174192
|
-
return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers,
|
|
174269
|
+
function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) {
|
|
174270
|
+
return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies };
|
|
174193
174271
|
}
|
|
174194
174272
|
}
|
|
174195
174273
|
server.createModuleSpecifierCache = createModuleSpecifierCache;
|
package/lib/typescript.d.ts
CHANGED
|
@@ -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;
|