0.7.7 • Published 5 months ago
@types/react-copy-write v0.7.7
Installation
npm install --save @types/react-copy-write
Summary
This package contains type definitions for react-copy-write (https://github.com/aweary/react-copy-write).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-copy-write.
index.d.ts
// Type definitions for react-copy-write 0.7
// Project: https://github.com/aweary/react-copy-write
// Definitions by: Sam A. Horvath-Hunt <https://github.com/samhh>
// Dave Jeffery <https://github.com/davej>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { Component } from 'react';
// It'd be nice if this could somehow be improved! Perhaps we need variadic
// kinds plus infer keyword? Alternatively unions may solve our issue if we had
// the ability to restrict type widening.
type AnyDeepMemberOfState<T> = any;
type MutateFn<T> = (draft: T, state: Readonly<T>) => void;
type Mutator<T> = (mutator: MutateFn<T>) => void;
type SelectorFn<T> = (state: T) => AnyDeepMemberOfState<T>;
type RenderFn<T> = (...state: Array<Readonly<ReturnType<SelectorFn<T>>>>) => JSX.Element | JSX.Element[] | null;
interface ConsumerPropsBase<T> {
select?: Array<SelectorFn<T>> | undefined;
}
interface ConsumerPropsExplicitRender<T> extends ConsumerPropsBase<T> {
render?: RenderFn<T> | undefined;
}
interface ConsumerPropsImplicitRender<T> extends ConsumerPropsBase<T> {
children?: RenderFn<T> | undefined;
}
type ConsumerProps<T> = ConsumerPropsExplicitRender<T> | ConsumerPropsImplicitRender<T>;
declare class Consumer<T> extends Component<ConsumerProps<T>> {}
interface ProviderProps<T> {
children: JSX.Element | JSX.Element[];
initialState?: Partial<T> | undefined;
}
declare class Provider<T> extends Component<ProviderProps<T>> {}
declare function create<T extends object>(state: T): {
Provider: new() => Provider<T>,
Consumer: new() => Consumer<T>,
createSelector: SelectorFn<T>,
mutate: Mutator<T>,
};
export default create;
Additional Details
- Last updated: Thu, 08 Jul 2021 20:20:32 GMT
- Dependencies: @types/react
- Global values: none
Credits
These definitions were written by Sam A. Horvath-Hunt, and Dave Jeffery .