Skip to content

ExpectEqual

Since 1.4.0

Expect types to be equal.

Signature

typescript
type ExpectEqual<T, Expected> = (() => T extends Expected ? Expected extends T ? true : false : false) extends () => true ? T : never

Parameters

ParameterDescription
TActual type
ExpectedExpected type

Description

Type assertion for testing type equality.

Examples

Basic Usage

typescript
import type { ExpectEqual } from 'uni-types'

type Test1 = ExpectEqual<'hello', 'hello'> // OK
type Test2 = ExpectEqual<'hello', 'world'> // Error

Released under the MIT License.