Options
All
  • Public
  • Public/Protected
  • All
Menu

Module typings/general-types

Index

Type aliases

BooleanNameValue

BooleanNameValue: NameValue<PropertyKey, boolean>

BooleanNameValue

desc

Boolean name-value type with string name and boolean value properties

BooleanPair

BooleanPair: Pair<boolean, boolean>

BooleanPair

desc

Boolean pair type with left and right boolean values

BufferEncoding

BufferEncoding: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"

Supported buffer encoding types

Call

Call<Fn>: Fn extends (arg: any) => infer RT ? RT : never

Call

desc

Get the return type from a given typeof expression

see

https://flow.org/en/docs/types/utilities/#toc-call

example

// Common use-case const add = (amount: number) => ({ type: 'ADD' as 'ADD', payload: amount }); type AddAction = Call; // { type: 'ADD'; payload: number }

// Examples migrated from Flow docs type ExtractPropType<T extends { prop: any }> = (arg: T) => T['prop']; type Obj = { prop: number }; type PropType = Call<ExtractPropType>; // number

type ExtractReturnType<T extends () => any> = (arg: T) => ReturnType; type Fn = () => number; type FnReturnType = Call<ExtractReturnType>; // number

Type parameters

  • Fn: (...args: any[]) => any

Class

Class<T>: new (...args: any[]) => T

Class

desc

Represents constructor of type T

see

https://flow.org/en/docs/types/utilities/#toc-class

example

class Store {} function makeStore(storeClass: Class): Store { return new storeClass(); }

Type parameters

  • T

Type declaration

    • new (...args: any[]): T
    • Parameters

      • Rest ...args: any[]

      Returns T

DateRange

DateRange: Range<Date>

DateRange

desc

DateRange type with date lower and upper bound properties

ElementType

ElementType<T, K>: T[K]

ElementType

desc

Get the type of elements inside of array, tuple or object of type T, that matches the given index type K

see

https://flow.org/en/docs/types/utilities/#toc-elementtype

example

// Expect: string; type Props = { name: string; age: number; visible: boolean }; type NameType = ElementType<Props, 'name'>;

// Expect: boolean type Tuple = [boolean, number]; type A = ElementType<Tuple, '0'>; // Expect: number type B = ElementType<Tuple, '1'>;

// Expect: boolean type Arr = boolean[]; type ItemsType = ElementType<Arr, number>;

// Expect: number type Obj = { [key: string]: number }; type ValuesType = ElementType<Obj, string>;

Type parameters

  • T: {[ P in K & any]: any }

  • K: keyof T | number

KeyValue

KeyValue<T, V>: { key: T; value: V }

KeyValue

desc

KeyValue type with key and value properties

Type parameters

  • T

  • V

Type declaration

  • key: T
  • value: V

Keys

Keys<T>: keyof T

Keys

desc

Get the union type of all the keys in an object type T

see

https://flow.org/en/docs/types/utilities/#toc-keys

example

type Props = { name: string; age: number; visible: boolean };

// Expect: "name" | "age" | "visible" type PropsKeys = Keys;

Type parameters

  • T

KeywordData

KeywordData<T>: [T, number | bigint]

KeywordData

desc

KeywordData type with double-sized string/number array values

Type parameters

  • T: PropertyKey

KeywordDict

KeywordDict<T>: Record<string, KeywordData<T>>

KeywordDict

desc

KeywordDict record type with string keys and keyword data values

Type parameters

  • T: PropertyKey

NameValue

NameValue<T, V>: { name: T; value: V }

NameValue

desc

NameValue type with string name and value properties

Type parameters

  • T: PropertyKey

  • V

Type declaration

  • name: T
  • value: V

NonNullKeyValue

NonNullKeyValue<T, V>: KeyValue<T, NonNull<V>>

NonNullKeyValue

desc

KeyValue type with key and non-nullable value properties

Type parameters

  • T

  • V

NonNullNameValue

NonNullNameValue<V>: NameValue<PropertyKey, NonNull<V>>

NonNullNameValue

desc

Non-nullable name-value type with string name and non-nullable value properties

