JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3059
  • Score
    100M100P100Q141953F
  • License MIT

React / Redux / TypeScript Utils

Package Exports

  • react-redux-typescript

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-redux-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React / Redux / TypeScript Utils

Utility belt for React + Redux + TypeScript Projects

  • Semantic Versioning
  • No external dependencies
  • Output separate bundles for your specific workflow needs:
    • ES5 + CommonJS - main
    • ES5 + ES-Modules - module
    • ES2015 + CommonJS - jsnext:main

Table of Contents (v3.0)

TS Redux Actions

For advanced docs check here: https://github.com/piotrwitek/ts-redux-actions

Mapped Types

Type Utils


Archived docs:


TS Redux Actions

createAction

createAction(typeString, creatorFunction?)
typeString: TS extends string,
creatorFunction: (...args: any[]) => { type: TS, payload?: P, meta?: M, error?: boolean }
return: (
  (...args: any[]) => { type: TS, payload?: P, meta?: M, error?: boolean }
) & { readonly type: TS }

Mapped Types

Diff

// TestDiff expects: ('a' | 'b')
type TestDiff =
  Diff<'a' | 'b' | 'c', 'c' | 'd'>;

Omit

// TestOmit expects: { b: number, c: boolean }
type TestOmit =
  Omit<{ a: string, b: number, c: boolean }, 'a'>;

Overwrite

// TestOverwrite expects: { b: number, c: boolean } & { a: number }
type TestOverwrite =
  Overwrite<{ a: string, b: number, c: boolean }, { a: number }>;

Type Utils

getReturnOfExpression

Get return value of an "expression" with inferred return type
alias: returntypeof
https://github.com/Microsoft/TypeScript/issues/6606

// this polyfill exist because TypeScript does not support getting type of expression 
// (tracking issue: https://github.com/Microsoft/TypeScript/issues/6606)
function getReturnOfExpression<T>(
  expression: (...params: any[]) => T,
): T;

// Example:
import { getReturnOfExpression } from 'react-redux-typescript';

const increment = () => ({ type: 'INCREMENT' as 'INCREMENT' });

const returnOfIncrement = getReturnOfExpression(increment);
type INCREMENT = typeof returnOfIncrement; // { type: "INCREMENT"; }

MIT License

Copyright (c) 2016 Piotr Witek piotrek.witek@gmail.com (http://piotrwitek.github.io)