File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11360,12 +11360,14 @@ namespace ts {
1136011360 const errorNode: Node = (<FunctionLikeDeclaration>subsequentNode).name || subsequentNode;
1136111361 // TODO(jfreeman): These are methods, so handle computed name case
1136211362 if (node.name && (<FunctionLikeDeclaration>subsequentNode).name && (<Identifier>node.name).text === (<Identifier>(<FunctionLikeDeclaration>subsequentNode).name).text) {
11363- Debug.assert(node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature);
11363+ const reportError =
11364+ (node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) &&
11365+ (node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static);
1136411366 // we can get here in two cases
1136511367 // 1. mixed static and instance class members
1136611368 // 2. something with the same name was defined before the set of overloads that prevents them from merging
1136711369 // here we'll report error only for the first case since for second we should already report error in binder
11368- if ((node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static) ) {
11370+ if (reportError ) {
1136911371 const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
1137011372 error(errorNode, diagnostic);
1137111373 }
Original file line number Diff line number Diff line change 1+ tests/cases/compiler/nonMergedOverloads.ts(1,5): error TS2300: Duplicate identifier 'f'.
2+ tests/cases/compiler/nonMergedOverloads.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided.
3+ tests/cases/compiler/nonMergedOverloads.ts(3,17): error TS2300: Duplicate identifier 'f'.
4+ tests/cases/compiler/nonMergedOverloads.ts(4,17): error TS2300: Duplicate identifier 'f'.
5+
6+
7+ ==== tests/cases/compiler/nonMergedOverloads.ts (4 errors) ====
8+ var f = 10;
9+ ~
10+ !!! error TS2300: Duplicate identifier 'f'.
11+
12+ export function f();
13+ ~
14+ !!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
15+ ~
16+ !!! error TS2300: Duplicate identifier 'f'.
17+ export function f() {
18+ ~
19+ !!! error TS2300: Duplicate identifier 'f'.
20+ }
Original file line number Diff line number Diff line change 1+ //// [nonMergedOverloads.ts]
2+ var f = 10 ;
3+
4+ export function f ( ) ;
5+ export function f ( ) {
6+ }
7+
8+ //// [nonMergedOverloads.js]
9+ var f = 10 ;
10+ function f ( ) {
11+ }
12+ exports . f = f ;
Original file line number Diff line number Diff line change 1+ var f = 10 ;
2+
3+ export function f ( ) ;
4+ export function f ( ) {
5+ }
You can’t perform that action at this time.
0 commit comments