Type parameters

  • V

NonNullPair

NonNullPair<T, V>: Pair<NonNull<T>, NonNull<V>>

NonNullPair

desc

Non-nullable pair type with left and right non-nullable values

Type parameters

  • T

  • V

NonNullRange

NonNullRange<T>: Range<NonNull<T>>

NonNullRange

desc

OptionalRange type with non-nullable lower and upper bound properties

Type parameters

  • T

NumberNameValue

NumberNameValue: NameValue<PropertyKey, number | bigint>

NumberNameValue

desc

Number name-value type with string name and number value properties

NumberPair

NumberPair: Pair<number | bigint, number | bigint>

NumberPair

desc

Number pair type with left and right number values

NumberRange

NumberRange: Range<number | bigint>

NumberRange

desc

NumberRange type with number lower and upper bound properties

OptionalKeyValue

OptionalKeyValue<T, V>: KeyValue<T, Optional<V>>

OptionalKeyValue

desc

KeyValue type with key and optional value properties

Type parameters

  • T

  • V

OptionalLeft

OptionalLeft<T, V>: Pair<Optional<T>, V>

OptionalLeft

desc

Optional pair type with optional left value

Type parameters

  • T

  • V

OptionalNameValue

OptionalNameValue<V>: NameValue<PropertyKey, Optional<V>>

OptionalNameValue

desc

Optional name-value type with string name and optional value properties

Type parameters

  • V

OptionalPair

OptionalPair<T, V>: Pair<Optional<T>, Optional<V>>

OptionalPair

desc

Optional pair type with left and right optional values

Type parameters

  • T

  • V

OptionalRange

OptionalRange<T>: Range<Optional<T>>

OptionalRange

desc

OptionalRange type with optional lower and upper bound properties

Type parameters

  • T

OptionalRight

OptionalRight<T, V>: Pair<T, Optional<V>>

OptionalRight

desc

Optional pair type with optional right value

Type parameters

  • T

  • V

Pair

Pair<T, V>: { left: T; right: V }

Pair

desc

Pair type with left and right values

Type parameters

  • T

  • V

Type declaration

  • left: T
  • right: V

Pair2

Pair2<T, V>: { first: T; second: V }

Pair2

desc

Pair2 type with first and second values

Type parameters

  • T

  • V

Type declaration

  • first: T
  • second: V

Pair3

Pair3<T, V, R>: { first: T; second: V; third: R }

Pair3

desc

Pair3 type with first, second and third values

Type parameters

  • T

  • V

  • R

Type declaration

  • first: T
  • second: V
  • third: R

Pair4

Pair4<T, V, R, S>: { first: T; fourth: S; second: V; third: R }

Pair4

desc

Pair4 type with first, second, third and fourth values

Type parameters

  • T

  • V

  • R

  • S

Type declaration

  • first: T
  • fourth: S
  • second: V
  • third: R

Pair5

Pair5<T, V, R, S, M>: { fifth: M; first: T; fourth: S; second: V; third: R }

Pair5

desc

Pair5 type with first, second, third, fourth and fifth values

Type parameters

  • T

  • V

  • R

  • S

  • M

Type declaration

  • fifth: M
  • first: T
  • fourth: S
  • second: V
  • third: R

Pair6

Pair6<T, V, R, S, M, N>: { fifth: M; first: T; fourth: S; second: V; sixth: N; third: R }

Pair6

desc

Pair6 type with first, second, third, fourth, fifth and sixth values

Type parameters

  • T

  • V

  • R

  • S

  • M

  • N

Type declaration

  • fifth: M
  • first: T
  • fourth: S
  • second: V
  • sixth: N
  • third: R

PartialKeyValue

PartialKeyValue<T, V>: KeyValue<T, Partial<V>>

PartialKeyValue

desc

KeyValue type with key and partial value properties

Type parameters

  • T

  • V

PartialPair

PartialPair<T, V>: Pair<Partial<T>, Partial<V>>

PartialPair

desc

Partial pair type with left and right partial values

Type parameters

  • T

  • V

PartialRange

PartialRange<T>: Range<Partial<T>>

