add tests for the issue

This commit is contained in:
erictsangx
2015-11-26 18:33:56 +08:00
parent f6454326dd
commit bc2b105037
3 changed files with 20 additions and 9 deletions
@@ -16,9 +16,9 @@ unionOfDifferentReturnType1(true); // error in type of parameter
unionOfDifferentReturnType1(); // error missing parameter
var unionOfDifferentParameterTypes: { (a: number): number; } | { (a: string): Date; };
unionOfDifferentParameterTypes(10);// error - no call signatures
unionOfDifferentParameterTypes("hello");// error - no call signatures
unionOfDifferentParameterTypes();// error - no call signatures
unionOfDifferentParameterTypes(10); //no error
unionOfDifferentParameterTypes("hello"); //no error
unionOfDifferentParameterTypes(); //error TS2346
var unionOfDifferentNumberOfSignatures: { (a: number): number; } | { (a: number): Date; (a: string): boolean; };
unionOfDifferentNumberOfSignatures(); // error - no call signatures
@@ -26,9 +26,9 @@ unionOfDifferentNumberOfSignatures(10); // error - no call signatures
unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
unionWithDifferentParameterCount();// no call signature
unionWithDifferentParameterCount("hello");// no call signature
unionWithDifferentParameterCount("hello", 10);// no call signature
unionWithDifferentParameterCount(); //error TS2346
unionWithDifferentParameterCount("hello"); //no error
unionWithDifferentParameterCount("hello", 10); //no error
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
strOrNum = unionWithOptionalParameter1('hello');
@@ -71,4 +71,4 @@ strOrNum = unionWithRestParameter3(); // error no call signature
var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; };
strOrNum = unionWithRestParameter4("hello"); // error supplied parameters do not match any call signature
strOrNum = unionWithRestParameter4("hello", "world");
strOrNum = unionWithRestParameter4("hello", "world");
@@ -0,0 +1,12 @@
interface A {
(number) : number;
}
var f1: string | number;
f1(); //error TS2658
var f2: string | A;
f2(); //error TS2658
var f3: string[] | number[];
f3.map(value=>value); //should not throw TS2349
@@ -41,8 +41,7 @@ str = x.commonMethodType(str); // (a: string) => string so result should be stri
strOrNum = x.commonPropertyDifferenType;
strOrNum = x.commonMethodDifferentReturnType(str); // string | union
x.commonMethodDifferentParameterType; // No error - property exists
x.commonMethodDifferentParameterType(strOrNum); // error - no call signatures because the type of this property is ((a: string) => string) | (a: number) => number
// and the call signatures arent identical
x.commonMethodDifferentParameterType(strOrNum); //error - TS2345
num = x.commonMethodWithTypeParameter(num);
num = x.commonMethodWithOwnTypeParameter(num);
str = x.commonMethodWithOwnTypeParameter(str);