UNPKG

440 BPlain TextView Raw
1// inlined from https://github.com/EskiMojo14/uncheckedindexed
2// relies on remaining as a TS file, not .d.ts
3type IfMaybeUndefined<T, True, False> = [undefined] extends [T] ? True : False
4
5const testAccess = ({} as Record<string, 0>)['a']
6
7export type IfUncheckedIndexedAccess<True, False> = IfMaybeUndefined<
8 typeof testAccess,
9 True,
10 False
11>
12
13export type UncheckedIndexedAccess<T> = IfUncheckedIndexedAccess<
14 T | undefined,
15 T
16>