forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonTypeIntersection.types
More file actions
35 lines (30 loc) · 1.44 KB
/
commonTypeIntersection.types
File metadata and controls
35 lines (30 loc) · 1.44 KB
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
//// [tests/cases/conformance/types/intersection/commonTypeIntersection.ts] ////
=== commonTypeIntersection.ts ===
declare let x1: { __typename?: 'TypeTwo' } & { a: boolean };
>x1 : { __typename?: "TypeTwo" | undefined; } & { a: boolean; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^
>__typename : "TypeTwo" | undefined
> : ^^^^^^^^^^^^^^^^^^^^^
>a : boolean
> : ^^^^^^^
let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // should error here
>y1 : { __typename?: "TypeOne" | undefined; } & { a: boolean; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^
>__typename : "TypeOne" | undefined
> : ^^^^^^^^^^^^^^^^^^^^^
>a : boolean
> : ^^^^^^^
>x1 : { __typename?: "TypeTwo" | undefined; } & { a: boolean; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^
declare let x2: { __typename?: 'TypeTwo' } & string;
>x2 : { __typename?: "TypeTwo" | undefined; } & string
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>__typename : "TypeTwo" | undefined
> : ^^^^^^^^^^^^^^^^^^^^^
let y2: { __typename?: 'TypeOne' } & string = x2; // should error here
>y2 : { __typename?: "TypeOne" | undefined; } & string
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>__typename : "TypeOne" | undefined
> : ^^^^^^^^^^^^^^^^^^^^^
>x2 : { __typename?: "TypeTwo" | undefined; } & string
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^