File: typeAssertionToGenericFunctionType.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (33 lines) | stat: -rw-r--r-- 993 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
=== tests/cases/compiler/typeAssertionToGenericFunctionType.ts ===
var x = {
>x : { a: <T>(x: T) => T; b: <T>(x: T) => void; }
>{    a: < <T>(x: T) => T > ((x: any) => 1),    b: <T>(x: T) => { x }} : { a: <T>(x: T) => T; b: <T>(x: T) => void; }

    a: < <T>(x: T) => T > ((x: any) => 1),
>a : <T>(x: T) => T
>< <T>(x: T) => T > ((x: any) => 1) : <T>(x: T) => T
>x : T
>((x: any) => 1) : (x: any) => number
>(x: any) => 1 : (x: any) => number
>x : any
>1 : 1

    b: <T>(x: T) => { x }
>b : <T>(x: T) => void
><T>(x: T) => { x } : <T>(x: T) => void
>x : T
>x : T
}
x.a<string>(1); // bug was that this caused 'Could not find symbol T' on return type T in the type assertion on x.a's definition
>x.a<string>(1) : any
>x.a : <T>(x: T) => T
>x : { a: <T>(x: T) => T; b: <T>(x: T) => void; }
>a : <T>(x: T) => T
>1 : 1

x.b<string>(); // error
>x.b<string>() : any
>x.b : <T>(x: T) => void
>x : { a: <T>(x: T) => T; b: <T>(x: T) => void; }
>b : <T>(x: T) => void