mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Bump version to 4.7.4 and LKG
This commit is contained in:
+3
-2
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var ts;
|
||||
(function (ts) {
|
||||
ts.versionMajorMinor = "4.7";
|
||||
ts.version = "4.7.3";
|
||||
ts.version = "4.7.4";
|
||||
var NativeCollections;
|
||||
(function (NativeCollections) {
|
||||
var globals = typeof globalThis !== "undefined" ? globalThis :
|
||||
@@ -28447,9 +28447,10 @@ var ts;
|
||||
}
|
||||
nextToken();
|
||||
var typeArguments = parseDelimitedList(20, parseType);
|
||||
if (!parseExpected(31)) {
|
||||
if (reScanGreaterToken() !== 31) {
|
||||
return undefined;
|
||||
}
|
||||
nextToken();
|
||||
return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
|
||||
}
|
||||
function canFollowTypeArgumentsInExpression() {
|
||||
|
||||
+53
-30
@@ -100,7 +100,7 @@ var ts;
|
||||
// The following is baselined as a literal template type without intervention
|
||||
/** The version of the TypeScript compiler release */
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
ts.version = "4.7.3";
|
||||
ts.version = "4.7.4";
|
||||
/* @internal */
|
||||
var Comparison;
|
||||
(function (Comparison) {
|
||||
@@ -35424,10 +35424,11 @@ var ts;
|
||||
}
|
||||
nextToken();
|
||||
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
||||
if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) {
|
||||
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
||||
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
||||
return undefined;
|
||||
}
|
||||
nextToken();
|
||||
// We successfully parsed a type argument list. The next token determines whether we want to
|
||||
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
||||
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
||||
@@ -131465,10 +131466,9 @@ var ts;
|
||||
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
|
||||
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
|
||||
})(GlobalsSearch || (GlobalsSearch = {}));
|
||||
function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
var _a, _b, _c;
|
||||
var start = ts.timestamp();
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
// Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
|
||||
// package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
|
||||
// relative path into node_modules), and we want to filter those completions out entirely.
|
||||
@@ -131493,7 +131493,7 @@ var ts;
|
||||
return result;
|
||||
function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
|
||||
if (isFromAmbientModule) {
|
||||
var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
|
||||
var result_1 = resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite);
|
||||
if (result_1) {
|
||||
ambientCount++;
|
||||
}
|
||||
@@ -131502,7 +131502,7 @@ var ts;
|
||||
var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
||||
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
||||
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
||||
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
|
||||
? resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, shouldGetModuleSpecifierFromCache)
|
||||
: undefined;
|
||||
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
||||
skippedAny = true;
|
||||
@@ -131607,7 +131607,7 @@ var ts;
|
||||
return undefined;
|
||||
var lowerCaseTokenText = location.text.toLowerCase();
|
||||
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
||||
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
||||
var _a;
|
||||
@@ -132938,6 +132938,7 @@ var ts;
|
||||
var hasUnresolvedAutoImports = false;
|
||||
// This also gets mutated in nested-functions after the return
|
||||
var symbols = [];
|
||||
var importSpecifierResolver;
|
||||
var symbolToOriginInfoMap = [];
|
||||
var symbolToSortTextMap = [];
|
||||
var seenPropertySymbols = new ts.Map();
|
||||
@@ -133159,14 +133160,14 @@ var ts;
|
||||
}
|
||||
else {
|
||||
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
|
||||
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
|
||||
var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{
|
||||
exportKind: 0 /* ExportKind.Named */,
|
||||
moduleFileName: fileName,
|
||||
isFromPackageJson: false,
|
||||
moduleSymbol: moduleSymbol,
|
||||
symbol: firstAccessibleSymbol,
|
||||
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier;
|
||||
if (moduleSpecifier) {
|
||||
var origin = {
|
||||
kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
|
||||
@@ -133422,7 +133423,7 @@ var ts;
|
||||
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
||||
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
||||
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
exportInfo.search(sourceFile.path,
|
||||
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
||||
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
||||
@@ -152453,6 +152454,18 @@ var ts;
|
||||
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
|
||||
}
|
||||
}
|
||||
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(importingFile, preferences, host);
|
||||
var importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
||||
return { getModuleSpecifierForBestExportInfo: getModuleSpecifierForBestExportInfo };
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, importMap, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
}
|
||||
codefix.createImportSpecifierResolver = createImportSpecifierResolver;
|
||||
// Sorted with the preferred fix coming first.
|
||||
var ImportFixKind;
|
||||
(function (ImportFixKind) {
|
||||
@@ -152553,18 +152566,12 @@ var ts;
|
||||
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
||||
}
|
||||
}
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
||||
function getImportFixes(exportInfos, useNamespaceInfo,
|
||||
/** undefined only for missing JSX namespace */
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
|
||||
if (importMap === void 0) { importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()); }
|
||||
var checker = program.getTypeChecker();
|
||||
var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
|
||||
var existingImports = ts.flatMap(exportInfos, importMap.getImportsForExportInfo);
|
||||
var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
|
||||
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
|
||||
if (addToExisting) {
|
||||
@@ -152692,21 +152699,37 @@ var ts;
|
||||
};
|
||||
});
|
||||
}
|
||||
function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
||||
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
||||
var importMap;
|
||||
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
||||
var moduleSpecifier = _a[_i];
|
||||
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
||||
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
||||
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
var moduleSymbol = checker.resolveExternalModuleName(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
|
||||
}
|
||||
}
|
||||
if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
getImportsForExportInfo: function (_a) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol));
|
||||
if (!matchingDeclarations)
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return matchingDeclarations.map(function (declaration) { return ({ declaration: declaration, importKind: importKind, symbol: symbol, targetFlags: targetFlags }); });
|
||||
}
|
||||
};
|
||||
}
|
||||
function shouldUseRequire(sourceFile, program) {
|
||||
// 1. TypeScript files don't use require variable declarations
|
||||
|
||||
+53
-30
@@ -294,7 +294,7 @@ var ts;
|
||||
// The following is baselined as a literal template type without intervention
|
||||
/** The version of the TypeScript compiler release */
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
ts.version = "4.7.3";
|
||||
ts.version = "4.7.4";
|
||||
/* @internal */
|
||||
var Comparison;
|
||||
(function (Comparison) {
|
||||
@@ -35618,10 +35618,11 @@ var ts;
|
||||
}
|
||||
nextToken();
|
||||
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
||||
if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) {
|
||||
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
||||
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
||||
return undefined;
|
||||
}
|
||||
nextToken();
|
||||
// We successfully parsed a type argument list. The next token determines whether we want to
|
||||
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
||||
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
||||
@@ -132076,10 +132077,9 @@ var ts;
|
||||
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
|
||||
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
|
||||
})(GlobalsSearch || (GlobalsSearch = {}));
|
||||
function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
var _a, _b, _c;
|
||||
var start = ts.timestamp();
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
// Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
|
||||
// package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
|
||||
// relative path into node_modules), and we want to filter those completions out entirely.
|
||||
@@ -132104,7 +132104,7 @@ var ts;
|
||||
return result;
|
||||
function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
|
||||
if (isFromAmbientModule) {
|
||||
var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
|
||||
var result_1 = resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite);
|
||||
if (result_1) {
|
||||
ambientCount++;
|
||||
}
|
||||
@@ -132113,7 +132113,7 @@ var ts;
|
||||
var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
||||
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
||||
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
||||
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
|
||||
? resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, shouldGetModuleSpecifierFromCache)
|
||||
: undefined;
|
||||
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
||||
skippedAny = true;
|
||||
@@ -132218,7 +132218,7 @@ var ts;
|
||||
return undefined;
|
||||
var lowerCaseTokenText = location.text.toLowerCase();
|
||||
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
||||
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
||||
var _a;
|
||||
@@ -133549,6 +133549,7 @@ var ts;
|
||||
var hasUnresolvedAutoImports = false;
|
||||
// This also gets mutated in nested-functions after the return
|
||||
var symbols = [];
|
||||
var importSpecifierResolver;
|
||||
var symbolToOriginInfoMap = [];
|
||||
var symbolToSortTextMap = [];
|
||||
var seenPropertySymbols = new ts.Map();
|
||||
@@ -133770,14 +133771,14 @@ var ts;
|
||||
}
|
||||
else {
|
||||
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
|
||||
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
|
||||
var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{
|
||||
exportKind: 0 /* ExportKind.Named */,
|
||||
moduleFileName: fileName,
|
||||
isFromPackageJson: false,
|
||||
moduleSymbol: moduleSymbol,
|
||||
symbol: firstAccessibleSymbol,
|
||||
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier;
|
||||
if (moduleSpecifier) {
|
||||
var origin = {
|
||||
kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
|
||||
@@ -134033,7 +134034,7 @@ var ts;
|
||||
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
||||
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
||||
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
exportInfo.search(sourceFile.path,
|
||||
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
||||
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
||||
@@ -153064,6 +153065,18 @@ var ts;
|
||||
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
|
||||
}
|
||||
}
|
||||
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(importingFile, preferences, host);
|
||||
var importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
||||
return { getModuleSpecifierForBestExportInfo: getModuleSpecifierForBestExportInfo };
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, importMap, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
}
|
||||
codefix.createImportSpecifierResolver = createImportSpecifierResolver;
|
||||
// Sorted with the preferred fix coming first.
|
||||
var ImportFixKind;
|
||||
(function (ImportFixKind) {
|
||||
@@ -153164,18 +153177,12 @@ var ts;
|
||||
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
||||
}
|
||||
}
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
||||
function getImportFixes(exportInfos, useNamespaceInfo,
|
||||
/** undefined only for missing JSX namespace */
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
|
||||
if (importMap === void 0) { importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()); }
|
||||
var checker = program.getTypeChecker();
|
||||
var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
|
||||
var existingImports = ts.flatMap(exportInfos, importMap.getImportsForExportInfo);
|
||||
var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
|
||||
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
|
||||
if (addToExisting) {
|
||||
@@ -153303,21 +153310,37 @@ var ts;
|
||||
};
|
||||
});
|
||||
}
|
||||
function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
||||
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
||||
var importMap;
|
||||
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
||||
var moduleSpecifier = _a[_i];
|
||||
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
||||
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
||||
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
var moduleSymbol = checker.resolveExternalModuleName(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
|
||||
}
|
||||
}
|
||||
if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
getImportsForExportInfo: function (_a) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol));
|
||||
if (!matchingDeclarations)
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return matchingDeclarations.map(function (declaration) { return ({ declaration: declaration, importKind: importKind, symbol: symbol, targetFlags: targetFlags }); });
|
||||
}
|
||||
};
|
||||
}
|
||||
function shouldUseRequire(sourceFile, program) {
|
||||
// 1. TypeScript files don't use require variable declarations
|
||||
|
||||
+53
-30
@@ -294,7 +294,7 @@ var ts;
|
||||
// The following is baselined as a literal template type without intervention
|
||||
/** The version of the TypeScript compiler release */
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
ts.version = "4.7.3";
|
||||
ts.version = "4.7.4";
|
||||
/* @internal */
|
||||
var Comparison;
|
||||
(function (Comparison) {
|
||||
@@ -35618,10 +35618,11 @@ var ts;
|
||||
}
|
||||
nextToken();
|
||||
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
||||
if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) {
|
||||
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
||||
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
||||
return undefined;
|
||||
}
|
||||
nextToken();
|
||||
// We successfully parsed a type argument list. The next token determines whether we want to
|
||||
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
||||
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
||||
@@ -132076,10 +132077,9 @@ var ts;
|
||||
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
|
||||
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
|
||||
})(GlobalsSearch || (GlobalsSearch = {}));
|
||||
function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
var _a, _b, _c;
|
||||
var start = ts.timestamp();
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
// Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
|
||||
// package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
|
||||
// relative path into node_modules), and we want to filter those completions out entirely.
|
||||
@@ -132104,7 +132104,7 @@ var ts;
|
||||
return result;
|
||||
function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
|
||||
if (isFromAmbientModule) {
|
||||
var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
|
||||
var result_1 = resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite);
|
||||
if (result_1) {
|
||||
ambientCount++;
|
||||
}
|
||||
@@ -132113,7 +132113,7 @@ var ts;
|
||||
var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
||||
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
||||
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
||||
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
|
||||
? resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, shouldGetModuleSpecifierFromCache)
|
||||
: undefined;
|
||||
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
||||
skippedAny = true;
|
||||
@@ -132218,7 +132218,7 @@ var ts;
|
||||
return undefined;
|
||||
var lowerCaseTokenText = location.text.toLowerCase();
|
||||
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
||||
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
||||
var _a;
|
||||
@@ -133549,6 +133549,7 @@ var ts;
|
||||
var hasUnresolvedAutoImports = false;
|
||||
// This also gets mutated in nested-functions after the return
|
||||
var symbols = [];
|
||||
var importSpecifierResolver;
|
||||
var symbolToOriginInfoMap = [];
|
||||
var symbolToSortTextMap = [];
|
||||
var seenPropertySymbols = new ts.Map();
|
||||
@@ -133770,14 +133771,14 @@ var ts;
|
||||
}
|
||||
else {
|
||||
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
|
||||
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
|
||||
var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{
|
||||
exportKind: 0 /* ExportKind.Named */,
|
||||
moduleFileName: fileName,
|
||||
isFromPackageJson: false,
|
||||
moduleSymbol: moduleSymbol,
|
||||
symbol: firstAccessibleSymbol,
|
||||
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier;
|
||||
if (moduleSpecifier) {
|
||||
var origin = {
|
||||
kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
|
||||
@@ -134033,7 +134034,7 @@ var ts;
|
||||
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
||||
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
||||
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
exportInfo.search(sourceFile.path,
|
||||
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
||||
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
||||
@@ -153064,6 +153065,18 @@ var ts;
|
||||
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
|
||||
}
|
||||
}
|
||||
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(importingFile, preferences, host);
|
||||
var importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
||||
return { getModuleSpecifierForBestExportInfo: getModuleSpecifierForBestExportInfo };
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, importMap, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
}
|
||||
codefix.createImportSpecifierResolver = createImportSpecifierResolver;
|
||||
// Sorted with the preferred fix coming first.
|
||||
var ImportFixKind;
|
||||
(function (ImportFixKind) {
|
||||
@@ -153164,18 +153177,12 @@ var ts;
|
||||
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
||||
}
|
||||
}
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
||||
function getImportFixes(exportInfos, useNamespaceInfo,
|
||||
/** undefined only for missing JSX namespace */
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
|
||||
if (importMap === void 0) { importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()); }
|
||||
var checker = program.getTypeChecker();
|
||||
var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
|
||||
var existingImports = ts.flatMap(exportInfos, importMap.getImportsForExportInfo);
|
||||
var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
|
||||
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
|
||||
if (addToExisting) {
|
||||
@@ -153303,21 +153310,37 @@ var ts;
|
||||
};
|
||||
});
|
||||
}
|
||||
function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
||||
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
||||
var importMap;
|
||||
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
||||
var moduleSpecifier = _a[_i];
|
||||
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
||||
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
||||
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
var moduleSymbol = checker.resolveExternalModuleName(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
|
||||
}
|
||||
}
|
||||
if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
getImportsForExportInfo: function (_a) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol));
|
||||
if (!matchingDeclarations)
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return matchingDeclarations.map(function (declaration) { return ({ declaration: declaration, importKind: importKind, symbol: symbol, targetFlags: targetFlags }); });
|
||||
}
|
||||
};
|
||||
}
|
||||
function shouldUseRequire(sourceFile, program) {
|
||||
// 1. TypeScript files don't use require variable declarations
|
||||
|
||||
+53
-30
@@ -294,7 +294,7 @@ var ts;
|
||||
// The following is baselined as a literal template type without intervention
|
||||
/** The version of the TypeScript compiler release */
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
ts.version = "4.7.3";
|
||||
ts.version = "4.7.4";
|
||||
/* @internal */
|
||||
var Comparison;
|
||||
(function (Comparison) {
|
||||
@@ -35618,10 +35618,11 @@ var ts;
|
||||
}
|
||||
nextToken();
|
||||
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
||||
if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) {
|
||||
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
||||
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
||||
return undefined;
|
||||
}
|
||||
nextToken();
|
||||
// We successfully parsed a type argument list. The next token determines whether we want to
|
||||
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
||||
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
||||
@@ -132076,10 +132077,9 @@ var ts;
|
||||
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
|
||||
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
|
||||
})(GlobalsSearch || (GlobalsSearch = {}));
|
||||
function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
|
||||
var _a, _b, _c;
|
||||
var start = ts.timestamp();
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
// Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
|
||||
// package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
|
||||
// relative path into node_modules), and we want to filter those completions out entirely.
|
||||
@@ -132104,7 +132104,7 @@ var ts;
|
||||
return result;
|
||||
function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
|
||||
if (isFromAmbientModule) {
|
||||
var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
|
||||
var result_1 = resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite);
|
||||
if (result_1) {
|
||||
ambientCount++;
|
||||
}
|
||||
@@ -132113,7 +132113,7 @@ var ts;
|
||||
var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
||||
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
||||
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
||||
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
|
||||
? resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, shouldGetModuleSpecifierFromCache)
|
||||
: undefined;
|
||||
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
||||
skippedAny = true;
|
||||
@@ -132218,7 +132218,7 @@ var ts;
|
||||
return undefined;
|
||||
var lowerCaseTokenText = location.text.toLowerCase();
|
||||
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
|
||||
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
||||
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
||||
var _a;
|
||||
@@ -133549,6 +133549,7 @@ var ts;
|
||||
var hasUnresolvedAutoImports = false;
|
||||
// This also gets mutated in nested-functions after the return
|
||||
var symbols = [];
|
||||
var importSpecifierResolver;
|
||||
var symbolToOriginInfoMap = [];
|
||||
var symbolToSortTextMap = [];
|
||||
var seenPropertySymbols = new ts.Map();
|
||||
@@ -133770,14 +133771,14 @@ var ts;
|
||||
}
|
||||
else {
|
||||
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
|
||||
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
|
||||
var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{
|
||||
exportKind: 0 /* ExportKind.Named */,
|
||||
moduleFileName: fileName,
|
||||
isFromPackageJson: false,
|
||||
moduleSymbol: moduleSymbol,
|
||||
symbol: firstAccessibleSymbol,
|
||||
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
|
||||
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier;
|
||||
if (moduleSpecifier) {
|
||||
var origin = {
|
||||
kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
|
||||
@@ -134033,7 +134034,7 @@ var ts;
|
||||
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
||||
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
||||
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
||||
exportInfo.search(sourceFile.path,
|
||||
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
||||
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
||||
@@ -153064,6 +153065,18 @@ var ts;
|
||||
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
|
||||
}
|
||||
}
|
||||
function createImportSpecifierResolver(importingFile, program, host, preferences) {
|
||||
var packageJsonImportFilter = ts.createPackageJsonImportFilter(importingFile, preferences, host);
|
||||
var importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
|
||||
return { getModuleSpecifierForBestExportInfo: getModuleSpecifierForBestExportInfo };
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, importMap, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
}
|
||||
codefix.createImportSpecifierResolver = createImportSpecifierResolver;
|
||||
// Sorted with the preferred fix coming first.
|
||||
var ImportFixKind;
|
||||
(function (ImportFixKind) {
|
||||
@@ -153164,18 +153177,12 @@ var ts;
|
||||
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
||||
}
|
||||
}
|
||||
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
||||
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
|
||||
/*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
||||
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
||||
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
||||
}
|
||||
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
||||
function getImportFixes(exportInfos, useNamespaceInfo,
|
||||
/** undefined only for missing JSX namespace */
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
|
||||
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
|
||||
if (importMap === void 0) { importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()); }
|
||||
var checker = program.getTypeChecker();
|
||||
var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
|
||||
var existingImports = ts.flatMap(exportInfos, importMap.getImportsForExportInfo);
|
||||
var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
|
||||
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
|
||||
if (addToExisting) {
|
||||
@@ -153303,21 +153310,37 @@ var ts;
|
||||
};
|
||||
});
|
||||
}
|
||||
function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
||||
function createExistingImportMap(checker, importingFile, compilerOptions) {
|
||||
var importMap;
|
||||
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
||||
var moduleSpecifier = _a[_i];
|
||||
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
||||
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
||||
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
var moduleSymbol = checker.resolveExternalModuleName(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
|
||||
}
|
||||
}
|
||||
if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
||||
else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
|
||||
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
getImportsForExportInfo: function (_a) {
|
||||
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
|
||||
// Can't use an es6 import for a type in JS.
|
||||
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
|
||||
return ts.emptyArray;
|
||||
var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol));
|
||||
if (!matchingDeclarations)
|
||||
return ts.emptyArray;
|
||||
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
||||
return matchingDeclarations.map(function (declaration) { return ({ declaration: declaration, importKind: importKind, symbol: symbol, targetFlags: targetFlags }); });
|
||||
}
|
||||
};
|
||||
}
|
||||
function shouldUseRequire(sourceFile, program) {
|
||||
// 1. TypeScript files don't use require variable declarations
|
||||
|
||||
@@ -89,7 +89,7 @@ var ts;
|
||||
// The following is baselined as a literal template type without intervention
|
||||
/** The version of the TypeScript compiler release */
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
ts.version = "4.7.3";
|
||||
ts.version = "4.7.4";
|
||||
/* @internal */
|
||||
var Comparison;
|
||||
(function (Comparison) {
|
||||
@@ -35413,10 +35413,11 @@ var ts;
|
||||
}
|
||||
nextToken();
|
||||
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
|
||||
if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) {
|
||||
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
|
||||
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
||||
return undefined;
|
||||
}
|
||||
nextToken();
|
||||
// We successfully parsed a type argument list. The next token determines whether we want to
|
||||
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
||||
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "https://www.typescriptlang.org/",
|
||||
"version": "4.7.3",
|
||||
"version": "4.7.4",
|
||||
"license": "Apache-2.0",
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ts {
|
||||
// The following is baselined as a literal template type without intervention
|
||||
/** The version of the TypeScript compiler release */
|
||||
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
||||
export const version = "4.7.3" as string;
|
||||
export const version = "4.7.4" as string;
|
||||
|
||||
/**
|
||||
* Type of objects whose values are all of the same type.
|
||||
|
||||
Reference in New Issue
Block a user