Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(DeepEqualAssertion): allow Actual and Expected types not to exten…
…d each other fix #2964
- Loading branch information
1 parent
ada1a4f
commit 39bac1d
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {expectType} from 'tsd'; | ||
|
||
import test from '..'; | ||
|
||
test('actual extends expected', t => { | ||
type Expected = {foo: [1, 2, 3]}; | ||
const expected: Expected = {foo: [1, 2, 3]}; | ||
const actual = {foo: [1, 2, 3]}; | ||
if (t.deepEqual(actual, expected)) { | ||
expectType<Expected>(actual); | ||
} | ||
}); | ||
|
||
test('expected extends actual', t => { | ||
type Expected = {foo: Array<number | string>}; | ||
type Actual = {foo: number[]}; | ||
const expected: Expected = {foo: [1, 2, 3]}; | ||
const actual: Actual = {foo: [1, 2, 3]}; | ||
if (t.deepEqual(actual, expected)) { | ||
expectType<Actual>(expected); | ||
} | ||
}); | ||
|
||
test('neither extends the each other', t => { | ||
type Expected = {readonly foo: readonly [1, 2, 3]}; | ||
type Actual = {foo: number[]}; | ||
const expected: Expected = {foo: [1, 2, 3]}; | ||
const actual: Actual = {foo: [1, 2, 3]}; | ||
t.deepEqual(actual, expected); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters