Adding/fixing tests
This commit is contained in:
parent
b3dd18a463
commit
d317bd1340
2 changed files with 30 additions and 5 deletions
|
@ -25,12 +25,12 @@ unionOfDifferentNumberOfSignatures(); // error - no call signatures
|
|||
unionOfDifferentNumberOfSignatures(10); // error - no call signatures
|
||||
unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
|
||||
|
||||
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
|
||||
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
|
||||
|
||||
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
|
||||
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
|
||||
strOrNum = unionWithOptionalParameter1('hello');
|
||||
strOrNum = unionWithOptionalParameter1('hello', 10);
|
||||
strOrNum = unionWithOptionalParameter1('hello', "hello"); // error in parameter type
|
||||
|
@ -43,7 +43,7 @@ strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signa
|
|||
strOrNum = unionWithOptionalParameter2(); // error no call signature
|
||||
|
||||
var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; };
|
||||
strOrNum = unionWithOptionalParameter3('hello'); // error no call signature
|
||||
strOrNum = unionWithOptionalParameter3('hello');
|
||||
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
|
||||
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
|
||||
strOrNum = unionWithOptionalParameter3(); // error no call signature
|
||||
|
@ -63,8 +63,9 @@ strOrNum = unionWithRestParameter2('hello', "hello"); // error no call signature
|
|||
strOrNum = unionWithRestParameter2(); // error no call signature
|
||||
|
||||
var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: string): number };
|
||||
strOrNum = unionWithRestParameter3('hello'); // error no call signature
|
||||
strOrNum = unionWithRestParameter3('hello');
|
||||
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
|
||||
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
|
||||
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
|
||||
strOrNum = unionWithRestParameter3(); // error no call signature
|
||||
strOrNum = unionWithRestParameter3(); // error no call signature
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
interface A {
|
||||
(x: number): number;
|
||||
(x: string, y?: string): boolean;
|
||||
(x: Date): void;
|
||||
<T>(x: T[]): T[];
|
||||
}
|
||||
|
||||
interface B {
|
||||
(x: number): number;
|
||||
(x: string): string;
|
||||
(x: Date): void;
|
||||
<T>(x: T[]): T[];
|
||||
}
|
||||
|
||||
interface C {
|
||||
(x: string, ...y: string[]): number;
|
||||
(x: number, s?: string): number;
|
||||
<T>(x: T[]): T[];
|
||||
}
|
||||
|
||||
var f: A | B | C;
|
||||
var n = f(42); // number
|
||||
var s = f("abc"); // boolean | string | number
|
||||
var a = f([true, false]); // boolean[]
|
Loading…
Reference in a new issue