Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @younho9/types

Index

Alternative Type aliases

AlternativeAny

AlternativeAny: Primitive | object

AlternativeFunction

AlternativeFunction: AnyFunction

Alternative of Function

Ban-types https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md#default-options

Function vs (...args: Array<any>) => any

values Function () => any (arg: any) => any (arg1: any, arg2: any) => any (...args: Array<any>) => any
Function
() => any
(arg: any) => any
(arg1: any, arg2: any) => any
(...args: Array<any>) => any

AlternativeObject

AlternativeObject: Record<string, unknown>

Alternative of object

Ban-types https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md#default-options

{} vs object vs Object vs Record<string, unknown> vs Record<PropertyKey, unknown>

values {} object Object Record<string, unknown> Record<PropertyKey, unknown>
{}
[]
() => undefined (Function)
new String('') (String)
new Number(1) (Number)
new Boolean(false) (Boolean)
a (string)
1 (number)
Symbol('symbol') (symbol)
null (null)
undefined (undefined)
abc (ABC: {a: string; b: number; c: boolean})
abc (interface ABC)
abc (type ABC)
abc (class ABC)
abc (Record<string, unknown>)
abc (Record<PropertyKey, unknown>)
abc.a (access property)

Dict

Dict<Type>: Record<string, Type>

Dictionary of Type

Type parameters

  • Type = unknown

Optional

Optional<ObjectType>: Partial<ObjectType>

Make all properties in ObjectType optional

Type parameters

  • ObjectType: object

Basic Type aliases

Falsy

Falsy: false | 0 | 0 | 0n | "" | null | undefined

NaN is also Falsy, but TypeScript doesn't have a numeric literal. https://github.com/Microsoft/TypeScript/issues/15135

HTMLAllCollection is also Falsy, but it's a deprecated feature.

Also, !!HTMLAllCollection is inferred as true in TypeScript. https://developer.mozilla.org/en-US/docs/Web/API/Document/all

Nullish

Nullish: undefined | null

Truthy

Truthy<T>: Exclude<T, Falsy>

Type parameters

Object Type aliases

Completed

Completed<Base>: { [ Key in keyof Required<Base>]: Key extends RequiredKeys<Base> ? Base[Key] : Base[Key] | undefined }

Type parameters

  • Base

ConditionalExcludeKeys

ConditionalExcludeKeys<Base, Condition>: Exclude<keyof Base, ConditionalKeys<Base, Condition>>

Extract the keys from a type where the value type of the key extends the given Condition.

Internally this is used for the ConditionalPick and ConditionalExcept types.

example
import {ConditionalKeys} from 'type-fest';

interface Example {
a: string;
b: string | number;
c?: string;
d: {};
}

type StringKeysOnly = ConditionalKeys<Example, string>;
//=> 'a'

To support partial types, make sure your Condition is a union of undefined (for example, string | undefined) as demonstrated below.

example
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
//=> 'a' | 'c'

Type parameters

  • Base

  • Condition

OptionalKeys

OptionalKeys<Base>: Exclude<keyof Base, RequiredKeys<Base>>

Get all optional properties

Type parameters

  • Base

RequiredKeys

RequiredKeys<Base>: NonNullable<{ [ Key in keyof Base]: Pick<Base, Key> extends Required<Pick<Base, Key>> ? Key : never }[keyof Base]>

Get all required properties

Type parameters

  • Base

StringKeyOf

StringKeyOf<ObjectType>: ToString<keyof Omit<ObjectType, symbol>>[]

Type parameters

  • ObjectType: object

Other Type aliases

AnyFunction

AnyFunction<ReturnType>: (...args: any[]) => ReturnType

Type parameters

  • ReturnType = any

Type declaration

    • (...args: any[]): ReturnType
    • Parameters

      • Rest ...args: any[]

      Returns ReturnType

GetOptional

GetOptional<Base>: Pick<Base, OptionalKeys<Base>>

Type parameters

  • Base

GetRequired

GetRequired<Base>: Pick<Base, RequiredKeys<Base>>

Type parameters

  • Base

Utilities Type aliases

InvariantOf

InvariantOf<Type>: Type & InvariantSignature<Type>

Make type as Invariant

Type parameters

  • Type

InvariantOfDeep

InvariantOfDeep<Type>: Type extends Primitive ? InvariantOf<Type> : InvariantOf<{ [ KeyType in keyof Type]: InvariantOfDeep<Type[KeyType]> }>

Make type as Invariant deeply

Type parameters

  • Type

Subtract

Subtract<Type>: Exclude<AlternativeAny, Type>

Type parameters

  • Type

ToString

ToString<Type>: Type extends Subtract<symbol | bigint | object> ? `${Type}` : never

Type parameters

  • Type

Generated using TypeDoc