Skip to content

Commit da314a3

Browse files
committed
Merge pull request #1041 from Microsoft/declFilePrivateMethodOverload
Declaration file emit for private method overloads
2 parents 2145b2f + 3ce8414 commit da314a3

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//// [declFilePrivateMethodOverloads.ts]
2+
3+
interface IContext {
4+
someMethod();
5+
}
6+
class c1 {
7+
private _forEachBindingContext(bindingContext: IContext, fn: (bindingContext: IContext) => void);
8+
private _forEachBindingContext(bindingContextArray: Array<IContext>, fn: (bindingContext: IContext) => void);
9+
private _forEachBindingContext(context, fn: (bindingContext: IContext) => void): void {
10+
// Function here
11+
}
12+
13+
private overloadWithArityDifference(bindingContext: IContext);
14+
private overloadWithArityDifference(bindingContextArray: Array<IContext>, fn: (bindingContext: IContext) => void);
15+
private overloadWithArityDifference(context): void {
16+
// Function here
17+
}
18+
}
19+
declare class c2 {
20+
private overload1(context, fn);
21+
22+
private overload2(context);
23+
private overload2(context, fn);
24+
}
25+
26+
//// [declFilePrivateMethodOverloads.js]
27+
var c1 = (function () {
28+
function c1() {
29+
}
30+
c1.prototype._forEachBindingContext = function (context, fn) {
31+
// Function here
32+
};
33+
c1.prototype.overloadWithArityDifference = function (context) {
34+
// Function here
35+
};
36+
return c1;
37+
})();
38+
39+
40+
//// [declFilePrivateMethodOverloads.d.ts]
41+
interface IContext {
42+
someMethod(): any;
43+
}
44+
declare class c1 {
45+
private _forEachBindingContext(bindingContext, fn);
46+
private _forEachBindingContext(bindingContextArray, fn);
47+
private overloadWithArityDifference(bindingContext);
48+
private overloadWithArityDifference(bindingContextArray, fn);
49+
}
50+
declare class c2 {
51+
private overload1(context, fn);
52+
private overload2(context);
53+
private overload2(context, fn);
54+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
=== tests/cases/compiler/declFilePrivateMethodOverloads.ts ===
2+
3+
interface IContext {
4+
>IContext : IContext
5+
6+
someMethod();
7+
>someMethod : () => any
8+
}
9+
class c1 {
10+
>c1 : c1
11+
12+
private _forEachBindingContext(bindingContext: IContext, fn: (bindingContext: IContext) => void);
13+
>_forEachBindingContext : { (bindingContext: IContext, fn: (bindingContext: IContext) => void): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; }
14+
>bindingContext : IContext
15+
>IContext : IContext
16+
>fn : (bindingContext: IContext) => void
17+
>bindingContext : IContext
18+
>IContext : IContext
19+
20+
private _forEachBindingContext(bindingContextArray: Array<IContext>, fn: (bindingContext: IContext) => void);
21+
>_forEachBindingContext : { (bindingContext: IContext, fn: (bindingContext: IContext) => void): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; }
22+
>bindingContextArray : IContext[]
23+
>Array : T[]
24+
>IContext : IContext
25+
>fn : (bindingContext: IContext) => void
26+
>bindingContext : IContext
27+
>IContext : IContext
28+
29+
private _forEachBindingContext(context, fn: (bindingContext: IContext) => void): void {
30+
>_forEachBindingContext : { (bindingContext: IContext, fn: (bindingContext: IContext) => void): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; }
31+
>context : any
32+
>fn : (bindingContext: IContext) => void
33+
>bindingContext : IContext
34+
>IContext : IContext
35+
36+
// Function here
37+
}
38+
39+
private overloadWithArityDifference(bindingContext: IContext);
40+
>overloadWithArityDifference : { (bindingContext: IContext): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; }
41+
>bindingContext : IContext
42+
>IContext : IContext
43+
44+
private overloadWithArityDifference(bindingContextArray: Array<IContext>, fn: (bindingContext: IContext) => void);
45+
>overloadWithArityDifference : { (bindingContext: IContext): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; }
46+
>bindingContextArray : IContext[]
47+
>Array : T[]
48+
>IContext : IContext
49+
>fn : (bindingContext: IContext) => void
50+
>bindingContext : IContext
51+
>IContext : IContext
52+
53+
private overloadWithArityDifference(context): void {
54+
>overloadWithArityDifference : { (bindingContext: IContext): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; }
55+
>context : any
56+
57+
// Function here
58+
}
59+
}
60+
declare class c2 {
61+
>c2 : c2
62+
63+
private overload1(context, fn);
64+
>overload1 : (context: any, fn: any) => any
65+
>context : any
66+
>fn : any
67+
68+
private overload2(context);
69+
>overload2 : { (context: any): any; (context: any, fn: any): any; }
70+
>context : any
71+
72+
private overload2(context, fn);
73+
>overload2 : { (context: any): any; (context: any, fn: any): any; }
74+
>context : any
75+
>fn : any
76+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @declaration: true
2+
3+
interface IContext {
4+
someMethod();
5+
}
6+
class c1 {
7+
private _forEachBindingContext(bindingContext: IContext, fn: (bindingContext: IContext) => void);
8+
private _forEachBindingContext(bindingContextArray: Array<IContext>, fn: (bindingContext: IContext) => void);
9+
private _forEachBindingContext(context, fn: (bindingContext: IContext) => void): void {
10+
// Function here
11+
}
12+
13+
private overloadWithArityDifference(bindingContext: IContext);
14+
private overloadWithArityDifference(bindingContextArray: Array<IContext>, fn: (bindingContext: IContext) => void);
15+
private overloadWithArityDifference(context): void {
16+
// Function here
17+
}
18+
}
19+
declare class c2 {
20+
private overload1(context, fn);
21+
22+
private overload2(context);
23+
private overload2(context, fn);
24+
}

0 commit comments

Comments
 (0)