From 3ce841466d3e240ebae43e3d2fc396a36b97e560 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 3 Nov 2014 07:26:21 -0800 Subject: [PATCH] Declaration file emit for private method overloads (#1018) --- .../declFilePrivateMethodOverloads.js | 54 +++++++++++++ .../declFilePrivateMethodOverloads.types | 76 +++++++++++++++++++ .../declFilePrivateMethodOverloads.ts | 24 ++++++ 3 files changed, 154 insertions(+) create mode 100644 tests/baselines/reference/declFilePrivateMethodOverloads.js create mode 100644 tests/baselines/reference/declFilePrivateMethodOverloads.types create mode 100644 tests/cases/compiler/declFilePrivateMethodOverloads.ts diff --git a/tests/baselines/reference/declFilePrivateMethodOverloads.js b/tests/baselines/reference/declFilePrivateMethodOverloads.js new file mode 100644 index 00000000000..d6b2320b904 --- /dev/null +++ b/tests/baselines/reference/declFilePrivateMethodOverloads.js @@ -0,0 +1,54 @@ +//// [declFilePrivateMethodOverloads.ts] + +interface IContext { + someMethod(); +} +class c1 { + private _forEachBindingContext(bindingContext: IContext, fn: (bindingContext: IContext) => void); + private _forEachBindingContext(bindingContextArray: Array, fn: (bindingContext: IContext) => void); + private _forEachBindingContext(context, fn: (bindingContext: IContext) => void): void { + // Function here + } + + private overloadWithArityDifference(bindingContext: IContext); + private overloadWithArityDifference(bindingContextArray: Array, fn: (bindingContext: IContext) => void); + private overloadWithArityDifference(context): void { + // Function here + } +} +declare class c2 { + private overload1(context, fn); + + private overload2(context); + private overload2(context, fn); +} + +//// [declFilePrivateMethodOverloads.js] +var c1 = (function () { + function c1() { + } + c1.prototype._forEachBindingContext = function (context, fn) { + // Function here + }; + c1.prototype.overloadWithArityDifference = function (context) { + // Function here + }; + return c1; +})(); + + +//// [declFilePrivateMethodOverloads.d.ts] +interface IContext { + someMethod(): any; +} +declare class c1 { + private _forEachBindingContext(bindingContext, fn); + private _forEachBindingContext(bindingContextArray, fn); + private overloadWithArityDifference(bindingContext); + private overloadWithArityDifference(bindingContextArray, fn); +} +declare class c2 { + private overload1(context, fn); + private overload2(context); + private overload2(context, fn); +} diff --git a/tests/baselines/reference/declFilePrivateMethodOverloads.types b/tests/baselines/reference/declFilePrivateMethodOverloads.types new file mode 100644 index 00000000000..9989fea31f0 --- /dev/null +++ b/tests/baselines/reference/declFilePrivateMethodOverloads.types @@ -0,0 +1,76 @@ +=== tests/cases/compiler/declFilePrivateMethodOverloads.ts === + +interface IContext { +>IContext : IContext + + someMethod(); +>someMethod : () => any +} +class c1 { +>c1 : c1 + + private _forEachBindingContext(bindingContext: IContext, fn: (bindingContext: IContext) => void); +>_forEachBindingContext : { (bindingContext: IContext, fn: (bindingContext: IContext) => void): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; } +>bindingContext : IContext +>IContext : IContext +>fn : (bindingContext: IContext) => void +>bindingContext : IContext +>IContext : IContext + + private _forEachBindingContext(bindingContextArray: Array, fn: (bindingContext: IContext) => void); +>_forEachBindingContext : { (bindingContext: IContext, fn: (bindingContext: IContext) => void): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; } +>bindingContextArray : IContext[] +>Array : T[] +>IContext : IContext +>fn : (bindingContext: IContext) => void +>bindingContext : IContext +>IContext : IContext + + private _forEachBindingContext(context, fn: (bindingContext: IContext) => void): void { +>_forEachBindingContext : { (bindingContext: IContext, fn: (bindingContext: IContext) => void): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; } +>context : any +>fn : (bindingContext: IContext) => void +>bindingContext : IContext +>IContext : IContext + + // Function here + } + + private overloadWithArityDifference(bindingContext: IContext); +>overloadWithArityDifference : { (bindingContext: IContext): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; } +>bindingContext : IContext +>IContext : IContext + + private overloadWithArityDifference(bindingContextArray: Array, fn: (bindingContext: IContext) => void); +>overloadWithArityDifference : { (bindingContext: IContext): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; } +>bindingContextArray : IContext[] +>Array : T[] +>IContext : IContext +>fn : (bindingContext: IContext) => void +>bindingContext : IContext +>IContext : IContext + + private overloadWithArityDifference(context): void { +>overloadWithArityDifference : { (bindingContext: IContext): any; (bindingContextArray: IContext[], fn: (bindingContext: IContext) => void): any; } +>context : any + + // Function here + } +} +declare class c2 { +>c2 : c2 + + private overload1(context, fn); +>overload1 : (context: any, fn: any) => any +>context : any +>fn : any + + private overload2(context); +>overload2 : { (context: any): any; (context: any, fn: any): any; } +>context : any + + private overload2(context, fn); +>overload2 : { (context: any): any; (context: any, fn: any): any; } +>context : any +>fn : any +} diff --git a/tests/cases/compiler/declFilePrivateMethodOverloads.ts b/tests/cases/compiler/declFilePrivateMethodOverloads.ts new file mode 100644 index 00000000000..55bebeb9c83 --- /dev/null +++ b/tests/cases/compiler/declFilePrivateMethodOverloads.ts @@ -0,0 +1,24 @@ +// @declaration: true + +interface IContext { + someMethod(); +} +class c1 { + private _forEachBindingContext(bindingContext: IContext, fn: (bindingContext: IContext) => void); + private _forEachBindingContext(bindingContextArray: Array, fn: (bindingContext: IContext) => void); + private _forEachBindingContext(context, fn: (bindingContext: IContext) => void): void { + // Function here + } + + private overloadWithArityDifference(bindingContext: IContext); + private overloadWithArityDifference(bindingContextArray: Array, fn: (bindingContext: IContext) => void); + private overloadWithArityDifference(context): void { + // Function here + } +} +declare class c2 { + private overload1(context, fn); + + private overload2(context); + private overload2(context, fn); +} \ No newline at end of file