File: contextualSignatureInstantiation4.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (67 lines) | stat: -rw-r--r-- 2,684 bytes parent folder | download | duplicates (4)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
=== tests/cases/compiler/contextualSignatureInstantiation4.ts ===
// Repros from #32976

declare class Banana<T extends string> { constructor(a: string, property: T) }
>Banana : Banana<T>
>a : string
>property : T

declare function fruitFactory1<TFruit>(Fruit: new (...args: any[]) => TFruit): TFruit
>fruitFactory1 : <TFruit>(Fruit: new (...args: any[]) => TFruit) => TFruit
>Fruit : new (...args: any[]) => TFruit
>args : any[]

const banana1 = fruitFactory1(Banana) // Banana<any>
>banana1 : Banana<any>
>fruitFactory1(Banana) : Banana<any>
>fruitFactory1 : <TFruit>(Fruit: new (...args: any[]) => TFruit) => TFruit
>Banana : typeof Banana

declare function fruitFactory2<TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit): TFruit
>fruitFactory2 : <TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit) => TFruit
>Fruit : new (a: string, ...args: any[]) => TFruit
>a : string
>args : any[]

const banana2 = fruitFactory2(Banana) // Banana<any>
>banana2 : Banana<any>
>fruitFactory2(Banana) : Banana<any>
>fruitFactory2 : <TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit) => TFruit
>Banana : typeof Banana

declare function fruitFactory3<TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit): TFruit
>fruitFactory3 : <TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit) => TFruit
>Fruit : new (a: string, s: "foo", ...args: any[]) => TFruit
>a : string
>s : "foo"
>args : any[]

const banana3 = fruitFactory3(Banana) // Banana<"foo">
>banana3 : Banana<"foo">
>fruitFactory3(Banana) : Banana<"foo">
>fruitFactory3 : <TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit) => TFruit
>Banana : typeof Banana

declare function fruitFactory4<TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit): TFruit
>fruitFactory4 : <TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit) => TFruit
>Fruit : new (a: string, ...args: "foo"[]) => TFruit
>a : string
>args : "foo"[]

const banana4 = fruitFactory4(Banana) // Banana<"foo">
>banana4 : Banana<"foo">
>fruitFactory4(Banana) : Banana<"foo">
>fruitFactory4 : <TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit) => TFruit
>Banana : typeof Banana

declare function fruitFactory5<TFruit>(Fruit: new (...args: "foo"[]) => TFruit): TFruit
>fruitFactory5 : <TFruit>(Fruit: new (...args: "foo"[]) => TFruit) => TFruit
>Fruit : new (...args: "foo"[]) => TFruit
>args : "foo"[]

const banana5 = fruitFactory5(Banana) // Banana<"foo">
>banana5 : Banana<"foo">
>fruitFactory5(Banana) : Banana<"foo">
>fruitFactory5 : <TFruit>(Fruit: new (...args: "foo"[]) => TFruit) => TFruit
>Banana : typeof Banana