Skip to content

IsCompatible

Since 1.4.0

Check type compatibility.

Signature

typescript
type IsCompatible<T, U> = T extends U ? true : false

Parameters

ParameterDescription
TFirst type
USecond type to check against

Description

Checks if type T is compatible with type U.

Examples

Basic Usage

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

type Check1 = IsCompatible<string, string | number>
// true

type Check2 = IsCompatible<string, number>
// false

Released under the MIT License.