Skip to content

Instantly share code, notes, and snippets.

View dmitriy-novikov's full-sized avatar

Dmitriy dmitriy-novikov

View GitHub Profile
@dmitriy-novikov
dmitriy-novikov / infer-value-types.ts
Last active November 5, 2020 12:52
Action Type Inference
import * as actions from 'action-creators';
// Тип, который берет action-creators, выводит типы всех экшенов по отдельности и собирает их в union
type InferValueTypes<T> = T extends { [key: string]: infer U }
? U
: never;
type ActionTypes = ReturnType<InferValueTypes<typeof actions>>;