Skip to content

Instantly share code, notes, and snippets.

View vishnuroshan's full-sized avatar
:shipit:
maybe the bug is actually a feature

Vishnu Roshan vishnuroshan

:shipit:
maybe the bug is actually a feature
View GitHub Profile
@vishnuroshan
vishnuroshan / types.ts
Created August 11, 2023 10:40 — forked from ClickerMonkey/types.ts
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]