Add ArrayElement type helper

This commit is contained in:
Garrett Mills 2022-06-28 22:03:15 -05:00
parent 2e43b5bda9
commit fe9170282f
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@extollo/lib", "name": "@extollo/lib",
"version": "0.9.48", "version": "0.9.49",
"description": "The framework library that lifts up your code.", "description": "The framework library that lifts up your code.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@ -80,3 +80,6 @@ export type Integer = TypeTag<'@extollo/lib.Integer'> & number
export function isInteger(num: number): num is Integer { export function isInteger(num: number): num is Integer {
return !isNaN(num) && parseInt(String(num), 10) === num return !isNaN(num) && parseInt(String(num), 10) === num
} }
export type ArrayElement<ArrayType extends readonly unknown[]> =
ArrayType extends readonly (infer ElementType)[] ? ElementType : never;