|
| 1 | +import {expectType} from 'tsd'; |
| 2 | + |
| 3 | +import test from '..'; |
| 4 | + |
| 5 | +test('actual extends expected', t => { |
| 6 | + type Expected = {foo: [1, 2, 3]}; |
| 7 | + const expected: Expected = {foo: [1, 2, 3]}; |
| 8 | + const actual = {foo: [1, 2, 3]}; |
| 9 | + if (t.deepEqual(actual, expected)) { |
| 10 | + expectType<Expected>(actual); |
| 11 | + } |
| 12 | +}); |
| 13 | + |
| 14 | +test('expected extends actual', t => { |
| 15 | + type Expected = {foo: Array<number | string>}; |
| 16 | + type Actual = {foo: number[]}; |
| 17 | + const expected: Expected = {foo: [1, 2, 3]}; |
| 18 | + const actual: Actual = {foo: [1, 2, 3]}; |
| 19 | + if (t.deepEqual(actual, expected)) { |
| 20 | + expectType<Actual>(expected); |
| 21 | + } |
| 22 | +}); |
| 23 | + |
| 24 | +test('neither extends the each other', t => { |
| 25 | + type Expected = {readonly foo: readonly [1, 2, 3]}; |
| 26 | + type Actual = {foo: number[]}; |
| 27 | + const expected: Expected = {foo: [1, 2, 3]}; |
| 28 | + const actual: Actual = {foo: [1, 2, 3]}; |
| 29 | + t.deepEqual(actual, expected); |
| 30 | +}); |
0 commit comments