Skip to content

Commit 76401ad

Browse files
Bump version to 4.7.4 and LKG
1 parent dfe885b commit 76401ad

8 files changed

+220
-126
lines changed

lib/tsc.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
6969
var ts;
7070
(function (ts) {
7171
ts.versionMajorMinor = "4.7";
72-
ts.version = "4.7.3";
72+
ts.version = "4.7.4";
7373
var NativeCollections;
7474
(function (NativeCollections) {
7575
var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -28447,9 +28447,10 @@ var ts;
2844728447
}
2844828448
nextToken();
2844928449
var typeArguments = parseDelimitedList(20, parseType);
28450-
if (!parseExpected(31)) {
28450+
if (reScanGreaterToken() !== 31) {
2845128451
return undefined;
2845228452
}
28453+
nextToken();
2845328454
return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
2845428455
}
2845528456
function canFollowTypeArgumentsInExpression() {

lib/tsserver.js

+53-30
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var ts;
100100
// The following is baselined as a literal template type without intervention
101101
/** The version of the TypeScript compiler release */
102102
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
103-
ts.version = "4.7.3";
103+
ts.version = "4.7.4";
104104
/* @internal */
105105
var Comparison;
106106
(function (Comparison) {
@@ -35424,10 +35424,11 @@ var ts;
3542435424
}
3542535425
nextToken();
3542635426
var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
35427-
if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) {
35427+
if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) {
3542835428
// If it doesn't have the closing `>` then it's definitely not an type argument list.
3542935429
return undefined;
3543035430
}
35431+
nextToken();
3543135432
// We successfully parsed a type argument list. The next token determines whether we want to
3543235433
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
3543335434
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
@@ -131465,10 +131466,9 @@ var ts;
131465131466
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
131466131467
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
131467131468
})(GlobalsSearch || (GlobalsSearch = {}));
131468-
function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
131469+
function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
131469131470
var _a, _b, _c;
131470131471
var start = ts.timestamp();
131471-
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131472131472
// Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
131473131473
// package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
131474131474
// relative path into node_modules), and we want to filter those completions out entirely.
@@ -131493,7 +131493,7 @@ var ts;
131493131493
return result;
131494131494
function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
131495131495
if (isFromAmbientModule) {
131496-
var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
131496+
var result_1 = resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite);
131497131497
if (result_1) {
131498131498
ambientCount++;
131499131499
}
@@ -131502,7 +131502,7 @@ var ts;
131502131502
var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131503131503
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131504131504
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131505-
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131505+
? resolver.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, shouldGetModuleSpecifierFromCache)
131506131506
: undefined;
131507131507
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131508131508
skippedAny = true;
@@ -131607,7 +131607,7 @@ var ts;
131607131607
return undefined;
131608131608
var lowerCaseTokenText = location.text.toLowerCase();
131609131609
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
131610-
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131610+
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
131611131611
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131612131612
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131613131613
var _a;
@@ -132938,6 +132938,7 @@ var ts;
132938132938
var hasUnresolvedAutoImports = false;
132939132939
// This also gets mutated in nested-functions after the return
132940132940
var symbols = [];
132941+
var importSpecifierResolver;
132941132942
var symbolToOriginInfoMap = [];
132942132943
var symbolToSortTextMap = [];
132943132944
var seenPropertySymbols = new ts.Map();
@@ -133159,14 +133160,14 @@ var ts;
133159133160
}
133160133161
else {
133161133162
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
133162-
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
133163+
var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{
133163133164
exportKind: 0 /* ExportKind.Named */,
133164133165
moduleFileName: fileName,
133165133166
isFromPackageJson: false,
133166133167
moduleSymbol: moduleSymbol,
133167133168
symbol: firstAccessibleSymbol,
133168133169
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
133169-
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
133170+
}], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier;
133170133171
if (moduleSpecifier) {
133171133172
var origin = {
133172133173
kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
@@ -133422,7 +133423,7 @@ var ts;
133422133423
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
133423133424
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
133424133425
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
133425-
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133426+
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133426133427
exportInfo.search(sourceFile.path,
133427133428
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
133428133429
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
@@ -152453,6 +152454,18 @@ var ts;
152453152454
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
152454152455
}
152455152456
}
152457+
function createImportSpecifierResolver(importingFile, program, host, preferences) {
152458+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(importingFile, preferences, host);
152459+
var importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
152460+
return { getModuleSpecifierForBestExportInfo: getModuleSpecifierForBestExportInfo };
152461+
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, fromCacheOnly) {
152462+
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
152463+
/*useRequire*/ false, program, importingFile, host, preferences, importMap, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152464+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
152465+
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
152466+
}
152467+
}
152468+
codefix.createImportSpecifierResolver = createImportSpecifierResolver;
152456152469
// Sorted with the preferred fix coming first.
152457152470
var ImportFixKind;
152458152471
(function (ImportFixKind) {
@@ -152553,18 +152566,12 @@ var ts;
152553152566
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
152554152567
}
152555152568
}
152556-
function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152557-
var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
152558-
/*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152559-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
152560-
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
152561-
}
152562-
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
152563152569
function getImportFixes(exportInfos, useNamespaceInfo,
152564152570
/** undefined only for missing JSX namespace */
152565-
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
152571+
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
152572+
if (importMap === void 0) { importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()); }
152566152573
var checker = program.getTypeChecker();
152567-
var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
152574+
var existingImports = ts.flatMap(exportInfos, importMap.getImportsForExportInfo);
152568152575
var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
152569152576
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
152570152577
if (addToExisting) {
@@ -152692,21 +152699,37 @@ var ts;
152692152699
};
152693152700
});
152694152701
}
152695-
function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) {
152696-
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
152697-
// Can't use an es6 import for a type in JS.
152698-
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
152699-
return ts.emptyArray;
152700-
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
152701-
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
152702+
function createExistingImportMap(checker, importingFile, compilerOptions) {
152703+
var importMap;
152704+
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
152705+
var moduleSpecifier = _a[_i];
152702152706
var i = ts.importFromModuleSpecifier(moduleSpecifier);
152703152707
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
152704-
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
152708+
var moduleSymbol = checker.resolveExternalModuleName(moduleSpecifier);
152709+
if (moduleSymbol) {
152710+
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
152711+
}
152705152712
}
152706-
if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
152707-
return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
152713+
else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
152714+
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
152715+
if (moduleSymbol) {
152716+
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
152717+
}
152708152718
}
152709-
});
152719+
}
152720+
return {
152721+
getImportsForExportInfo: function (_a) {
152722+
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
152723+
// Can't use an es6 import for a type in JS.
152724+
if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
152725+
return ts.emptyArray;
152726+
var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol));
152727+
if (!matchingDeclarations)
152728+
return ts.emptyArray;
152729+
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
152730+
return matchingDeclarations.map(function (declaration) { return ({ declaration: declaration, importKind: importKind, symbol: symbol, targetFlags: targetFlags }); });
152731+
}
152732+
};
152710152733
}
152711152734
function shouldUseRequire(sourceFile, program) {
152712152735
// 1. TypeScript files don't use require variable declarations

0 commit comments

Comments
 (0)