Update LKG for 3.8.2.

This commit is contained in:
Daniel Rosenwasser 2020-02-14 15:41:28 -08:00
parent 203ed3ec44
commit 870cd7b603
8 changed files with 574 additions and 452 deletions

10
lib/protocol.d.ts vendored
View File

@ -146,6 +146,16 @@ declare namespace ts.server.protocol {
* Contains extra information that plugin can include to be passed on
*/
metadata?: unknown;
/**
* Exposes information about the performance of this request-response pair.
*/
performanceData?: PerformanceData;
}
interface PerformanceData {
/**
* Time spent updating the program graph, in milliseconds.
*/
updateGraphDurationMs?: number;
}
/**
* Arguments for FileRequest messages.

View File

@ -67,7 +67,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
var ts;
(function (ts) {
ts.versionMajorMinor = "3.8";
ts.version = ts.versionMajorMinor + ".1-rc";
ts.version = ts.versionMajorMinor + ".2";
function tryGetNativeMap() {
return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined;
}
@ -19385,17 +19385,18 @@ var ts;
}
return finishNode(node);
}
function parseNamespaceExport() {
var node = createNode(262);
function parseNamespaceExport(pos) {
var node = createNode(262, pos);
node.name = parseIdentifier();
return finishNode(node);
}
function parseExportDeclaration(node) {
node.kind = 260;
node.isTypeOnly = parseOptional(145);
var namespaceExportPos = scanner.getStartPos();
if (parseOptional(41)) {
if (parseOptional(123)) {
node.exportClause = parseNamespaceExport();
node.exportClause = parseNamespaceExport(namespaceExportPos);
}
parseExpected(149);
node.moduleSpecifier = parseModuleSpecifier();
@ -40366,7 +40367,7 @@ var ts;
}
}
if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
var objectOnlyTarget = extractTypesOfKind(target, 524288);
var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
if (objectOnlyTarget.flags & 1048576) {
var result_4 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
if (result_4) {
@ -40423,7 +40424,7 @@ var ts;
return 0;
}
function typeRelatedToDiscriminatedType(source, target) {
var sourceProperties = getPropertiesOfObjectType(source);
var sourceProperties = getPropertiesOfType(source);
var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
if (!sourcePropertiesFiltered)
return 0;
@ -40453,7 +40454,7 @@ var ts;
var type = _a[_i];
var _loop_13 = function (i) {
var sourceProperty = sourcePropertiesFiltered[i];
var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName);
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
if (!targetProperty)
return "continue-outer";
if (sourceProperty === targetProperty)
@ -50871,7 +50872,7 @@ var ts;
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node) {
return ts.hasModifier(node, 8) && !!(node.flags & 8388608);
return (ts.hasModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedModifierFlags(n);

View File

@ -94,7 +94,7 @@ var ts;
// If changing the text in this section, be sure to test `configurePrerelease` too.
ts.versionMajorMinor = "3.8";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".1-rc";
ts.version = ts.versionMajorMinor + ".2";
/**
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
*/
@ -24091,17 +24091,18 @@ var ts;
}
return finishNode(node);
}
function parseNamespaceExport() {
var node = createNode(262 /* NamespaceExport */);
function parseNamespaceExport(pos) {
var node = createNode(262 /* NamespaceExport */, pos);
node.name = parseIdentifier();
return finishNode(node);
}
function parseExportDeclaration(node) {
node.kind = 260 /* ExportDeclaration */;
node.isTypeOnly = parseOptional(145 /* TypeKeyword */);
var namespaceExportPos = scanner.getStartPos();
if (parseOptional(41 /* AsteriskToken */)) {
if (parseOptional(123 /* AsKeyword */)) {
node.exportClause = parseNamespaceExport();
node.exportClause = parseNamespaceExport(namespaceExportPos);
}
parseExpected(149 /* FromKeyword */);
node.moduleSpecifier = parseModuleSpecifier();
@ -48437,7 +48438,7 @@ var ts;
// with respect to T. We do not report errors here, as we will use the existing
// error result from checking each constituent of the union.
if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */);
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
if (objectOnlyTarget.flags & 1048576 /* Union */) {
var result_4 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
if (result_4) {
@ -48528,7 +48529,7 @@ var ts;
//
// NOTE: See ~/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts
// for examples.
var sourceProperties = getPropertiesOfObjectType(source);
var sourceProperties = getPropertiesOfType(source);
var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
if (!sourcePropertiesFiltered)
return 0 /* False */;
@ -48567,7 +48568,7 @@ var ts;
var type = _a[_i];
var _loop_13 = function (i) {
var sourceProperty = sourcePropertiesFiltered[i];
var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName);
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
if (!targetProperty)
return "continue-outer";
if (sourceProperty === targetProperty)
@ -60685,7 +60686,7 @@ var ts;
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node) {
return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */);
return (ts.hasModifier(node, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedModifierFlags(n);
@ -114496,11 +114497,13 @@ var ts;
return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]);
}
var exportSpecifier = ts.getDeclarationOfKind(symbol, 263 /* ExportSpecifier */);
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) {
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
}
}
// symbolAtLocation for a binding element is the local symbol. See if the search symbol is the property.
// Don't do this when populating search set for a rename when prefix and suffix text will be provided -- just rename the local.
@ -117108,100 +117111,112 @@ var ts;
* @param importGroup a list of ImportDeclarations, all with the same module name.
*/
function coalesceImports(importGroup) {
var _a;
if (importGroup.length === 0) {
return importGroup;
}
var _a = getCategorizedImports(importGroup), importWithoutClause = _a.importWithoutClause, defaultImports = _a.defaultImports, namespaceImports = _a.namespaceImports, namedImports = _a.namedImports;
var _b = getCategorizedImports(importGroup), importWithoutClause = _b.importWithoutClause, typeOnlyImports = _b.typeOnlyImports, regularImports = _b.regularImports;
var coalescedImports = [];
if (importWithoutClause) {
coalescedImports.push(importWithoutClause);
}
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
return coalescedImports;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _i = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _i < sortedNamespaceImports_1.length; _i++) {
var namespaceImport = sortedNamespaceImports_1[_i];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
return coalescedImports;
}
var newDefaultImport;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _b = 0, defaultImports_1 = defaultImports; _b < defaultImports_1.length; _b++) {
var defaultImport = defaultImports_1[_b];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
for (var _i = 0, _c = [regularImports, typeOnlyImports]; _i < _c.length; _i++) {
var group_2 = _c[_i];
var isTypeOnly = group_2 === typeOnlyImports;
var defaultImports = group_2.defaultImports, namespaceImports = group_2.namespaceImports, namedImports = group_2.namedImports;
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (!isTypeOnly && defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
continue;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _d = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _d < sortedNamespaceImports_1.length; _d++) {
var namespaceImport = sortedNamespaceImports_1[_d];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
continue;
}
var newDefaultImport = void 0;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _e = 0, defaultImports_1 = defaultImports; _e < defaultImports_1.length; _e++) {
var defaultImport = defaultImports_1[_e];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
// Type-only imports are not allowed to combine
if (isTypeOnly && newDefaultImport && newNamedImports) {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, /*namedBindings*/ undefined));
coalescedImports.push(updateImportDeclarationAndClause((_a = namedImports[0]) !== null && _a !== void 0 ? _a : importDecl, /*name*/ undefined, newNamedImports));
}
else {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
return coalescedImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var defaultImports = [];
var namespaceImports = [];
var namedImports = [];
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
namespaceImports.push(importDeclaration);
}
else {
namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
defaultImports: defaultImports,
namespaceImports: namespaceImports,
namedImports: namedImports,
};
}
}
OrganizeImports.coalesceImports = coalesceImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var typeOnlyImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
var regularImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var group_3 = importDeclaration.importClause.isTypeOnly ? typeOnlyImports : regularImports;
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
group_3.defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
group_3.namespaceImports.push(importDeclaration);
}
else {
group_3.namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
typeOnlyImports: typeOnlyImports,
regularImports: regularImports,
};
}
// Internal for testing
/**
* @param exportGroup a list of ExportDeclarations, all with the same module name.
@ -117210,21 +117225,24 @@ var ts;
if (exportGroup.length === 0) {
return exportGroup;
}
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports;
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports, typeOnlyExports = _a.typeOnlyExports;
var coalescedExports = [];
if (exportWithoutClause) {
coalescedExports.push(exportWithoutClause);
}
if (namedExports.length === 0) {
return coalescedExports;
for (var _i = 0, _b = [namedExports, typeOnlyExports]; _i < _b.length; _i++) {
var exportGroup_1 = _b[_i];
if (exportGroup_1.length === 0) {
continue;
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(exportGroup_1, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = exportGroup_1[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(namedExports, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = namedExports[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
return coalescedExports;
/*
* Returns entire export declarations because they may already have been rewritten and
@ -117234,13 +117252,17 @@ var ts;
function getCategorizedExports(exportGroup) {
var exportWithoutClause;
var namedExports = [];
for (var _i = 0, exportGroup_1 = exportGroup; _i < exportGroup_1.length; _i++) {
var exportDeclaration = exportGroup_1[_i];
var typeOnlyExports = [];
for (var _i = 0, exportGroup_2 = exportGroup; _i < exportGroup_2.length; _i++) {
var exportDeclaration = exportGroup_2[_i];
if (exportDeclaration.exportClause === undefined) {
// Only the first such export is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
exportWithoutClause = exportWithoutClause || exportDeclaration;
}
else if (exportDeclaration.isTypeOnly) {
typeOnlyExports.push(exportDeclaration);
}
else {
namedExports.push(exportDeclaration);
}
@ -117248,6 +117270,7 @@ var ts;
return {
exportWithoutClause: exportWithoutClause,
namedExports: namedExports,
typeOnlyExports: typeOnlyExports,
};
}
}
@ -124267,9 +124290,10 @@ var ts;
break;
}
case 254 /* ImportDeclaration */:
var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isImportDeclaration);
deleteNode(changes, sourceFile, node,
// For first import, leave header comment in place
node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
isFirstImport ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
break;
case 191 /* BindingElement */:
var pattern = node.parent;
@ -133951,7 +133975,7 @@ var ts;
var node = getNodeOrParentOfParentheses(file, startPosition);
var maybeBinary = getParentBinaryExpression(node);
var refactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
if ((ts.isBinaryExpression(maybeBinary) || ts.isStringLiteral(maybeBinary)) && isStringConcatenationValid(maybeBinary)) {
if (ts.isBinaryExpression(maybeBinary) && isStringConcatenationValid(maybeBinary)) {
refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
return [refactorInfo];
}
@ -138518,6 +138542,8 @@ var ts;
/*@internal*/
function isDynamicFileName(fileName) {
return fileName[0] === "^" ||
((ts.stringContains(fileName, "walkThroughSnippet:/") || ts.stringContains(fileName, "untitled:/")) &&
ts.getBaseFileName(fileName)[0] === "^") ||
(ts.stringContains(fileName, ":^") && !ts.stringContains(fileName, ts.directorySeparator));
}
server.isDynamicFileName = isDynamicFileName;

View File

@ -6253,6 +6253,16 @@ declare namespace ts.server.protocol {
* Contains extra information that plugin can include to be passed on
*/
metadata?: unknown;
/**
* Exposes information about the performance of this request-response pair.
*/
performanceData?: PerformanceData;
}
interface PerformanceData {
/**
* Time spent updating the program graph, in milliseconds.
*/
updateGraphDurationMs?: number;
}
/**
* Arguments for FileRequest messages.

View File

@ -244,7 +244,7 @@ var ts;
// If changing the text in this section, be sure to test `configurePrerelease` too.
ts.versionMajorMinor = "3.8";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".1-rc";
ts.version = ts.versionMajorMinor + ".2";
/**
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
*/
@ -24241,17 +24241,18 @@ var ts;
}
return finishNode(node);
}
function parseNamespaceExport() {
var node = createNode(262 /* NamespaceExport */);
function parseNamespaceExport(pos) {
var node = createNode(262 /* NamespaceExport */, pos);
node.name = parseIdentifier();
return finishNode(node);
}
function parseExportDeclaration(node) {
node.kind = 260 /* ExportDeclaration */;
node.isTypeOnly = parseOptional(145 /* TypeKeyword */);
var namespaceExportPos = scanner.getStartPos();
if (parseOptional(41 /* AsteriskToken */)) {
if (parseOptional(123 /* AsKeyword */)) {
node.exportClause = parseNamespaceExport();
node.exportClause = parseNamespaceExport(namespaceExportPos);
}
parseExpected(149 /* FromKeyword */);
node.moduleSpecifier = parseModuleSpecifier();
@ -48587,7 +48588,7 @@ var ts;
// with respect to T. We do not report errors here, as we will use the existing
// error result from checking each constituent of the union.
if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */);
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
if (objectOnlyTarget.flags & 1048576 /* Union */) {
var result_4 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
if (result_4) {
@ -48678,7 +48679,7 @@ var ts;
//
// NOTE: See ~/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts
// for examples.
var sourceProperties = getPropertiesOfObjectType(source);
var sourceProperties = getPropertiesOfType(source);
var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
if (!sourcePropertiesFiltered)
return 0 /* False */;
@ -48717,7 +48718,7 @@ var ts;
var type = _a[_i];
var _loop_13 = function (i) {
var sourceProperty = sourcePropertiesFiltered[i];
var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName);
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
if (!targetProperty)
return "continue-outer";
if (sourceProperty === targetProperty)
@ -60835,7 +60836,7 @@ var ts;
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node) {
return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */);
return (ts.hasModifier(node, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedModifierFlags(n);
@ -115019,11 +115020,13 @@ var ts;
return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]);
}
var exportSpecifier = ts.getDeclarationOfKind(symbol, 263 /* ExportSpecifier */);
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) {
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
}
}
// symbolAtLocation for a binding element is the local symbol. See if the search symbol is the property.
// Don't do this when populating search set for a rename when prefix and suffix text will be provided -- just rename the local.
@ -117631,100 +117634,112 @@ var ts;
* @param importGroup a list of ImportDeclarations, all with the same module name.
*/
function coalesceImports(importGroup) {
var _a;
if (importGroup.length === 0) {
return importGroup;
}
var _a = getCategorizedImports(importGroup), importWithoutClause = _a.importWithoutClause, defaultImports = _a.defaultImports, namespaceImports = _a.namespaceImports, namedImports = _a.namedImports;
var _b = getCategorizedImports(importGroup), importWithoutClause = _b.importWithoutClause, typeOnlyImports = _b.typeOnlyImports, regularImports = _b.regularImports;
var coalescedImports = [];
if (importWithoutClause) {
coalescedImports.push(importWithoutClause);
}
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
return coalescedImports;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _i = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _i < sortedNamespaceImports_1.length; _i++) {
var namespaceImport = sortedNamespaceImports_1[_i];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
return coalescedImports;
}
var newDefaultImport;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _b = 0, defaultImports_1 = defaultImports; _b < defaultImports_1.length; _b++) {
var defaultImport = defaultImports_1[_b];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
for (var _i = 0, _c = [regularImports, typeOnlyImports]; _i < _c.length; _i++) {
var group_2 = _c[_i];
var isTypeOnly = group_2 === typeOnlyImports;
var defaultImports = group_2.defaultImports, namespaceImports = group_2.namespaceImports, namedImports = group_2.namedImports;
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (!isTypeOnly && defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
continue;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _d = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _d < sortedNamespaceImports_1.length; _d++) {
var namespaceImport = sortedNamespaceImports_1[_d];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
continue;
}
var newDefaultImport = void 0;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _e = 0, defaultImports_1 = defaultImports; _e < defaultImports_1.length; _e++) {
var defaultImport = defaultImports_1[_e];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
// Type-only imports are not allowed to combine
if (isTypeOnly && newDefaultImport && newNamedImports) {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, /*namedBindings*/ undefined));
coalescedImports.push(updateImportDeclarationAndClause((_a = namedImports[0]) !== null && _a !== void 0 ? _a : importDecl, /*name*/ undefined, newNamedImports));
}
else {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
return coalescedImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var defaultImports = [];
var namespaceImports = [];
var namedImports = [];
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
namespaceImports.push(importDeclaration);
}
else {
namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
defaultImports: defaultImports,
namespaceImports: namespaceImports,
namedImports: namedImports,
};
}
}
OrganizeImports.coalesceImports = coalesceImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var typeOnlyImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
var regularImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var group_3 = importDeclaration.importClause.isTypeOnly ? typeOnlyImports : regularImports;
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
group_3.defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
group_3.namespaceImports.push(importDeclaration);
}
else {
group_3.namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
typeOnlyImports: typeOnlyImports,
regularImports: regularImports,
};
}
// Internal for testing
/**
* @param exportGroup a list of ExportDeclarations, all with the same module name.
@ -117733,21 +117748,24 @@ var ts;
if (exportGroup.length === 0) {
return exportGroup;
}
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports;
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports, typeOnlyExports = _a.typeOnlyExports;
var coalescedExports = [];
if (exportWithoutClause) {
coalescedExports.push(exportWithoutClause);
}
if (namedExports.length === 0) {
return coalescedExports;
for (var _i = 0, _b = [namedExports, typeOnlyExports]; _i < _b.length; _i++) {
var exportGroup_1 = _b[_i];
if (exportGroup_1.length === 0) {
continue;
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(exportGroup_1, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = exportGroup_1[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(namedExports, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = namedExports[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
return coalescedExports;
/*
* Returns entire export declarations because they may already have been rewritten and
@ -117757,13 +117775,17 @@ var ts;
function getCategorizedExports(exportGroup) {
var exportWithoutClause;
var namedExports = [];
for (var _i = 0, exportGroup_1 = exportGroup; _i < exportGroup_1.length; _i++) {
var exportDeclaration = exportGroup_1[_i];
var typeOnlyExports = [];
for (var _i = 0, exportGroup_2 = exportGroup; _i < exportGroup_2.length; _i++) {
var exportDeclaration = exportGroup_2[_i];
if (exportDeclaration.exportClause === undefined) {
// Only the first such export is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
exportWithoutClause = exportWithoutClause || exportDeclaration;
}
else if (exportDeclaration.isTypeOnly) {
typeOnlyExports.push(exportDeclaration);
}
else {
namedExports.push(exportDeclaration);
}
@ -117771,6 +117793,7 @@ var ts;
return {
exportWithoutClause: exportWithoutClause,
namedExports: namedExports,
typeOnlyExports: typeOnlyExports,
};
}
}
@ -124790,9 +124813,10 @@ var ts;
break;
}
case 254 /* ImportDeclaration */:
var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isImportDeclaration);
deleteNode(changes, sourceFile, node,
// For first import, leave header comment in place
node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
isFirstImport ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
break;
case 191 /* BindingElement */:
var pattern = node.parent;
@ -134474,7 +134498,7 @@ var ts;
var node = getNodeOrParentOfParentheses(file, startPosition);
var maybeBinary = getParentBinaryExpression(node);
var refactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
if ((ts.isBinaryExpression(maybeBinary) || ts.isStringLiteral(maybeBinary)) && isStringConcatenationValid(maybeBinary)) {
if (ts.isBinaryExpression(maybeBinary) && isStringConcatenationValid(maybeBinary)) {
refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
return [refactorInfo];
}
@ -138668,6 +138692,8 @@ var ts;
/*@internal*/
function isDynamicFileName(fileName) {
return fileName[0] === "^" ||
((ts.stringContains(fileName, "walkThroughSnippet:/") || ts.stringContains(fileName, "untitled:/")) &&
ts.getBaseFileName(fileName)[0] === "^") ||
(ts.stringContains(fileName, ":^") && !ts.stringContains(fileName, ts.directorySeparator));
}
server.isDynamicFileName = isDynamicFileName;

View File

@ -244,7 +244,7 @@ var ts;
// If changing the text in this section, be sure to test `configurePrerelease` too.
ts.versionMajorMinor = "3.8";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".1-rc";
ts.version = ts.versionMajorMinor + ".2";
/**
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
*/
@ -24241,17 +24241,18 @@ var ts;
}
return finishNode(node);
}
function parseNamespaceExport() {
var node = createNode(262 /* NamespaceExport */);
function parseNamespaceExport(pos) {
var node = createNode(262 /* NamespaceExport */, pos);
node.name = parseIdentifier();
return finishNode(node);
}
function parseExportDeclaration(node) {
node.kind = 260 /* ExportDeclaration */;
node.isTypeOnly = parseOptional(145 /* TypeKeyword */);
var namespaceExportPos = scanner.getStartPos();
if (parseOptional(41 /* AsteriskToken */)) {
if (parseOptional(123 /* AsKeyword */)) {
node.exportClause = parseNamespaceExport();
node.exportClause = parseNamespaceExport(namespaceExportPos);
}
parseExpected(149 /* FromKeyword */);
node.moduleSpecifier = parseModuleSpecifier();
@ -48587,7 +48588,7 @@ var ts;
// with respect to T. We do not report errors here, as we will use the existing
// error result from checking each constituent of the union.
if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */);
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
if (objectOnlyTarget.flags & 1048576 /* Union */) {
var result_4 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
if (result_4) {
@ -48678,7 +48679,7 @@ var ts;
//
// NOTE: See ~/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts
// for examples.
var sourceProperties = getPropertiesOfObjectType(source);
var sourceProperties = getPropertiesOfType(source);
var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
if (!sourcePropertiesFiltered)
return 0 /* False */;
@ -48717,7 +48718,7 @@ var ts;
var type = _a[_i];
var _loop_13 = function (i) {
var sourceProperty = sourcePropertiesFiltered[i];
var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName);
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
if (!targetProperty)
return "continue-outer";
if (sourceProperty === targetProperty)
@ -60835,7 +60836,7 @@ var ts;
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node) {
return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */);
return (ts.hasModifier(node, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedModifierFlags(n);
@ -115019,11 +115020,13 @@ var ts;
return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]);
}
var exportSpecifier = ts.getDeclarationOfKind(symbol, 263 /* ExportSpecifier */);
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) {
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
}
}
// symbolAtLocation for a binding element is the local symbol. See if the search symbol is the property.
// Don't do this when populating search set for a rename when prefix and suffix text will be provided -- just rename the local.
@ -117631,100 +117634,112 @@ var ts;
* @param importGroup a list of ImportDeclarations, all with the same module name.
*/
function coalesceImports(importGroup) {
var _a;
if (importGroup.length === 0) {
return importGroup;
}
var _a = getCategorizedImports(importGroup), importWithoutClause = _a.importWithoutClause, defaultImports = _a.defaultImports, namespaceImports = _a.namespaceImports, namedImports = _a.namedImports;
var _b = getCategorizedImports(importGroup), importWithoutClause = _b.importWithoutClause, typeOnlyImports = _b.typeOnlyImports, regularImports = _b.regularImports;
var coalescedImports = [];
if (importWithoutClause) {
coalescedImports.push(importWithoutClause);
}
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
return coalescedImports;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _i = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _i < sortedNamespaceImports_1.length; _i++) {
var namespaceImport = sortedNamespaceImports_1[_i];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
return coalescedImports;
}
var newDefaultImport;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _b = 0, defaultImports_1 = defaultImports; _b < defaultImports_1.length; _b++) {
var defaultImport = defaultImports_1[_b];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
for (var _i = 0, _c = [regularImports, typeOnlyImports]; _i < _c.length; _i++) {
var group_2 = _c[_i];
var isTypeOnly = group_2 === typeOnlyImports;
var defaultImports = group_2.defaultImports, namespaceImports = group_2.namespaceImports, namedImports = group_2.namedImports;
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (!isTypeOnly && defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
continue;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _d = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _d < sortedNamespaceImports_1.length; _d++) {
var namespaceImport = sortedNamespaceImports_1[_d];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
continue;
}
var newDefaultImport = void 0;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _e = 0, defaultImports_1 = defaultImports; _e < defaultImports_1.length; _e++) {
var defaultImport = defaultImports_1[_e];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
// Type-only imports are not allowed to combine
if (isTypeOnly && newDefaultImport && newNamedImports) {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, /*namedBindings*/ undefined));
coalescedImports.push(updateImportDeclarationAndClause((_a = namedImports[0]) !== null && _a !== void 0 ? _a : importDecl, /*name*/ undefined, newNamedImports));
}
else {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
return coalescedImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var defaultImports = [];
var namespaceImports = [];
var namedImports = [];
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
namespaceImports.push(importDeclaration);
}
else {
namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
defaultImports: defaultImports,
namespaceImports: namespaceImports,
namedImports: namedImports,
};
}
}
OrganizeImports.coalesceImports = coalesceImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var typeOnlyImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
var regularImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var group_3 = importDeclaration.importClause.isTypeOnly ? typeOnlyImports : regularImports;
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
group_3.defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
group_3.namespaceImports.push(importDeclaration);
}
else {
group_3.namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
typeOnlyImports: typeOnlyImports,
regularImports: regularImports,
};
}
// Internal for testing
/**
* @param exportGroup a list of ExportDeclarations, all with the same module name.
@ -117733,21 +117748,24 @@ var ts;
if (exportGroup.length === 0) {
return exportGroup;
}
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports;
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports, typeOnlyExports = _a.typeOnlyExports;
var coalescedExports = [];
if (exportWithoutClause) {
coalescedExports.push(exportWithoutClause);
}
if (namedExports.length === 0) {
return coalescedExports;
for (var _i = 0, _b = [namedExports, typeOnlyExports]; _i < _b.length; _i++) {
var exportGroup_1 = _b[_i];
if (exportGroup_1.length === 0) {
continue;
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(exportGroup_1, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = exportGroup_1[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(namedExports, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = namedExports[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
return coalescedExports;
/*
* Returns entire export declarations because they may already have been rewritten and
@ -117757,13 +117775,17 @@ var ts;
function getCategorizedExports(exportGroup) {
var exportWithoutClause;
var namedExports = [];
for (var _i = 0, exportGroup_1 = exportGroup; _i < exportGroup_1.length; _i++) {
var exportDeclaration = exportGroup_1[_i];
var typeOnlyExports = [];
for (var _i = 0, exportGroup_2 = exportGroup; _i < exportGroup_2.length; _i++) {
var exportDeclaration = exportGroup_2[_i];
if (exportDeclaration.exportClause === undefined) {
// Only the first such export is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
exportWithoutClause = exportWithoutClause || exportDeclaration;
}
else if (exportDeclaration.isTypeOnly) {
typeOnlyExports.push(exportDeclaration);
}
else {
namedExports.push(exportDeclaration);
}
@ -117771,6 +117793,7 @@ var ts;
return {
exportWithoutClause: exportWithoutClause,
namedExports: namedExports,
typeOnlyExports: typeOnlyExports,
};
}
}
@ -124790,9 +124813,10 @@ var ts;
break;
}
case 254 /* ImportDeclaration */:
var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isImportDeclaration);
deleteNode(changes, sourceFile, node,
// For first import, leave header comment in place
node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
isFirstImport ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
break;
case 191 /* BindingElement */:
var pattern = node.parent;
@ -134474,7 +134498,7 @@ var ts;
var node = getNodeOrParentOfParentheses(file, startPosition);
var maybeBinary = getParentBinaryExpression(node);
var refactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
if ((ts.isBinaryExpression(maybeBinary) || ts.isStringLiteral(maybeBinary)) && isStringConcatenationValid(maybeBinary)) {
if (ts.isBinaryExpression(maybeBinary) && isStringConcatenationValid(maybeBinary)) {
refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
return [refactorInfo];
}

View File

@ -244,7 +244,7 @@ var ts;
// If changing the text in this section, be sure to test `configurePrerelease` too.
ts.versionMajorMinor = "3.8";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".1-rc";
ts.version = ts.versionMajorMinor + ".2";
/**
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
*/
@ -24241,17 +24241,18 @@ var ts;
}
return finishNode(node);
}
function parseNamespaceExport() {
var node = createNode(262 /* NamespaceExport */);
function parseNamespaceExport(pos) {
var node = createNode(262 /* NamespaceExport */, pos);
node.name = parseIdentifier();
return finishNode(node);
}
function parseExportDeclaration(node) {
node.kind = 260 /* ExportDeclaration */;
node.isTypeOnly = parseOptional(145 /* TypeKeyword */);
var namespaceExportPos = scanner.getStartPos();
if (parseOptional(41 /* AsteriskToken */)) {
if (parseOptional(123 /* AsKeyword */)) {
node.exportClause = parseNamespaceExport();
node.exportClause = parseNamespaceExport(namespaceExportPos);
}
parseExpected(149 /* FromKeyword */);
node.moduleSpecifier = parseModuleSpecifier();
@ -48587,7 +48588,7 @@ var ts;
// with respect to T. We do not report errors here, as we will use the existing
// error result from checking each constituent of the union.
if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */);
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
if (objectOnlyTarget.flags & 1048576 /* Union */) {
var result_4 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
if (result_4) {
@ -48678,7 +48679,7 @@ var ts;
//
// NOTE: See ~/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts
// for examples.
var sourceProperties = getPropertiesOfObjectType(source);
var sourceProperties = getPropertiesOfType(source);
var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
if (!sourcePropertiesFiltered)
return 0 /* False */;
@ -48717,7 +48718,7 @@ var ts;
var type = _a[_i];
var _loop_13 = function (i) {
var sourceProperty = sourcePropertiesFiltered[i];
var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName);
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
if (!targetProperty)
return "continue-outer";
if (sourceProperty === targetProperty)
@ -60835,7 +60836,7 @@ var ts;
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node) {
return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */);
return (ts.hasModifier(node, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedModifierFlags(n);
@ -115019,11 +115020,13 @@ var ts;
return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]);
}
var exportSpecifier = ts.getDeclarationOfKind(symbol, 263 /* ExportSpecifier */);
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) {
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
if (res_3)
return res_3;
}
}
// symbolAtLocation for a binding element is the local symbol. See if the search symbol is the property.
// Don't do this when populating search set for a rename when prefix and suffix text will be provided -- just rename the local.
@ -117631,100 +117634,112 @@ var ts;
* @param importGroup a list of ImportDeclarations, all with the same module name.
*/
function coalesceImports(importGroup) {
var _a;
if (importGroup.length === 0) {
return importGroup;
}
var _a = getCategorizedImports(importGroup), importWithoutClause = _a.importWithoutClause, defaultImports = _a.defaultImports, namespaceImports = _a.namespaceImports, namedImports = _a.namedImports;
var _b = getCategorizedImports(importGroup), importWithoutClause = _b.importWithoutClause, typeOnlyImports = _b.typeOnlyImports, regularImports = _b.regularImports;
var coalescedImports = [];
if (importWithoutClause) {
coalescedImports.push(importWithoutClause);
}
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
return coalescedImports;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _i = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _i < sortedNamespaceImports_1.length; _i++) {
var namespaceImport = sortedNamespaceImports_1[_i];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
return coalescedImports;
}
var newDefaultImport;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _b = 0, defaultImports_1 = defaultImports; _b < defaultImports_1.length; _b++) {
var defaultImport = defaultImports_1[_b];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
for (var _i = 0, _c = [regularImports, typeOnlyImports]; _i < _c.length; _i++) {
var group_2 = _c[_i];
var isTypeOnly = group_2 === typeOnlyImports;
var defaultImports = group_2.defaultImports, namespaceImports = group_2.namespaceImports, namedImports = group_2.namedImports;
// Normally, we don't combine default and namespace imports, but it would be silly to
// produce two import declarations in this special case.
if (!isTypeOnly && defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) {
// Add the namespace import to the existing default ImportDeclaration.
var defaultImport = defaultImports[0];
coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217
continue;
}
var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) {
return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name);
}); // TODO: GH#18217
for (var _d = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _d < sortedNamespaceImports_1.length; _d++) {
var namespaceImport = sortedNamespaceImports_1[_d];
// Drop the name, if any
coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217
}
if (defaultImports.length === 0 && namedImports.length === 0) {
continue;
}
var newDefaultImport = void 0;
var newImportSpecifiers = [];
if (defaultImports.length === 1) {
newDefaultImport = defaultImports[0].importClause.name;
}
else {
for (var _e = 0, defaultImports_1 = defaultImports; _e < defaultImports_1.length; _e++) {
var defaultImport = defaultImports_1[_e];
newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
// Type-only imports are not allowed to combine
if (isTypeOnly && newDefaultImport && newNamedImports) {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, /*namedBindings*/ undefined));
coalescedImports.push(updateImportDeclarationAndClause((_a = namedImports[0]) !== null && _a !== void 0 ? _a : importDecl, /*name*/ undefined, newNamedImports));
}
else {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
}
}
newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
var importDecl = defaultImports.length > 0
? defaultImports[0]
: namedImports[0];
var newNamedImports = sortedImportSpecifiers.length === 0
? newDefaultImport
? undefined
: ts.createNamedImports(ts.emptyArray)
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports));
return coalescedImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var defaultImports = [];
var namespaceImports = [];
var namedImports = [];
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
namespaceImports.push(importDeclaration);
}
else {
namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
defaultImports: defaultImports,
namespaceImports: namespaceImports,
namedImports: namedImports,
};
}
}
OrganizeImports.coalesceImports = coalesceImports;
/*
* Returns entire import declarations because they may already have been rewritten and
* may lack parent pointers. The desired parts can easily be recovered based on the
* categorization.
*
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
*/
function getCategorizedImports(importGroup) {
var importWithoutClause;
var typeOnlyImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
var regularImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
for (var _i = 0, importGroup_1 = importGroup; _i < importGroup_1.length; _i++) {
var importDeclaration = importGroup_1[_i];
if (importDeclaration.importClause === undefined) {
// Only the first such import is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
importWithoutClause = importWithoutClause || importDeclaration;
continue;
}
var group_3 = importDeclaration.importClause.isTypeOnly ? typeOnlyImports : regularImports;
var _a = importDeclaration.importClause, name = _a.name, namedBindings = _a.namedBindings;
if (name) {
group_3.defaultImports.push(importDeclaration);
}
if (namedBindings) {
if (ts.isNamespaceImport(namedBindings)) {
group_3.namespaceImports.push(importDeclaration);
}
else {
group_3.namedImports.push(importDeclaration);
}
}
}
return {
importWithoutClause: importWithoutClause,
typeOnlyImports: typeOnlyImports,
regularImports: regularImports,
};
}
// Internal for testing
/**
* @param exportGroup a list of ExportDeclarations, all with the same module name.
@ -117733,21 +117748,24 @@ var ts;
if (exportGroup.length === 0) {
return exportGroup;
}
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports;
var _a = getCategorizedExports(exportGroup), exportWithoutClause = _a.exportWithoutClause, namedExports = _a.namedExports, typeOnlyExports = _a.typeOnlyExports;
var coalescedExports = [];
if (exportWithoutClause) {
coalescedExports.push(exportWithoutClause);
}
if (namedExports.length === 0) {
return coalescedExports;
for (var _i = 0, _b = [namedExports, typeOnlyExports]; _i < _b.length; _i++) {
var exportGroup_1 = _b[_i];
if (exportGroup_1.length === 0) {
continue;
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(exportGroup_1, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = exportGroup_1[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
}
var newExportSpecifiers = [];
newExportSpecifiers.push.apply(newExportSpecifiers, ts.flatMap(namedExports, function (i) { return i.exportClause && ts.isNamedExports(i.exportClause) ? i.exportClause.elements : ts.emptyArray; }));
var sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
var exportDecl = namedExports[0];
coalescedExports.push(ts.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ?
ts.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
ts.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.isTypeOnly));
return coalescedExports;
/*
* Returns entire export declarations because they may already have been rewritten and
@ -117757,13 +117775,17 @@ var ts;
function getCategorizedExports(exportGroup) {
var exportWithoutClause;
var namedExports = [];
for (var _i = 0, exportGroup_1 = exportGroup; _i < exportGroup_1.length; _i++) {
var exportDeclaration = exportGroup_1[_i];
var typeOnlyExports = [];
for (var _i = 0, exportGroup_2 = exportGroup; _i < exportGroup_2.length; _i++) {
var exportDeclaration = exportGroup_2[_i];
if (exportDeclaration.exportClause === undefined) {
// Only the first such export is interesting - the others are redundant.
// Note: Unfortunately, we will lose trivia that was on this node.
exportWithoutClause = exportWithoutClause || exportDeclaration;
}
else if (exportDeclaration.isTypeOnly) {
typeOnlyExports.push(exportDeclaration);
}
else {
namedExports.push(exportDeclaration);
}
@ -117771,6 +117793,7 @@ var ts;
return {
exportWithoutClause: exportWithoutClause,
namedExports: namedExports,
typeOnlyExports: typeOnlyExports,
};
}
}
@ -124790,9 +124813,10 @@ var ts;
break;
}
case 254 /* ImportDeclaration */:
var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isImportDeclaration);
deleteNode(changes, sourceFile, node,
// For first import, leave header comment in place
node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
isFirstImport ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
break;
case 191 /* BindingElement */:
var pattern = node.parent;
@ -134474,7 +134498,7 @@ var ts;
var node = getNodeOrParentOfParentheses(file, startPosition);
var maybeBinary = getParentBinaryExpression(node);
var refactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
if ((ts.isBinaryExpression(maybeBinary) || ts.isStringLiteral(maybeBinary)) && isStringConcatenationValid(maybeBinary)) {
if (ts.isBinaryExpression(maybeBinary) && isStringConcatenationValid(maybeBinary)) {
refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
return [refactorInfo];
}

View File

@ -83,7 +83,7 @@ var ts;
// If changing the text in this section, be sure to test `configurePrerelease` too.
ts.versionMajorMinor = "3.8";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".1-rc";
ts.version = ts.versionMajorMinor + ".2";
/**
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
*/
@ -24080,17 +24080,18 @@ var ts;
}
return finishNode(node);
}
function parseNamespaceExport() {
var node = createNode(262 /* NamespaceExport */);
function parseNamespaceExport(pos) {
var node = createNode(262 /* NamespaceExport */, pos);
node.name = parseIdentifier();
return finishNode(node);
}
function parseExportDeclaration(node) {
node.kind = 260 /* ExportDeclaration */;
node.isTypeOnly = parseOptional(145 /* TypeKeyword */);
var namespaceExportPos = scanner.getStartPos();
if (parseOptional(41 /* AsteriskToken */)) {
if (parseOptional(123 /* AsKeyword */)) {
node.exportClause = parseNamespaceExport();
node.exportClause = parseNamespaceExport(namespaceExportPos);
}
parseExpected(149 /* FromKeyword */);
node.moduleSpecifier = parseModuleSpecifier();
@ -48426,7 +48427,7 @@ var ts;
// with respect to T. We do not report errors here, as we will use the existing
// error result from checking each constituent of the union.
if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */);
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
if (objectOnlyTarget.flags & 1048576 /* Union */) {
var result_4 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
if (result_4) {
@ -48517,7 +48518,7 @@ var ts;
//
// NOTE: See ~/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts
// for examples.
var sourceProperties = getPropertiesOfObjectType(source);
var sourceProperties = getPropertiesOfType(source);
var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
if (!sourcePropertiesFiltered)
return 0 /* False */;
@ -48556,7 +48557,7 @@ var ts;
var type = _a[_i];
var _loop_13 = function (i) {
var sourceProperty = sourcePropertiesFiltered[i];
var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName);
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
if (!targetProperty)
return "continue-outer";
if (sourceProperty === targetProperty)
@ -60674,7 +60675,7 @@ var ts;
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node) {
return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */);
return (ts.hasModifier(node, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedModifierFlags(n);