|
| 1 | +=== tests/cases/conformance/types/intersection/intersectionAsWeakTypeSource.ts === |
| 2 | +interface X { x: string } |
| 3 | +>X : Symbol(X, Decl(intersectionAsWeakTypeSource.ts, 0, 0)) |
| 4 | +>x : Symbol(X.x, Decl(intersectionAsWeakTypeSource.ts, 0, 13)) |
| 5 | + |
| 6 | +interface Y { y: number } |
| 7 | +>Y : Symbol(Y, Decl(intersectionAsWeakTypeSource.ts, 0, 25)) |
| 8 | +>y : Symbol(Y.y, Decl(intersectionAsWeakTypeSource.ts, 1, 13)) |
| 9 | + |
| 10 | +interface Z { z?: boolean } |
| 11 | +>Z : Symbol(Z, Decl(intersectionAsWeakTypeSource.ts, 1, 25)) |
| 12 | +>z : Symbol(Z.z, Decl(intersectionAsWeakTypeSource.ts, 2, 13)) |
| 13 | + |
| 14 | +type XY = X & Y; |
| 15 | +>XY : Symbol(XY, Decl(intersectionAsWeakTypeSource.ts, 2, 27)) |
| 16 | +>X : Symbol(X, Decl(intersectionAsWeakTypeSource.ts, 0, 0)) |
| 17 | +>Y : Symbol(Y, Decl(intersectionAsWeakTypeSource.ts, 0, 25)) |
| 18 | + |
| 19 | +const xy: XY = {x: 'x', y: 10}; |
| 20 | +>xy : Symbol(xy, Decl(intersectionAsWeakTypeSource.ts, 5, 5)) |
| 21 | +>XY : Symbol(XY, Decl(intersectionAsWeakTypeSource.ts, 2, 27)) |
| 22 | +>x : Symbol(x, Decl(intersectionAsWeakTypeSource.ts, 5, 16)) |
| 23 | +>y : Symbol(y, Decl(intersectionAsWeakTypeSource.ts, 5, 23)) |
| 24 | + |
| 25 | +const z1: Z = xy; // error, {xy} doesn't overlap with {z} |
| 26 | +>z1 : Symbol(z1, Decl(intersectionAsWeakTypeSource.ts, 7, 5)) |
| 27 | +>Z : Symbol(Z, Decl(intersectionAsWeakTypeSource.ts, 1, 25)) |
| 28 | +>xy : Symbol(xy, Decl(intersectionAsWeakTypeSource.ts, 5, 5)) |
| 29 | + |
| 30 | + |
| 31 | +interface ViewStyle { |
| 32 | +>ViewStyle : Symbol(ViewStyle, Decl(intersectionAsWeakTypeSource.ts, 7, 17)) |
| 33 | + |
| 34 | + view: number |
| 35 | +>view : Symbol(ViewStyle.view, Decl(intersectionAsWeakTypeSource.ts, 10, 21)) |
| 36 | + |
| 37 | + styleMedia: string |
| 38 | +>styleMedia : Symbol(ViewStyle.styleMedia, Decl(intersectionAsWeakTypeSource.ts, 11, 16)) |
| 39 | +} |
| 40 | +type Brand<T> = number & { __brand: T } |
| 41 | +>Brand : Symbol(Brand, Decl(intersectionAsWeakTypeSource.ts, 13, 1)) |
| 42 | +>T : Symbol(T, Decl(intersectionAsWeakTypeSource.ts, 14, 11)) |
| 43 | +>__brand : Symbol(__brand, Decl(intersectionAsWeakTypeSource.ts, 14, 26)) |
| 44 | +>T : Symbol(T, Decl(intersectionAsWeakTypeSource.ts, 14, 11)) |
| 45 | + |
| 46 | +declare function create<T extends { [s: string]: ViewStyle }>(styles: T): { [P in keyof T]: Brand<T[P]> }; |
| 47 | +>create : Symbol(create, Decl(intersectionAsWeakTypeSource.ts, 14, 39)) |
| 48 | +>T : Symbol(T, Decl(intersectionAsWeakTypeSource.ts, 15, 24)) |
| 49 | +>s : Symbol(s, Decl(intersectionAsWeakTypeSource.ts, 15, 37)) |
| 50 | +>ViewStyle : Symbol(ViewStyle, Decl(intersectionAsWeakTypeSource.ts, 7, 17)) |
| 51 | +>styles : Symbol(styles, Decl(intersectionAsWeakTypeSource.ts, 15, 62)) |
| 52 | +>T : Symbol(T, Decl(intersectionAsWeakTypeSource.ts, 15, 24)) |
| 53 | +>P : Symbol(P, Decl(intersectionAsWeakTypeSource.ts, 15, 77)) |
| 54 | +>T : Symbol(T, Decl(intersectionAsWeakTypeSource.ts, 15, 24)) |
| 55 | +>Brand : Symbol(Brand, Decl(intersectionAsWeakTypeSource.ts, 13, 1)) |
| 56 | +>T : Symbol(T, Decl(intersectionAsWeakTypeSource.ts, 15, 24)) |
| 57 | +>P : Symbol(P, Decl(intersectionAsWeakTypeSource.ts, 15, 77)) |
| 58 | + |
| 59 | +const wrapped = create({ first: { view: 0, styleMedia: "???" } }); |
| 60 | +>wrapped : Symbol(wrapped, Decl(intersectionAsWeakTypeSource.ts, 16, 5)) |
| 61 | +>create : Symbol(create, Decl(intersectionAsWeakTypeSource.ts, 14, 39)) |
| 62 | +>first : Symbol(first, Decl(intersectionAsWeakTypeSource.ts, 16, 24)) |
| 63 | +>view : Symbol(view, Decl(intersectionAsWeakTypeSource.ts, 16, 33)) |
| 64 | +>styleMedia : Symbol(styleMedia, Decl(intersectionAsWeakTypeSource.ts, 16, 42)) |
| 65 | + |
| 66 | +const vs: ViewStyle = wrapped.first // error, first is a branded number |
| 67 | +>vs : Symbol(vs, Decl(intersectionAsWeakTypeSource.ts, 17, 5)) |
| 68 | +>ViewStyle : Symbol(ViewStyle, Decl(intersectionAsWeakTypeSource.ts, 7, 17)) |
| 69 | +>wrapped.first : Symbol(first, Decl(intersectionAsWeakTypeSource.ts, 16, 24)) |
| 70 | +>wrapped : Symbol(wrapped, Decl(intersectionAsWeakTypeSource.ts, 16, 5)) |
| 71 | +>first : Symbol(first, Decl(intersectionAsWeakTypeSource.ts, 16, 24)) |
| 72 | + |
0 commit comments