Skip to content

Commit 380c462

Browse files
committed
feat: added IfSame utility type
1 parent 2b7e7cb commit 380c462

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/types/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export type IfUnknown<Type, T, F> = unknown extends Type ? T : F;
1010

1111
export type IfPromise<Type, T, F> = Type extends Promise<any> ? T : F;
1212

13+
export type IfSame<Left, Right, T, F> = [Left] extends [Right] ? ([Right] extends [Left] ? T : F) : F;
14+
1315
export type NotPromise<Type> = Type extends Promise<any> ? never : Type;
1416

1517
export type CanBeUndefined<Type, T, F> = Type | undefined extends Type ? T : F;

0 commit comments

Comments
 (0)