File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -7096,7 +7096,20 @@ module ts {
70967096 function isImplementationOfOverload ( node : FunctionDeclaration ) {
70977097 if ( node . body ) {
70987098 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 ) ;
71007113 }
71017114 return false ;
71027115 }
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ export function fooWithOverloads(a: any): any {
2121 return a ;
2222}
2323
24+ export function fooWithSingleOverload ( a : string ) : string ;
25+ export function fooWithSingleOverload ( a : any ) {
26+ return a ;
27+ }
28+
2429/** This comment should appear for nonExportedFoo*/
2530function nonExportedFoo ( ) {
2631}
@@ -83,6 +88,10 @@ function fooWithOverloads(a) {
8388 return a ;
8489}
8590exports . fooWithOverloads = fooWithOverloads ;
91+ function fooWithSingleOverload ( a ) {
92+ return a ;
93+ }
94+ exports . fooWithSingleOverload = fooWithSingleOverload ;
8695/** This comment should appear for nonExportedFoo*/
8796function nonExportedFoo ( ) {
8897}
@@ -134,6 +143,7 @@ export declare function fooWithParameters(/** this is comment about a*/ a: strin
134143export declare function fooWithRestParameters ( a : string , ...rests : string [ ] ) : string ;
135144export declare function fooWithOverloads ( a : string ) : string ;
136145export declare function fooWithOverloads ( a : number ) : number ;
146+ export declare function fooWithSingleOverload ( a : string ) : string ;
137147//// [declFileFunctions_1.d.ts]
138148/** This comment should appear for foo*/
139149declare function globalfoo ( ) : void ;
Original file line number Diff line number Diff line change @@ -47,6 +47,18 @@ export function fooWithOverloads(a: any): any {
4747>a : any
4848}
4949
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+
5062/** This comment should appear for nonExportedFoo*/
5163function nonExportedFoo() {
5264>nonExportedFoo : () => void
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ export function fooWithOverloads(a: any): any {
2323 return a ;
2424}
2525
26+ export function fooWithSingleOverload ( a : string ) : string ;
27+ export function fooWithSingleOverload ( a : any ) {
28+ return a ;
29+ }
30+
2631/** This comment should appear for nonExportedFoo*/
2732function nonExportedFoo ( ) {
2833}
You can’t perform that action at this time.
0 commit comments