Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/actionify/src/deps/types.ts>LastArrayElement

Create and manage your GitHub workflows with TypeScript and Deno.
Latest
type alias LastArrayElement
import { type LastArrayElement } from "https://deno.land/x/actionify@0.3.0/src/deps/types.ts";

Extracts the type of the last element of an array.

Use-case: Defining the return type of functions that extract the last element of an array, for example lodash.last.

Examples

Example 1

import type {LastArrayElement} from 'type-fest';

declare function lastOf<V extends readonly any[]>(array: V): LastArrayElement<V>;

const array = ['foo', 2];

typeof lastOf(array);
//=> number

Type Parameters

ValueType extends readonly unknown[]
definition: ValueType extends readonly [infer ElementType] ? ElementType : ValueType extends readonly [infer _, ...infer Tail] ? LastArrayElement<Tail> : ValueType extends ReadonlyArray<infer ElementType> ? ElementType : never