Update LKG.

This commit is contained in:
Daniel Rosenwasser
2020-09-14 17:37:02 -07:00
parent 0c526fd362
commit eec3a3ee34
21 changed files with 458 additions and 155 deletions
+54 -19
View File
@@ -78,7 +78,7 @@ var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
@@ -2379,6 +2379,15 @@ var ts;
return length <= s.length ? s : s + padString.repeat(length - s.length);
}
ts.padRight = padRight;
function takeWhile(array, predicate) {
var len = array.length;
var index = 0;
while (index < len && predicate(array[index])) {
index++;
}
return array.slice(0, index);
}
ts.takeWhile = takeWhile;
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -8808,6 +8817,7 @@ var ts;
Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type: diag(7055, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type_7055", "'{0}', which lacks return-type annotation, implicitly has an '{1}' yield type."),
The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed: diag(7056, ts.DiagnosticCategory.Error, "The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_ty_7056", "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
@@ -17016,6 +17026,14 @@ var ts;
return options.outFile || options.out;
}
ts.outFile = outFile;
/** Returns 'undefined' if and only if 'options.paths' is undefined. */
function getPathsBasePath(options, host) {
var _a, _b;
if (!options.paths)
return undefined;
return (_a = options.baseUrl) !== null && _a !== void 0 ? _a : ts.Debug.checkDefined(options.pathsBasePath || ((_b = host.getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(host)), "Encountered 'paths' without a 'baseUrl', config file, or host 'getCurrentDirectory'.");
}
ts.getPathsBasePath = getPathsBasePath;
/**
* Gets the source files that are expected to have an emit output.
*
@@ -39031,8 +39049,7 @@ var ts;
}
}
function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) {
var _a, _b;
var _c = state.compilerOptions, baseUrl = _c.baseUrl, paths = _c.paths, pathsBasePath = _c.pathsBasePath;
var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths;
if (paths && !ts.pathIsRelative(moduleName)) {
if (state.traceEnabled) {
if (baseUrl) {
@@ -39040,7 +39057,7 @@ var ts;
}
trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
}
var baseDirectory = baseUrl !== null && baseUrl !== void 0 ? baseUrl : ts.Debug.checkDefined(pathsBasePath || ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)), "Encountered 'paths' without a 'baseUrl', config file, or host 'getCurrentDirectory'.");
var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined
return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state);
}
}
@@ -42256,8 +42273,8 @@ var ts;
if (symbol) {
var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression));
var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */;
var excludeFlags = isAlias ? 2097152 /* AliasExcludes */ : 0 /* None */;
declareSymbol(symbol.exports, symbol, node.left, flags, excludeFlags);
ts.setParent(node.left, node);
declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */);
}
}
function bindModuleExportsAssignment(node) {
@@ -46946,6 +46963,7 @@ var ts;
},
};
function withContext(enclosingDeclaration, flags, tracker, cb) {
var _a, _b;
ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0);
var context = {
enclosingDeclaration: enclosingDeclaration,
@@ -46970,6 +46988,9 @@ var ts;
approximateLength: 0
};
var resultingNode = cb(context);
if (context.truncating && context.flags & 1 /* NoTruncation */) {
(_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a);
}
return context.encounteredError ? undefined : resultingNode;
}
function checkTruncationLength(context) {
@@ -47933,7 +47954,6 @@ var ts;
}
function getSpecifierForModuleSymbol(symbol, context) {
var _a;
var _b;
var file = ts.getDeclarationOfKind(symbol, 300 /* SourceFile */);
if (!file) {
var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
@@ -47978,7 +47998,7 @@ var ts;
var moduleResolverHost = context.tracker.moduleResolverHost;
var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }));
(_a = (_b = links).specifierCache) !== null && _a !== void 0 ? _a : (_b.specifierCache = new ts.Map());
(_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map());
links.specifierCache.set(contextFile.path, specifier);
}
return specifier;
@@ -49171,6 +49191,7 @@ var ts;
break;
case 219 /* BinaryExpression */:
case 204 /* PropertyAccessExpression */:
case 205 /* ElementAccessExpression */:
// Could be best encoded as though an export specifier or as though an export assignment
// If name is default or export=, do an export assignment
// Otherwise do an export specifier
@@ -55444,7 +55465,7 @@ var ts;
}
return undefined;
}
var shouldIncludeUndefined = compilerOptions.noUncheckedIndexSignatures &&
var shouldIncludeUndefined = compilerOptions.noUncheckedIndexedAccess &&
(accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */;
if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
var indexNode = getIndexNodeForAccessExpression(accessNode);
@@ -96707,6 +96728,7 @@ var ts;
reportCyclicStructureError: reportCyclicStructureError,
reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
reportTruncationError: reportTruncationError,
moduleResolverHost: host,
trackReferencedAmbientModule: trackReferencedAmbientModule,
trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
@@ -96806,6 +96828,11 @@ var ts;
context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier));
}
}
function reportTruncationError() {
if (errorNameNode) {
context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed));
}
}
function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
@@ -109169,7 +109196,7 @@ var ts;
var info = getInfo(importingSourceFileName, host);
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences);
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
}
/** Returns an import for each symlink and for the realpath. */
function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
@@ -109199,7 +109226,7 @@ var ts;
return nodeModulesSpecifiers;
}
if (!specifier && !modulePath.isRedirect) {
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, preferences);
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
if (ts.pathIsBareSpecifier(local)) {
pathsSpecifiers = ts.append(pathsSpecifiers, local);
}
@@ -109228,16 +109255,17 @@ var ts;
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory };
}
function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, _b) {
function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) {
var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
var ending = _b.ending, relativePreference = _b.relativePreference;
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs, bundledPackageName = compilerOptions.bundledPackageName;
var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
if (!baseUrl || relativePreference === 0 /* Relative */) {
if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
return relativePath;
}
var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName);
var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl;
var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName);
if (!relativeToBaseUrl) {
return relativePath;
}
@@ -143161,7 +143189,6 @@ var ts;
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences));
addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host));
}
// Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file.
function getStatementsToMove(context) {
var rangeToMove = getRangeToMove(context);
if (rangeToMove === undefined)
@@ -143169,13 +143196,20 @@ var ts;
var all = [];
var ranges = [];
var toMove = rangeToMove.toMove, afterLast = rangeToMove.afterLast;
ts.getRangesWhere(toMove, function (s) { return !isPureImport(s); }, function (start, afterEndIndex) {
ts.getRangesWhere(toMove, isAllowedStatementToMove, function (start, afterEndIndex) {
for (var i = start; i < afterEndIndex; i++)
all.push(toMove[i]);
ranges.push({ first: toMove[start], afterLast: afterLast });
});
return all.length === 0 ? undefined : { all: all, ranges: ranges };
}
function isAllowedStatementToMove(statement) {
// Filters imports and prologue directives out of the range of statements to move.
// Imports will be copied to the new file anyway, and may still be needed in the old file.
// Prologue directives will be copied to the new file and should be left in the old file.
return !isPureImport(statement) && !ts.isPrologueDirective(statement);
;
}
function isPureImport(node) {
switch (node.kind) {
case 264 /* ImportDeclaration */:
@@ -143204,9 +143238,10 @@ var ts;
}
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
var checker = program.getTypeChecker();
var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
deleteMovedStatements(oldFile, toMove.ranges, changes);
return toMove.all;
return __spreadArrays(prologueDirectives, toMove.all);
}
var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
var quotePreference = ts.getQuotePreference(oldFile, preferences);
@@ -143220,11 +143255,11 @@ var ts;
var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference);
var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax);
if (imports.length && body.length) {
return __spreadArrays(imports, [
return __spreadArrays(prologueDirectives, imports, [
4 /* NewLineTrivia */
], body);
}
return __spreadArrays(imports, body);
return __spreadArrays(prologueDirectives, imports, body);
}
function deleteMovedStatements(sourceFile, moved, changes) {
for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) {