From fe9170282f7db71b20dbc3689f145051a46598ac Mon Sep 17 00:00:00 2001 From: garrettmills Date: Tue, 28 Jun 2022 22:03:15 -0500 Subject: [PATCH] Add ArrayElement type helper --- package.json | 2 +- src/util/support/types.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index db7751d..557a411 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@extollo/lib", - "version": "0.9.48", + "version": "0.9.49", "description": "The framework library that lifts up your code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/util/support/types.ts b/src/util/support/types.ts index ddb105a..37421c0 100644 --- a/src/util/support/types.ts +++ b/src/util/support/types.ts @@ -80,3 +80,6 @@ export type Integer = TypeTag<'@extollo/lib.Integer'> & number export function isInteger(num: number): num is Integer { return !isNaN(num) && parseInt(String(num), 10) === num } + +export type ArrayElement = + ArrayType extends readonly (infer ElementType)[] ? ElementType : never;