If our dependencies look like this:
declare class Repository<T> {
find<T>(options: FindOptions): Promise<T>;
}
interface FindOptions {
import { AnyAction, Reducer } from 'redux'; | |
/** | |
* Equivalent for `handleActions` from the redux-actions` library. | |
* @see https://redux.js.org/recipes/reducing-boilerplate#generating-reducers | |
* | |
* @template T Reducer shape. | |
*/ | |
export function createReducer<T>(handlers: Record<string, Reducer<T>>, initialState: T): Reducer<T> { | |
return (state: T = initialState, action: AnyAction): T => { |
/** | |
* TypeScript version of @istarkov's cancellable Promise wrapper. | |
* | |
* @see https://github.com/facebook/react/issues/5465#issuecomment-157888325 | |
*/ | |
const makeCancelable = <T>(promise: Promise<T>): { promise: Promise<T>; cancel(): void } => { | |
let hasCanceled = false; | |
const wrappedPromise = new Promise<T>((resolve, reject) => { | |
promise.then( |
export function flatMap<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => U[]): U[] { | |
return Array.prototype.concat(...array.map(callbackfn)); | |
} |
import { AnyAction, Middleware } from 'redux'; | |
export const userTimingMiddleware: Middleware = () => { | |
return next => { | |
return <A extends AnyAction>(action: A): A => { | |
if (performance.mark === undefined) { | |
return next(action); | |
} | |
performance.mark(`${action.type}_start`); |
enum PokemonType { | |
Water, | |
Rock, | |
Fire, | |
Air, | |
Electric, | |
Poison | |
} | |
class Pokemon { |
/** | |
* TypeScript version of the solution proposed by @kitze. | |
* | |
* @see https://gist.github.com/kitze/23d82bb9eb0baabfd03a6a720b1d637f | |
*/ | |
import React from 'react'; | |
interface Props<T = {}> { | |
condition: boolean; | |
render: (children: React.ReactElement<T> | null) => React.ReactElement<T> | null; |
type IdentityFunction<T> = (argument: T) => T; | |
type InnerHTMLTransformer = IdentityFunction<string>; | |
type RegularExpressionFlags = | |
| 'i' | |
| 'g' | |
| 'ig'; | |
type Phrase = string | RegExp; |
/node_modules/ | |
webpack:///webpack | |
^webpack://.*/process\-update\.js$ | |
^webpack://.*/client\.js$ | |
^debugger:// | |
\(webpack\)-hot-middleware | |
webpack/bootstrap | |
/jquery\.min\.js$ | |
/jquery\-migrate\-1\.4\.1\.min\.js$ |
{ | |
"compilerOptions": { | |
/* Basic Options */ | |
"target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ | |
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | |
"lib": [ /* Specify library files to be included in the compilation. */ | |
"dom", | |
"esnext" | |
], | |
// "allowJs": true, /* Allow javascript files to be compiled. */ |