Skip to content

Instantly share code, notes, and snippets.

View dvitiuk-opensource's full-sized avatar

Dmytro Vitiuk dvitiuk-opensource

View GitHub Profile
@dvitiuk-opensource
dvitiuk-opensource / actions-union.ts
Last active June 8, 2018 10:24
Improved NgRx type safety with TypeScript 2.8
type FunctionType = (...args: any[]) => any;
interface ActionCreatorsMapObject {
[action: string]: FunctionType;
}
export type ActionsUnion<A extends ActionCreatorsMapObject> = ReturnType<A[keyof A]>;
import { Injectable, isDevMode, NgModule, Pipe } from "@angular/core";
import { Observable } from "rxjs/Observable";
import { BehaviorSubject } from "rxjs/BehaviorSubject";
export type AvailableFeatures = keyof { "FEATURE_FROM_BACK", "PAID_PLAN": false }
export type AvailableFeaturesObj = {[key in AvailableFeatures]: any};
export const Features: AvailableFeaturesObj = {
"PAID_PLAN": true,
function add(x, y) {
return x + y;
}
function mul(x, y) {
return x * y;
}
function make(){