Sha256: 15ab3db8aa099e50e8e6edd5719b05dd8abf2c75f56dc3895432d92ec3f6cd6b

Contents?: true

Size: 980 Bytes

Versions: 28

Compression:

Stored size: 980 Bytes

Contents

/**
Returns a boolean for whether the two given types are equal.

@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796

Use-cases:
- If you want to make a conditional branch based on the result of a comparison of two types.

@example
```
import type {IsEqual} from 'type-fest';

// This type returns a boolean for whether the given array includes the given item.
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
type Includes<Value extends readonly any[], Item> =
	Value extends readonly [Value[0], ...infer rest]
		? IsEqual<Value[0], Item> extends true
			? true
			: Includes<rest, Item>
		: false;
```

@category Type Guard
@category Utilities
*/
export type IsEqual<A, B> =
	(<G>() => G extends A ? 1 : 2) extends
	(<G>() => G extends B ? 1 : 2)
		? true
		: false;

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/type-fest/source/is-equal.d.ts