Skip to content

Commit

Permalink
Bump version to 4.7.4 and LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
typescript-bot committed Jun 16, 2022
1 parent dfe885b commit 76401ad
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 126 deletions.
5 changes: 3 additions & 2 deletions lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down Expand Up @@ -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() {
Expand Down
83 changes: 53 additions & 30 deletions lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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++;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 */),
Expand Down Expand Up @@ -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())))
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 76401ad

Please sign in to comment.