diff --git a/index.d.ts b/index.d.ts index a1a8fa595..f9e18b8f7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -122,7 +122,7 @@ export interface AssertAssertion { export interface DeepEqualAssertion { /** Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to `expected`. */ - (actual: ValueType, expected: ValueType, message?: string): void; + (actual: ValueType, expected: ValueType_, message?: string): void; // See #2575 /** Skip this assertion. */ skip(actual: any, expected: any, message?: string): void; @@ -165,7 +165,7 @@ export interface IsAssertion { * Assert that `actual` is [the same * value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) as `expected`. */ - (actual: ValueType, expected: ValueType, message?: string): void; + (actual: ValueType, expected: ValueType_, message?: string): void; // See #2575 /** Skip this assertion. */ skip(actual: any, expected: any, message?: string): void; @@ -176,7 +176,7 @@ export interface NotAssertion { * Assert that `actual` is not [the same * value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) as `expected`. */ - (actual: ValueType, expected: ValueType, message?: string): void; + (actual: ValueType, expected: ValueType_, message?: string): void; // See #2575 /** Skip this assertion. */ skip(actual: any, expected: any, message?: string): void; @@ -184,7 +184,7 @@ export interface NotAssertion { export interface NotDeepEqualAssertion { /** Assert that `actual` is not [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to `expected`. */ - (actual: ValueType, expected: ValueType, message?: string): void; + (actual: ValueType, expected: ValueType_, message?: string): void; // See #2575 /** Skip this assertion. */ skip(actual: any, expected: any, message?: string): void; diff --git a/test-d/regression-2575.ts b/test-d/regression-2575.ts new file mode 100644 index 000000000..6bc9b0d15 --- /dev/null +++ b/test-d/regression-2575.ts @@ -0,0 +1,16 @@ +import {expectError} from 'tsd'; +import {IsAssertion, NotAssertion, DeepEqualAssertion, NotDeepEqualAssertion} from '..'; + +declare const is: IsAssertion; +declare const not: NotAssertion; +declare const deepEqual: DeepEqualAssertion; +declare const notDeepEqual: NotDeepEqualAssertion; + +declare const literalStringUnionValue: 'hello' | 'world'; +declare const objectWithLiteralStringUnionValue: {foo: 'hello' | 'world'}; + +// See #2575 and https://github.com/microsoft/TypeScript/issues/40377 +expectError(is(literalStringUnionValue, 'another-string')); +expectError(not(literalStringUnionValue, 'another-string')); +expectError(deepEqual(objectWithLiteralStringUnionValue, {foo: 'another-string'})); +expectError(notDeepEqual(objectWithLiteralStringUnionValue, {foo: 'another-string'}));