uncheckedindexed.ts 440 B

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