245 lines
8.7 KiB
Plaintext
245 lines
8.7 KiB
Plaintext
|
=== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/functionLiterals.ts ===
|
||
|
// PropName<TypeParamList>(ParamList):ReturnType is equivalent to PropName: { <TypeParamList>(ParamList): ReturnType }
|
||
|
|
||
|
var b: {
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
|
||
|
func1(x: number): number; // Method signature
|
||
|
>func1 : (x: number) => number
|
||
|
>x : number
|
||
|
|
||
|
func2: (x: number) => number; // Function type literal
|
||
|
>func2 : (x: number) => number
|
||
|
>x : number
|
||
|
|
||
|
func3: { (x: number): number }; // Object type literal
|
||
|
>func3 : (x: number) => number
|
||
|
>x : number
|
||
|
}
|
||
|
|
||
|
// no errors
|
||
|
b.func1 = b.func2;
|
||
|
>b.func1 = b.func2 : (x: number) => number
|
||
|
>b.func1 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func1 : (x: number) => number
|
||
|
>b.func2 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func2 : (x: number) => number
|
||
|
|
||
|
b.func1 = b.func3;
|
||
|
>b.func1 = b.func3 : (x: number) => number
|
||
|
>b.func1 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func1 : (x: number) => number
|
||
|
>b.func3 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func3 : (x: number) => number
|
||
|
|
||
|
b.func2 = b.func1;
|
||
|
>b.func2 = b.func1 : (x: number) => number
|
||
|
>b.func2 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func2 : (x: number) => number
|
||
|
>b.func1 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func1 : (x: number) => number
|
||
|
|
||
|
b.func2 = b.func3;
|
||
|
>b.func2 = b.func3 : (x: number) => number
|
||
|
>b.func2 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func2 : (x: number) => number
|
||
|
>b.func3 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func3 : (x: number) => number
|
||
|
|
||
|
b.func3 = b.func1;
|
||
|
>b.func3 = b.func1 : (x: number) => number
|
||
|
>b.func3 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func3 : (x: number) => number
|
||
|
>b.func1 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func1 : (x: number) => number
|
||
|
|
||
|
b.func3 = b.func2;
|
||
|
>b.func3 = b.func2 : (x: number) => number
|
||
|
>b.func3 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func3 : (x: number) => number
|
||
|
>b.func2 : (x: number) => number
|
||
|
>b : { func1(x: number): number; func2: (x: number) => number; func3: (x: number) => number; }
|
||
|
>func2 : (x: number) => number
|
||
|
|
||
|
var c: {
|
||
|
>c : { func4(x: number): number; func4(s: string): string; func5: { (x: number): number; (s: string): string; }; }
|
||
|
|
||
|
func4(x: number): number;
|
||
|
>func4 : { (x: number): number; (s: string): string; }
|
||
|
>x : number
|
||
|
|
||
|
func4(s: string): string;
|
||
|
>func4 : { (x: number): number; (s: string): string; }
|
||
|
>s : string
|
||
|
|
||
|
func5: {
|
||
|
>func5 : { (x: number): number; (s: string): string; }
|
||
|
|
||
|
(x: number): number;
|
||
|
>x : number
|
||
|
|
||
|
(s: string): string;
|
||
|
>s : string
|
||
|
|
||
|
};
|
||
|
};
|
||
|
|
||
|
// no errors
|
||
|
c.func4 = c.func5;
|
||
|
>c.func4 = c.func5 : { (x: number): number; (s: string): string; }
|
||
|
>c.func4 : { (x: number): number; (s: string): string; }
|
||
|
>c : { func4(x: number): number; func4(s: string): string; func5: { (x: number): number; (s: string): string; }; }
|
||
|
>func4 : { (x: number): number; (s: string): string; }
|
||
|
>c.func5 : { (x: number): number; (s: string): string; }
|
||
|
>c : { func4(x: number): number; func4(s: string): string; func5: { (x: number): number; (s: string): string; }; }
|
||
|
>func5 : { (x: number): number; (s: string): string; }
|
||
|
|
||
|
c.func5 = c.func4;
|
||
|
>c.func5 = c.func4 : { (x: number): number; (s: string): string; }
|
||
|
>c.func5 : { (x: number): number; (s: string): string; }
|
||
|
>c : { func4(x: number): number; func4(s: string): string; func5: { (x: number): number; (s: string): string; }; }
|
||
|
>func5 : { (x: number): number; (s: string): string; }
|
||
|
>c.func4 : { (x: number): number; (s: string): string; }
|
||
|
>c : { func4(x: number): number; func4(s: string): string; func5: { (x: number): number; (s: string): string; }; }
|
||
|
>func4 : { (x: number): number; (s: string): string; }
|
||
|
|
||
|
// generic versions
|
||
|
var b2: {
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
|
||
|
func1<T>(x: T): number; // Method signature
|
||
|
>func1 : <T>(x: T) => number
|
||
|
>T : T
|
||
|
>x : T
|
||
|
>T : T
|
||
|
|
||
|
func2: <T>(x: T) => number; // Function type literal
|
||
|
>func2 : <T>(x: T) => number
|
||
|
>T : T
|
||
|
>x : T
|
||
|
>T : T
|
||
|
|
||
|
func3: { <T>(x: T): number }; // Object type literal
|
||
|
>func3 : <T>(x: T) => number
|
||
|
>T : T
|
||
|
>x : T
|
||
|
>T : T
|
||
|
}
|
||
|
|
||
|
// no errors
|
||
|
b2.func1 = b2.func2;
|
||
|
>b2.func1 = b2.func2 : <T>(x: T) => number
|
||
|
>b2.func1 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func1 : <T>(x: T) => number
|
||
|
>b2.func2 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func2 : <T>(x: T) => number
|
||
|
|
||
|
b2.func1 = b2.func3;
|
||
|
>b2.func1 = b2.func3 : <T>(x: T) => number
|
||
|
>b2.func1 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func1 : <T>(x: T) => number
|
||
|
>b2.func3 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func3 : <T>(x: T) => number
|
||
|
|
||
|
b2.func2 = b2.func1;
|
||
|
>b2.func2 = b2.func1 : <T>(x: T) => number
|
||
|
>b2.func2 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func2 : <T>(x: T) => number
|
||
|
>b2.func1 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func1 : <T>(x: T) => number
|
||
|
|
||
|
b2.func2 = b2.func3;
|
||
|
>b2.func2 = b2.func3 : <T>(x: T) => number
|
||
|
>b2.func2 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func2 : <T>(x: T) => number
|
||
|
>b2.func3 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func3 : <T>(x: T) => number
|
||
|
|
||
|
b2.func3 = b2.func1;
|
||
|
>b2.func3 = b2.func1 : <T>(x: T) => number
|
||
|
>b2.func3 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func3 : <T>(x: T) => number
|
||
|
>b2.func1 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func1 : <T>(x: T) => number
|
||
|
|
||
|
b2.func3 = b2.func2;
|
||
|
>b2.func3 = b2.func2 : <T>(x: T) => number
|
||
|
>b2.func3 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func3 : <T>(x: T) => number
|
||
|
>b2.func2 : <T>(x: T) => number
|
||
|
>b2 : { func1<T>(x: T): number; func2: <T>(x: T) => number; func3: <T>(x: T) => number; }
|
||
|
>func2 : <T>(x: T) => number
|
||
|
|
||
|
var c2: {
|
||
|
>c2 : { func4<T>(x: T): number; func4<T>(s: T): string; func5: { <T>(x: T): number; <T>(s: T): string; }; }
|
||
|
|
||
|
func4<T>(x: T): number;
|
||
|
>func4 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>T : T
|
||
|
>x : T
|
||
|
>T : T
|
||
|
|
||
|
func4<T>(s: T): string;
|
||
|
>func4 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>T : T
|
||
|
>s : T
|
||
|
>T : T
|
||
|
|
||
|
func5: {
|
||
|
>func5 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
|
||
|
<T>(x: T): number;
|
||
|
>T : T
|
||
|
>x : T
|
||
|
>T : T
|
||
|
|
||
|
<T>(s: T): string;
|
||
|
>T : T
|
||
|
>s : T
|
||
|
>T : T
|
||
|
|
||
|
};
|
||
|
};
|
||
|
|
||
|
// no errors
|
||
|
c2.func4 = c2.func5;
|
||
|
>c2.func4 = c2.func5 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2.func4 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2 : { func4<T>(x: T): number; func4<T>(s: T): string; func5: { <T>(x: T): number; <T>(s: T): string; }; }
|
||
|
>func4 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2.func5 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2 : { func4<T>(x: T): number; func4<T>(s: T): string; func5: { <T>(x: T): number; <T>(s: T): string; }; }
|
||
|
>func5 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
|
||
|
c2.func5 = c2.func4;
|
||
|
>c2.func5 = c2.func4 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2.func5 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2 : { func4<T>(x: T): number; func4<T>(s: T): string; func5: { <T>(x: T): number; <T>(s: T): string; }; }
|
||
|
>func5 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2.func4 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
>c2 : { func4<T>(x: T): number; func4<T>(s: T): string; func5: { <T>(x: T): number; <T>(s: T): string; }; }
|
||
|
>func4 : { <T>(x: T): number; <T>(s: T): string; }
|
||
|
|