From e8ba3f1f8854c64eca6a9f889ba6dc12f0cc16de Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 14 Aug 2022 01:53:20 -0500 Subject: [PATCH] Add utility type for the values within a readonly array --- src/util/common.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/common.ts b/src/util/common.ts index 0e4f829..b2ac8f1 100644 --- a/src/util/common.ts +++ b/src/util/common.ts @@ -1,5 +1,9 @@ export type WithRequired = T & { [P in K]-?: T[P] }; +export type ArrayElements> = T extends ReadonlyArray + ? S + : never; + // Reference: // https://stackoverflow.com/questions/7225407/convert-camelcasetext-to-sentence-case-text export function camelToTitle(camel: string): string {