-
Notifications
You must be signed in to change notification settings - Fork 12.8k
/
Copy pathweakTypeIntersections1.types
106 lines (93 loc) · 3.35 KB
/
weakTypeIntersections1.types
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//// [tests/cases/compiler/weakTypeIntersections1.ts] ////
=== weakTypeIntersections1.ts ===
interface EmptyInterface {}
interface EmptyInterface2 {}
interface Foo {
a: string;
>a : string
> : ^^^^^^
}
interface Bar {
b: string;
>b : string
> : ^^^^^^
}
const m1: Partial<Foo> & ThisType<{ x: string }> = () => null; // error
>m1 : Partial<Foo> & ThisType<{ x: string; }>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^
>x : string
> : ^^^^^^
>() => null : () => null
> : ^^^^^^^^^^
const m2: Partial<Foo> = () => null; // error
>m2 : Partial<Foo>
> : ^^^^^^^^^^^^
>() => null : () => null
> : ^^^^^^^^^^
const m3: Partial<Foo> & EmptyInterface = () => null; // error
>m3 : Partial<Foo> & EmptyInterface
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>() => null : () => null
> : ^^^^^^^^^^
const m4: EmptyInterface & EmptyInterface2 = () => null; // ok
>m4 : EmptyInterface & EmptyInterface2
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>() => null : () => null
> : ^^^^^^^^^^
const m5: Partial<Foo> & Partial<Bar> = () => null; // error
>m5 : Partial<Foo> & Partial<Bar>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>() => null : () => null
> : ^^^^^^^^^^
// https://github.com/microsoft/TypeScript/issues/56995
declare function fun0(arg: () => Foo & ThisType<Foo>): void;
>fun0 : { (arg: () => Foo & ThisType<Foo>): void; (arg: Partial<Foo> & ThisType<Foo>): void; }
> : ^^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^
>arg : () => Foo & ThisType<Foo>
> : ^^^^^^
declare function fun0(arg: Partial<Foo> & ThisType<Foo>): void;
>fun0 : { (arg: () => Foo & ThisType<Foo>): void; (arg: Partial<Foo> & ThisType<Foo>): void; }
> : ^^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^
>arg : Partial<Foo> & ThisType<Foo>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fun0({ a: "1" }); // ok
>fun0({ a: "1" }) : void
> : ^^^^
>fun0 : { (arg: () => Foo & ThisType<Foo>): void; (arg: Partial<Foo> & ThisType<Foo>): void; }
> : ^^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^
>{ a: "1" } : { a: string; }
> : ^^^^^^^^^^^^^^
>a : string
> : ^^^^^^
>"1" : "1"
> : ^^^
fun0(() => ({ a: "1" })); // ok
>fun0(() => ({ a: "1" })) : void
> : ^^^^
>fun0 : { (arg: () => Foo & ThisType<Foo>): void; (arg: Partial<Foo> & ThisType<Foo>): void; }
> : ^^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^
>() => ({ a: "1" }) : () => { a: string; }
> : ^^^^^^^^^^^^^^^^^^^^
>({ a: "1" }) : { a: string; }
> : ^^^^^^^^^^^^^^
>{ a: "1" } : { a: string; }
> : ^^^^^^^^^^^^^^
>a : string
> : ^^^^^^
>"1" : "1"
> : ^^^
fun0(() => ({ a: 1 })); // error
>fun0(() => ({ a: 1 })) : void
> : ^^^^
>fun0 : { (arg: () => Foo & ThisType<Foo>): void; (arg: Partial<Foo> & ThisType<Foo>): void; }
> : ^^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^
>() => ({ a: 1 }) : () => { a: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>({ a: 1 }) : { a: number; }
> : ^^^^^^^^^^^^^^
>{ a: 1 } : { a: number; }
> : ^^^^^^^^^^^^^^
>a : number
> : ^^^^^^
>1 : 1
> : ^