Skip to content

Commit 656fbc0

Browse files
committed
accept baseline
1 parent 23ef7b8 commit 656fbc0

12 files changed

+21
-5
lines changed

src/compiler/binder.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,14 @@ namespace ts {
388388
message = Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
389389
}
390390

391-
if (symbol.declarations && symbol.declarations.length) {
391+
let multipleDefaultExports = false;
392+
if (length(symbol.declarations)) {
392393
// If the current node is a default export of some sort, then check if
393394
// there are any other default exports that we need to error on.
394395
// We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
395396
if (isDefaultExport) {
396397
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
398+
multipleDefaultExports = true;
397399
}
398400
else {
399401
// This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration.
@@ -403,6 +405,7 @@ namespace ts {
403405
if (symbol.declarations && symbol.declarations.length &&
404406
(node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals)) {
405407
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
408+
multipleDefaultExports = true;
406409
}
407410
}
408411
}
@@ -413,7 +416,7 @@ namespace ts {
413416
const declarationName = getNameOfDeclaration(node) || node;
414417
const diag = createDiagnosticForNode(declarationName, message, getDisplayName(node))
415418
file.bindDiagnostics.push(
416-
isDefaultExport ? addRelatedInfo( diag, createDiagnosticForNode(declarationName, Diagnostics.This_export_conflicts_with_the_first)) : diag
419+
multipleDefaultExports ? addRelatedInfo(diag, createDiagnosticForNode(declarationName, Diagnostics.This_export_conflicts_with_the_first)) : diag
417420
);
418421

419422
symbol = createSymbol(SymbolFlags.None, name);

tests/baselines/reference/api/tsserverlibrary.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5432,6 +5432,7 @@ declare namespace ts {
54325432
Cannot_find_lib_definition_for_0_Did_you_mean_1: DiagnosticMessage;
54335433
_0_was_declared_here: DiagnosticMessage;
54345434
Property_0_is_used_before_its_initialization: DiagnosticMessage;
5435+
This_export_conflicts_with_the_first: DiagnosticMessage;
54355436
Import_declaration_0_is_using_private_name_1: DiagnosticMessage;
54365437
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage;
54375438
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage;
@@ -7399,6 +7400,7 @@ declare namespace ts {
73997400
type Mutable<T extends object> = {
74007401
-readonly [K in keyof T]: T[K];
74017402
};
7403+
function addRelatedInfo<T extends Diagnostic>(diagnostic: T, ...relatedInformation: DiagnosticRelatedInformation[]): T;
74027404
}
74037405
declare namespace ts {
74047406
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;

tests/baselines/reference/exportDefaultAlias_excludesEverything.errors.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ tests/cases/compiler/exportDefaultAlias_excludesEverything.ts(3,16): error TS252
1010
export default B;
1111
~
1212
!!! error TS2528: A module cannot have multiple default exports.
13+
!!! related TS2730 tests/cases/compiler/exportDefaultAlias_excludesEverything.ts:3:16: This export conflicts with the first.
1314

tests/baselines/reference/jsFileCompilationBindMultipleDefaultExports.errors.txt

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ tests/cases/compiler/a.js(3,20): error TS2652: Merged declaration 'a' cannot inc
1515
export default var a = 10;
1616

1717
!!! error TS2528: A module cannot have multiple default exports.
18+
!!! related TS2730 tests/cases/compiler/a.js:3:15: This export conflicts with the first.
1819
~~~
1920
!!! error TS1109: Expression expected.
2021
~

tests/baselines/reference/multipleDefaultExports01.errors.txt

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tests/cases/conformance/es6/modules/m1.ts(10,16): error TS2528: A module cannot
77
export default class foo {
88
~~~
99
!!! error TS2528: A module cannot have multiple default exports.
10+
!!! related TS2730 tests/cases/conformance/es6/modules/m1.ts:1:22: This export conflicts with the first.
1011

1112
}
1213

@@ -20,6 +21,7 @@ tests/cases/conformance/es6/modules/m1.ts(10,16): error TS2528: A module cannot
2021
export default x;
2122
~
2223
!!! error TS2528: A module cannot have multiple default exports.
24+
!!! related TS2730 tests/cases/conformance/es6/modules/m1.ts:10:16: This export conflicts with the first.
2325

2426
==== tests/cases/conformance/es6/modules/m2.ts (0 errors) ====
2527
import Entity from "./m1"

tests/baselines/reference/multipleDefaultExports03.errors.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ tests/cases/conformance/es6/modules/multipleDefaultExports03.ts(4,22): error TS2
1111
export default class C {
1212
~
1313
!!! error TS2528: A module cannot have multiple default exports.
14+
!!! related TS2730 tests/cases/conformance/es6/modules/multipleDefaultExports03.ts:4:22: This export conflicts with the first.
1415
}

tests/baselines/reference/multipleExportDefault1.errors.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ tests/cases/conformance/externalModules/multipleExportDefault1.ts(5,1): error TS
1616
};
1717
~~
1818
!!! error TS2528: A module cannot have multiple default exports.
19+
!!! related TS2730 tests/cases/conformance/externalModules/multipleExportDefault1.ts:5:1: This export conflicts with the first.
1920

tests/baselines/reference/multipleExportDefault2.errors.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tests/cases/conformance/externalModules/multipleExportDefault2.ts(5,25): error T
1010
};
1111
~~
1212
!!! error TS2528: A module cannot have multiple default exports.
13+
!!! related TS2730 tests/cases/conformance/externalModules/multipleExportDefault2.ts:1:1: This export conflicts with the first.
1314

1415
export default function Foo() { }
1516
~~~

tests/baselines/reference/multipleExportDefault3.errors.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ tests/cases/conformance/externalModules/multipleExportDefault3.ts(5,22): error T
1414
export default class C { }
1515
~
1616
!!! error TS2528: A module cannot have multiple default exports.
17+
!!! related TS2730 tests/cases/conformance/externalModules/multipleExportDefault3.ts:5:22: This export conflicts with the first.
1718

1819

tests/baselines/reference/multipleExportDefault4.errors.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ tests/cases/conformance/externalModules/multipleExportDefault4.ts(3,1): error TS
1313
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1414
};
1515
~~
16-
!!! error TS2528: A module cannot have multiple default exports.
16+
!!! error TS2528: A module cannot have multiple default exports.
17+
!!! related TS2730 tests/cases/conformance/externalModules/multipleExportDefault4.ts:3:1: This export conflicts with the first.

tests/baselines/reference/multipleExportDefault5.errors.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ tests/cases/conformance/externalModules/multipleExportDefault5.ts(2,22): error T
88
!!! error TS2528: A module cannot have multiple default exports.
99
export default class C {}
1010
~
11-
!!! error TS2528: A module cannot have multiple default exports.
11+
!!! error TS2528: A module cannot have multiple default exports.
12+
!!! related TS2730 tests/cases/conformance/externalModules/multipleExportDefault5.ts:2:22: This export conflicts with the first.

tests/baselines/reference/multipleExportDefault6.errors.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ tests/cases/conformance/externalModules/multipleExportDefault6.ts(5,1): error TS
1717
~~~~~~~~~~
1818
}
1919
~
20-
!!! error TS2528: A module cannot have multiple default exports.
20+
!!! error TS2528: A module cannot have multiple default exports.
21+
!!! related TS2730 tests/cases/conformance/externalModules/multipleExportDefault6.ts:5:1: This export conflicts with the first.

0 commit comments

Comments
 (0)