()
| 46 | } |
| 47 | |
| 48 | function testObjects() { |
| 49 | type ABC = { a: number; b: number; c: number }; |
| 50 | type BC = { b: number; c: number }; |
| 51 | type BC2 = { b: number; c: string }; |
| 52 | type C = { c: number }; |
| 53 | |
| 54 | let abc: ABC = { a: 1, b: 2, c: 3 }; |
| 55 | let abc2 = { a: 1, b: 2, c: 3 } as const; |
| 56 | let bc: BC = { b: 2, c: 3 }; |
| 57 | let bc2: BC2 = { b: 2, c: "3" }; |
| 58 | let bc3 = { b: 2, c: 3 } as const; |
| 59 | let bc4 = { b: 2, c: "3" } as const; |
| 60 | let c: C = { c: 3 }; |
| 61 | let c2 = { c: 3 } as const; |
| 62 | |
| 63 | const isBC = isExact<BC>(); |
| 64 | |
| 65 | // @ts-expect-error has different structure from BC (excessive property a) |
| 66 | isBC(abc); |
| 67 | // @ts-expect-error has different structure from BC (excessive property a) |
| 68 | isBC(abc2); |
| 69 | |
| 70 | // has the same structure as BC |
| 71 | isBC(bc); |
| 72 | // @ts-expect-error has different structure from BC (c has different type) |
| 73 | isBC(bc2); |
| 74 | // @ts-expect-error: has different structure from BC (b and c have different types) |
| 75 | isBC(bc3); |
| 76 | // @ts-expect-error has different structure from BC (c has different type) |
| 77 | isBC(bc4); |
| 78 | |
| 79 | // @ts-expect-error has different structure from BC (missing property b) |
| 80 | isBC(c); |
| 81 | // @ts-expect-error has different structure from BC (missing property b) |
| 82 | isBC(c2); |
| 83 | } |
| 84 | |
| 85 | function testObjectUnionType() { |
| 86 | type ABC = { a: number; b: number; c: number }; |
nothing calls this directly
no test coverage detected
searching dependent graphs…