File tree Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -11172,12 +11172,14 @@ namespace ts {
1117211172 let errorNode: Node = (<FunctionLikeDeclaration>subsequentNode).name || subsequentNode;
1117311173 // TODO(jfreeman): These are methods, so handle computed name case
1117411174 if (node.name && (<FunctionLikeDeclaration>subsequentNode).name && (<Identifier>node.name).text === (<Identifier>(<FunctionLikeDeclaration>subsequentNode).name).text) {
11175- Debug.assert(node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature);
11175+ const reportError =
11176+ (node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) &&
11177+ (node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static);
1117611178 // we can get here in two cases
1117711179 // 1. mixed static and instance class members
1117811180 // 2. something with the same name was defined before the set of overloads that prevents them from merging
1117911181 // here we'll report error only for the first case since for second we should already report error in binder
11180- if ((node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static) ) {
11182+ if (reportError ) {
1118111183 const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
1118211184 error(errorNode, diagnostic);
1118311185 }
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