File tree 4 files changed +41
-1
lines changed
4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -7096,7 +7096,20 @@ module ts {
7096
7096
function isImplementationOfOverload ( node : FunctionDeclaration ) {
7097
7097
if ( node . body ) {
7098
7098
var symbol = getSymbolOfNode ( node ) ;
7099
- return getSignaturesOfSymbol ( symbol ) . length > 1 ;
7099
+ var signaturesOfSymbol = getSignaturesOfSymbol ( symbol ) ;
7100
+ // If this function body corresponds to function with multiple signature, it is implementation of overload
7101
+ // eg: function foo(a: string): string;
7102
+ // function foo(a: number): number;
7103
+ // function foo(a: any) { // This is implementation of the overloads
7104
+ // return a;
7105
+ // }
7106
+ return signaturesOfSymbol . length > 1 ||
7107
+ // If there is single signature for the symbol, it is overload if that signature isnt coming from the node
7108
+ // eg: function foo(a: string): string;
7109
+ // function foo(a: any) { // This is implementation of the overloads
7110
+ // return a;
7111
+ // }
7112
+ ( signaturesOfSymbol . length === 1 && signaturesOfSymbol [ 0 ] . declaration !== node ) ;
7100
7113
}
7101
7114
return false ;
7102
7115
}
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ export function fooWithOverloads(a: any): any {
21
21
return a ;
22
22
}
23
23
24
+ export function fooWithSingleOverload ( a : string ) : string ;
25
+ export function fooWithSingleOverload ( a : any ) {
26
+ return a ;
27
+ }
28
+
24
29
/** This comment should appear for nonExportedFoo*/
25
30
function nonExportedFoo ( ) {
26
31
}
@@ -83,6 +88,10 @@ function fooWithOverloads(a) {
83
88
return a ;
84
89
}
85
90
exports . fooWithOverloads = fooWithOverloads ;
91
+ function fooWithSingleOverload ( a ) {
92
+ return a ;
93
+ }
94
+ exports . fooWithSingleOverload = fooWithSingleOverload ;
86
95
/** This comment should appear for nonExportedFoo*/
87
96
function nonExportedFoo ( ) {
88
97
}
@@ -134,6 +143,7 @@ export declare function fooWithParameters(/** this is comment about a*/ a: strin
134
143
export declare function fooWithRestParameters ( a : string , ...rests : string [ ] ) : string ;
135
144
export declare function fooWithOverloads ( a : string ) : string ;
136
145
export declare function fooWithOverloads ( a : number ) : number ;
146
+ export declare function fooWithSingleOverload ( a : string ) : string ;
137
147
//// [declFileFunctions_1.d.ts]
138
148
/** This comment should appear for foo*/
139
149
declare function globalfoo ( ) : void ;
Original file line number Diff line number Diff line change @@ -47,6 +47,18 @@ export function fooWithOverloads(a: any): any {
47
47
>a : any
48
48
}
49
49
50
+ export function fooWithSingleOverload(a: string): string;
51
+ >fooWithSingleOverload : (a: string) => string
52
+ >a : string
53
+
54
+ export function fooWithSingleOverload(a: any) {
55
+ >fooWithSingleOverload : (a: string) => string
56
+ >a : any
57
+
58
+ return a;
59
+ >a : any
60
+ }
61
+
50
62
/** This comment should appear for nonExportedFoo*/
51
63
function nonExportedFoo() {
52
64
>nonExportedFoo : () => void
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ export function fooWithOverloads(a: any): any {
23
23
return a ;
24
24
}
25
25
26
+ export function fooWithSingleOverload ( a : string ) : string ;
27
+ export function fooWithSingleOverload ( a : any ) {
28
+ return a ;
29
+ }
30
+
26
31
/** This comment should appear for nonExportedFoo*/
27
32
function nonExportedFoo ( ) {
28
33
}
You can’t perform that action at this time.
0 commit comments