PartialRange

desc

OptionalRange type with partial lower and upper bound properties

Type parameters

  • T

PartialValue

PartialValue<V>: NameValue<PropertyKey, Partial<V>>

PartialValue

desc

NameValue type with string name and partial value properties

Type parameters

  • V

ProcessConfig

ProcessConfig<T>: { env: T }

Supported process configuration options

Type parameters

Type declaration

  • Readonly env: T

PropertyKeyPair

PropertyKeyPair: Pair<PropertyKey, PropertyKey>

PropertyKeyPair

desc

Property key pair type with left and right property key values

PropertyType

PropertyType<T, K>: T[K]

PropertyType

desc

Get the type of property of an object at a given key K

see

https://flow.org/en/docs/types/utilities/#toc-propertytype

example

// Expect: string; type Props = { name: string; age: number; visible: boolean }; type NameType = PropertyType<Props, 'name'>;

// Expect: boolean type Tuple = [boolean, number]; type A = PropertyType<Tuple, '0'>; // Expect: number type B = PropertyType<Tuple, '1'>;

Type parameters

  • T

  • K: keyof T

Range

Range<T>: { lower: T; upper: T }

RangeValue

desc

RangeValue type with lower and upper bound properties

Type parameters

  • T

Type declaration

  • lower: T
  • upper: T

RegexNameValue

RegexNameValue: NameValue<PropertyKey, RegExp>

RegexNameValue

desc

Regex name-value type with string name and regex value properties

RegexStringPair

RegexStringPair: Pair<RegExp, string>

RegexStringPair

desc

Regex string pair type with regex left and string right values

RequiredKeyValue

RequiredKeyValue<T, V>: KeyValue<T, Required<V>>

RequiredKeyValue

desc

KeyValue type with key and required value properties

Type parameters

  • T

  • V

RequiredPair

RequiredPair<T, V>: Pair<Required<T>, Required<V>>

RequiredPair

desc

Required pair type with left and right required values

Type parameters

  • T

  • V

RequiredRange

RequiredRange<T>: Range<Required<T>>

RequiredRange

desc

OptionalRange type with required lower and upper bound properties

Type parameters

  • T

RequiredValue

RequiredValue<V>: NameValue<PropertyKey, Required<V>>

RequiredValue

desc

NameValue type with string name and required value properties

Type parameters

  • V

ReversePair

ReversePair<T, V>: Pair<V, T>

ReversePair

desc

Revers pair type with left and right values

Type parameters

  • T

  • V

SearchOptions

SearchOptions: { bool?: "and" | "or" | "not"; field?: string | string[]; limit?: number; suggest?: boolean; where?: {} }

Type declaration

  • Optional bool?: "and" | "or" | "not"
  • Optional field?: string | string[]
  • Optional limit?: number
  • Optional suggest?: boolean
  • Optional where?: {}
    • [key: string]: string

Shape

Shape<T>: Partial<T>

Shape

desc

Copies the shape of the type supplied, but marks every field optional.

see

https://flow.org/en/docs/types/utilities/#toc-shape

example

type Props = { name: string; age: number; visible: boolean };

// Expect: Partial type PartialProps = Shape;

Type parameters

  • T

StringNameValue

StringNameValue: NameValue<PropertyKey, string>

StringNameValue

desc

String name-value type with string name and string value properties

StringPair

StringPair: Pair<string, string>

StringPair

desc

String pair type with left and right string values

StringRegexPair

StringRegexPair: Pair<string, RegExp>

StringRegexPair

desc

String regex pair type with string left and regex right values

Values

Values<T>: T[keyof T]

Values

desc

Get the union type of all the values in an object type T

see

https://flow.org/en/docs/types/utilities/#toc-values

example

type Props = { name: string; age: number; visible: boolean };

// Expect: string | number | boolean type PropsValues = Values;

Type parameters

  • T

mixed

mixed: unknown

mixed

desc

An arbitrary type that could be anything

see

https://flow.org/en/docs/types/mixed

example

function stringify(value: mixed) { // ... }

stringify("foo"); stringify(3.14); stringify(null); stringify({});