mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 09:24:19 -06:00
Do not emit the signature for implementation of overload in the declaration file
This commit is contained in:
parent
d1cdf03d53
commit
455364cf5a
@ -5722,6 +5722,14 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isImplementationOfOverload(node: FunctionDeclaration) {
|
||||
if (node.body) {
|
||||
var symbol = getSymbolOfNode(node);
|
||||
return getSignaturesOfSymbol(symbol).length > 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getNodeCheckFlags(node: Node): NodeCheckFlags {
|
||||
return getNodeLinks(node).flags;
|
||||
}
|
||||
@ -5742,7 +5750,8 @@ module ts {
|
||||
getEnumMemberValue: getEnumMemberValue,
|
||||
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
|
||||
shouldEmitDeclarations: shouldEmitDeclarations,
|
||||
isReferencedInExportAssignment: isReferencedInExportAssignment
|
||||
isReferencedInExportAssignment: isReferencedInExportAssignment,
|
||||
isImplementationOfOverload: isImplementationOfOverload
|
||||
};
|
||||
checkProgram();
|
||||
return emitFiles(resolver);
|
||||
|
||||
@ -2125,9 +2125,9 @@ module ts {
|
||||
}
|
||||
|
||||
function emitFunctionDeclaration(node: FunctionDeclaration) {
|
||||
// TODO(shkamat): if this is overloaded declaration do not emit if body is present
|
||||
// If we are emitting Method/Constructor it isnt moduleElement and doesnt need canEmitModuleElement check
|
||||
if (node.kind !== SyntaxKind.FunctionDeclaration || canEmitModuleElementDeclaration(node)) {
|
||||
if ((node.kind !== SyntaxKind.FunctionDeclaration || canEmitModuleElementDeclaration(node)) &&
|
||||
!resolver.isImplementationOfOverload(node)) {
|
||||
emitDeclarationFlags(node);
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
write("function ");
|
||||
|
||||
@ -602,6 +602,7 @@ module ts {
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
shouldEmitDeclarations(): boolean;
|
||||
isReferencedInExportAssignment(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionDeclaration): boolean;
|
||||
}
|
||||
|
||||
export enum SymbolFlags {
|
||||
|
||||
@ -242,7 +242,6 @@ declare function sum(a, b);
|
||||
declare function multiply(a, b, c?, d?, e?);
|
||||
declare function f1(a);
|
||||
declare function f1(b);
|
||||
declare function f1(aOrb, opt?);
|
||||
declare function subtract(a, b, c?, d?, e?, f?);
|
||||
declare function square(a);
|
||||
declare function divide(a, b);
|
||||
|
||||
@ -259,16 +259,12 @@ var c5_i_2 = new c5("hello");
|
||||
//// [commentsOverloads.d.ts]
|
||||
declare function f1(a);
|
||||
declare function f1(b);
|
||||
declare function f1(aOrb);
|
||||
declare function f2(a);
|
||||
declare function f2(b);
|
||||
declare function f2(aOrb);
|
||||
declare function f3(a);
|
||||
declare function f3(b);
|
||||
declare function f3(aOrb);
|
||||
declare function f4(a);
|
||||
declare function f4(b);
|
||||
declare function f4(aOrb);
|
||||
interface i1 {
|
||||
(a);
|
||||
(b);
|
||||
@ -310,44 +306,34 @@ interface i4 {
|
||||
declare class c {
|
||||
prop1(a);
|
||||
prop1(b);
|
||||
prop1(aorb);
|
||||
prop2(a);
|
||||
prop2(b);
|
||||
prop2(aorb);
|
||||
prop3(a);
|
||||
prop3(b);
|
||||
prop3(aorb);
|
||||
prop4(a);
|
||||
prop4(b);
|
||||
prop4(aorb);
|
||||
prop5(a);
|
||||
prop5(b);
|
||||
prop5(aorb);
|
||||
}
|
||||
declare class c1 {
|
||||
constructor (a);
|
||||
constructor (b);
|
||||
constructor (aorb);
|
||||
}
|
||||
declare class c2 {
|
||||
constructor (a);
|
||||
constructor (b);
|
||||
constructor (aorb);
|
||||
}
|
||||
declare class c3 {
|
||||
constructor (a);
|
||||
constructor (b);
|
||||
constructor (aorb);
|
||||
}
|
||||
declare class c4 {
|
||||
constructor (a);
|
||||
constructor (b);
|
||||
constructor (aorb);
|
||||
}
|
||||
declare class c5 {
|
||||
constructor (a);
|
||||
constructor (b);
|
||||
constructor (aorb);
|
||||
}
|
||||
declare var c_i;
|
||||
declare var c1_i_1;
|
||||
|
||||
@ -142,7 +142,6 @@ declare class c {
|
||||
prop1;
|
||||
foo1(a);
|
||||
foo1(b);
|
||||
foo1(aOrb);
|
||||
}
|
||||
declare var i;
|
||||
interface i1 {
|
||||
|
||||
@ -142,7 +142,6 @@ declare class c {
|
||||
prop1;
|
||||
foo1(a);
|
||||
foo1(b);
|
||||
foo1(aOrb);
|
||||
}
|
||||
declare var i;
|
||||
interface i1 {
|
||||
|
||||
@ -224,7 +224,6 @@ export declare class ConstructorWithRestParamters {
|
||||
export declare class ConstructorWithOverloads {
|
||||
constructor (a);
|
||||
constructor (a);
|
||||
constructor (a);
|
||||
}
|
||||
export declare class ConstructorWithPublicParameterProperty {
|
||||
x;
|
||||
@ -255,7 +254,6 @@ declare class GlobalConstructorWithRestParamters {
|
||||
declare class GlobalConstructorWithOverloads {
|
||||
constructor (a);
|
||||
constructor (a);
|
||||
constructor (a);
|
||||
}
|
||||
declare class GlobalConstructorWithPublicParameterProperty {
|
||||
x;
|
||||
|
||||
@ -20,5 +20,4 @@ var C = (function () {
|
||||
declare class C {
|
||||
private foo(x);
|
||||
private foo(x);
|
||||
private foo(x);
|
||||
}
|
||||
|
||||
@ -118,11 +118,9 @@ export declare function fooWithParameters(a, b);
|
||||
export declare function fooWithRestParameters(a, ...rests);
|
||||
export declare function fooWithOverloads(a);
|
||||
export declare function fooWithOverloads(a);
|
||||
export declare function fooWithOverloads(a);
|
||||
//// [declFileFunctions_1.d.ts]
|
||||
declare function globalfoo();
|
||||
declare function globalfooWithParameters(a, b);
|
||||
declare function globalfooWithRestParameters(a, ...rests);
|
||||
declare function globalfooWithOverloads(a);
|
||||
declare function globalfooWithOverloads(a);
|
||||
declare function globalfooWithOverloads(a);
|
||||
|
||||
@ -332,25 +332,21 @@ export declare class c1 {
|
||||
fooWithRestParameters(a, ...rests);
|
||||
fooWithOverloads(a);
|
||||
fooWithOverloads(a);
|
||||
fooWithOverloads(a);
|
||||
private privateFoo();
|
||||
private privateFooWithParameters(a, b);
|
||||
private privateFooWithRestParameters(a, ...rests);
|
||||
private privateFooWithOverloads(a);
|
||||
private privateFooWithOverloads(a);
|
||||
private privateFooWithOverloads(a);
|
||||
static staticFoo();
|
||||
static staticFooWithParameters(a, b);
|
||||
static staticFooWithRestParameters(a, ...rests);
|
||||
static staticFooWithOverloads(a);
|
||||
static staticFooWithOverloads(a);
|
||||
static staticFooWithOverloads(a);
|
||||
private static privateStaticFoo();
|
||||
private static privateStaticFooWithParameters(a, b);
|
||||
private static privateStaticFooWithRestParameters(a, ...rests);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
}
|
||||
export interface I1 {
|
||||
foo();
|
||||
@ -366,25 +362,21 @@ declare class c2 {
|
||||
fooWithRestParameters(a, ...rests);
|
||||
fooWithOverloads(a);
|
||||
fooWithOverloads(a);
|
||||
fooWithOverloads(a);
|
||||
private privateFoo();
|
||||
private privateFooWithParameters(a, b);
|
||||
private privateFooWithRestParameters(a, ...rests);
|
||||
private privateFooWithOverloads(a);
|
||||
private privateFooWithOverloads(a);
|
||||
private privateFooWithOverloads(a);
|
||||
static staticFoo();
|
||||
static staticFooWithParameters(a, b);
|
||||
static staticFooWithRestParameters(a, ...rests);
|
||||
static staticFooWithOverloads(a);
|
||||
static staticFooWithOverloads(a);
|
||||
static staticFooWithOverloads(a);
|
||||
private static privateStaticFoo();
|
||||
private static privateStaticFooWithParameters(a, b);
|
||||
private static privateStaticFooWithRestParameters(a, ...rests);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
}
|
||||
interface I2 {
|
||||
foo();
|
||||
|
||||
@ -66,10 +66,8 @@ function foo5(x) {
|
||||
//// [declFileTypeofFunction.d.ts]
|
||||
declare function f(n);
|
||||
declare function f(n);
|
||||
declare function f();
|
||||
declare function g(n);
|
||||
declare function g(n);
|
||||
declare function g();
|
||||
declare var b;
|
||||
declare function b1();
|
||||
declare function foo();
|
||||
|
||||
@ -153,7 +153,6 @@ declare function withRestParams(a, ...myRestParameter);
|
||||
declare var withRestParamsVar;
|
||||
declare function overload1(n);
|
||||
declare function overload1(s);
|
||||
declare function overload1(ns);
|
||||
declare var withOverloadSignature;
|
||||
declare function f(n);
|
||||
declare module m2 {
|
||||
|
||||
@ -20,5 +20,4 @@ var C = (function () {
|
||||
declare class C {
|
||||
foo(n);
|
||||
foo(s);
|
||||
foo(a);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user