Skip to main content
Module

x/fonction/mod.ts>Init

A modern practical functional library
Latest
type alias Init
import { type Init } from "https://deno.land/x/fonction@v2.1.0-beta.4/mod.ts";

Infer the init types.

Examples

Example 1

// String
Init<string> // string
Init<''> // ''
Init<'hello'> // 'hell'

Example 2

// Array
Init<[] | never[] | readonly [] | readonly never[]> // []
Init<['hello']> // []
Init<['hello', 'world']> // ['hello']

Type Parameters

T extends string | readonly unknown[]
definition: T extends string ? InitString<T> : T extends readonly [...infer I, unknown] ? I : T