Skip to content

Commit 17d7cce

Browse files
committed
Added tests with programmer provided unions
1 parent ef1b23b commit 17d7cce

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction3.ts

+6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ var r12 = foo(i2);
4141
var r15 = foo(c2);
4242

4343
declare function id2<T>(x: T, y: T): T;
44+
declare function id3<T>(x: T, y: T, z: T): T;
4445

4546
declare function boom<R>(f: (x: string, y: number) => R): R;
4647
declare function boom2(f: (x: string, y: number) => string): void;
48+
declare function boom3<R>(f: (x: string, y: number, z: R) => R): R;
4749

4850
boom(id2); // Should be an error T = [string, number]
4951
boom2(id2); // Should be an error T = [string, number]
52+
boom<string|number>(id2); // Should be OK
53+
boom3<string|number>(id3); // Should be OK
5054

5155
declare function withNum<N extends number>(x: N): N;
5256
declare function withString<S extends string>(f: (x: S) => S): void;
@@ -56,9 +60,11 @@ withString(withNum); // Error
5660
useString(withNum); // Error
5761

5862
declare function okay<R>(f: (x: 1, y: number) => R): R;
63+
declare function okay2(f: (x: string, y: number) => string|number);
5964
declare function transitive<T>(x: T, f: (x: T) => T): void;
6065

6166
okay(id2);
67+
okay2(id2);
6268

6369
transitive(1, withNum);
6470
transitive('1', withNum);

0 commit comments

Comments
 (0)