From 4291cff90846af87a37e5f8007a76d5d64f89500 Mon Sep 17 00:00:00 2001 From: christianalfoni Date: Tue, 15 Jan 2019 18:39:02 +0100 Subject: [PATCH 1/2] feat(overmind): refactor to interface based typing and expose actions to actions and effects to comp BREAKING CHANGE: use interfaces instead of types --- .../overmind-angular/src/index.ts | 4 +- .../overmind-devtools/src/overmind/index.ts | 4 +- .../src/overmind/operators.ts | 4 +- .../overmind-react/src/index.test.tsx | 20 +-- .../node_modules/overmind-react/src/index.ts | 11 +- .../node_modules/overmind-vue/src/index.ts | 3 +- .../node_modules/overmind/src/config/index.ts | 4 +- .../node_modules/overmind/src/derived.test.ts | 56 ++------ .../node_modules/overmind/src/index.test.ts | 11 +- packages/node_modules/overmind/src/index.ts | 135 +++++++++--------- .../overmind/src/internalTypes.ts | 19 +-- .../node_modules/overmind/src/mock.test.ts | 12 +- packages/node_modules/overmind/src/types.ts | 26 ++-- .../examples/api/config_lazy.ts | 4 +- .../examples/api/config_merge.ts | 4 +- .../examples/api/config_namespaced.ts | 4 +- .../overmind-website/examples/api/connect.ts | 2 +- .../guide/connectingcomponents/actions.ts | 2 +- .../guide/connectingcomponents/array_1.ts | 2 +- .../guide/connectingcomponents/array_2.ts | 2 +- .../guide/connectingcomponents/array_3.ts | 4 +- .../guide/connectingcomponents/connect.ts | 2 +- .../guide/connectingcomponents/object_1.ts | 2 +- .../guide/connectingcomponents/object_2.ts | 4 +- .../goingfunctional/callactionoperator.ts | 2 +- .../examples/guide/managinglists/render.ts | 2 +- .../examples/guide/managinglists/render2.ts | 4 +- .../examples/guide/routing/users.ts | 6 +- .../examples/guide/typescript/declare.ts | 4 +- .../guide/typescript/declare_imports.ts | 1 - .../examples/guide/typescript/explicit.ts | 24 ++-- .../guide/usingovermindwithangular/connect.ts | 8 +- .../guide/usingovermindwithreact/hoc.ts | 10 +- .../usingovermindwithreact/hoc_passprop.ts | 4 +- .../guide/usingovermindwithreact/hook.ts | 6 +- .../usingovermindwithreact/hook_effect.ts | 2 +- .../hook_effect_subscription.ts | 2 +- .../usingovermindwithreact/hook_passprop.ts | 4 +- .../examples/guide/writingtests/effect.ts | 20 +-- .../overmind-website/examples/templates.ts | 8 +- .../overmind-website/src/overmind/index.ts | 4 +- 41 files changed, 209 insertions(+), 243 deletions(-) diff --git a/packages/node_modules/overmind-angular/src/index.ts b/packages/node_modules/overmind-angular/src/index.ts index 82df30e8..ceb0f4c2 100644 --- a/packages/node_modules/overmind-angular/src/index.ts +++ b/packages/node_modules/overmind-angular/src/index.ts @@ -4,9 +4,10 @@ import { EventType, Overmind, TApp, Configuration } from 'overmind' import { NgZone } from '@angular/core' import { IMutation } from 'proxy-state-tree' -export type TConnect = { +export interface IConnect { state: TApp['state'] actions: TApp['actions'] + effects: TApp['effects'] addMutationListener: (cb: (mutation: IMutation) => void) => () => void } @@ -31,6 +32,7 @@ export const createConnect = >(overmind: A) => () => { this.overmind = { state: this.__tree.state, actions: overmind.actions, + effects: overmind.effects, addMutationListener: overmind.addMutationListener, } this.__shouldUpdatePaths = false diff --git a/packages/node_modules/overmind-devtools/src/overmind/index.ts b/packages/node_modules/overmind-devtools/src/overmind/index.ts index 719a160d..efda1013 100644 --- a/packages/node_modules/overmind-devtools/src/overmind/index.ts +++ b/packages/node_modules/overmind-devtools/src/overmind/index.ts @@ -1,4 +1,4 @@ -import { Overmind, TConfig } from 'overmind' +import { Overmind, IConfig } from 'overmind' import { createHook } from 'overmind-react' import * as actions from './actions' @@ -13,7 +13,7 @@ const config = { } declare module 'overmind' { - interface IConfig extends TConfig {} + interface Config extends IConfig {} } export const overmind = new Overmind(config, { diff --git a/packages/node_modules/overmind-devtools/src/overmind/operators.ts b/packages/node_modules/overmind-devtools/src/overmind/operators.ts index a8e13542..4faf2dcd 100644 --- a/packages/node_modules/overmind-devtools/src/overmind/operators.ts +++ b/packages/node_modules/overmind-devtools/src/overmind/operators.ts @@ -326,4 +326,6 @@ export const forkEachMessage: ( ) => Operator[]> = (paths) => forEach(fork(({ value }) => value.type, paths) as Operator>) -export const updateOperatorAsync = action(() => {}) +export const updateOperatorAsync: Operator = action( + () => {} +) diff --git a/packages/node_modules/overmind-react/src/index.test.tsx b/packages/node_modules/overmind-react/src/index.test.tsx index a88764f3..edc32336 100644 --- a/packages/node_modules/overmind-react/src/index.test.tsx +++ b/packages/node_modules/overmind-react/src/index.test.tsx @@ -1,7 +1,7 @@ -import { Overmind, TAction } from 'overmind' +import { Overmind, IAction } from 'overmind' import * as React from 'react' import * as renderer from 'react-test-renderer' -import { TConnect, createConnect } from './' +import { IConnect, createConnect } from './' describe('React', () => { test('should connect state and actions to stateless components', () => { @@ -29,11 +29,11 @@ describe('React', () => { const app = new Overmind(config) - type Action = TAction + interface Action extends IAction {} const connect = createConnect(app) - const Component: React.SFC> = ({ overmind }) => { + const Component: React.SFC> = ({ overmind }) => { overmind.actions.doThis() return

{overmind.state.foo}

} @@ -68,11 +68,11 @@ describe('React', () => { const app = new Overmind(config) - type Action = TAction + interface Action extends IAction {} const connect = createConnect(app) - class Component extends React.Component> { + class Component extends React.Component> { componentDidMount() { this.props.overmind.actions.doThis() } @@ -101,7 +101,7 @@ describe('React', () => { const connect = createConnect(app) - class Component extends React.Component> { + class Component extends React.Component> { render() { const { overmind } = this.props @@ -120,7 +120,7 @@ describe('React', () => { const app = new Overmind({}) const connect = createConnect(app) - class FooComponent extends React.Component> { + class FooComponent extends React.Component> { render() { return

hop

} @@ -161,11 +161,11 @@ describe('React', () => { const app = new Overmind(config) - type Action = TAction + interface Action extends IAction {} const connect = createConnect(app) - class FooComponent extends React.Component> { + class FooComponent extends React.Component> { shouldComponentUpdate(nextProps) { return this.props.overmind !== nextProps.overmind } diff --git a/packages/node_modules/overmind-react/src/index.ts b/packages/node_modules/overmind-react/src/index.ts index c05c1e56..8f84675c 100644 --- a/packages/node_modules/overmind-react/src/index.ts +++ b/packages/node_modules/overmind-react/src/index.ts @@ -29,10 +29,11 @@ type Omit = Pick< { [P in K]: never } & { [x: string]: never; [x: number]: never })[keyof T] > -export type TConnect = { +export interface IConnect { overmind: { state: TApp['state'] actions: TApp['actions'] + effects: TApp['effects'] addMutationListener: (cb: (mutation: IMutation) => void) => () => void } } @@ -44,6 +45,7 @@ export const createHook =
>( ): (() => { state: A['state'] actions: A['actions'] + effects: A['effects'] addMutationListener: (cb: (mutation: IMutation) => void) => () => void }) => { let currentComponentInstanceId = 0 @@ -128,6 +130,7 @@ export const createHook = >( return { state: tree.state, actions: overmind.actions, + effects: overmind.effects, addMutationListener: overmind.addMutationListener, } } @@ -140,7 +143,7 @@ export const createConnect = >( component: IReactComponent< Props & { overmind: { state: A['state']; actions: A['actions'] } } > - ): IReactComponent, keyof TConnect>> => { + ): IReactComponent, keyof IConnect>> => { let componentInstanceId = 0 const name = component.name const populatedComponent = component as any @@ -171,6 +174,7 @@ export const createConnect = >( this.state = { overmind: { state: this.tree.state, + effects: overmind.effects, actions: overmind.actions, addMutationListener: overmind.addMutationListener, onUpdate: this.onUpdate, @@ -185,6 +189,7 @@ export const createConnect = >( this.setState({ overmind: { state: this.tree.state, + effects: overmind.effects, actions: overmind.actions, addMutationListener: overmind.addMutationListener, onUpdate: this.onUpdate, @@ -223,6 +228,7 @@ export const createConnect = >( this.state = { overmind: { state: this.tree.state, + effects: overmind.effects, actions: overmind.actions, addMutationListener: overmind.addMutationListener, onUpdate: this.onUpdate, @@ -260,6 +266,7 @@ export const createConnect = >( this.setState({ overmind: { state: this.tree.state, + effects: overmind.effects, actions: overmind.actions, addMutationListener: overmind.addMutationListener, onUpdate: this.onUpdate, diff --git a/packages/node_modules/overmind-vue/src/index.ts b/packages/node_modules/overmind-vue/src/index.ts index 1852d6df..0ed7ec68 100644 --- a/packages/node_modules/overmind-vue/src/index.ts +++ b/packages/node_modules/overmind-vue/src/index.ts @@ -1,4 +1,4 @@ -import { EventType, Overmind } from 'overmind' +import { EventType } from 'overmind' let nextComponentId = 0 @@ -19,6 +19,7 @@ export const createConnect = (overmind) => (options) => { this.overmind = { state: this.__tree.state, actions: overmind.actions, + effects: overmind.effects, addMutationListener: overmind.addMutationListener, } this.__tree.track(this.__onUpdate) diff --git a/packages/node_modules/overmind/src/config/index.ts b/packages/node_modules/overmind/src/config/index.ts index 418fa840..632be2ce 100644 --- a/packages/node_modules/overmind/src/config/index.ts +++ b/packages/node_modules/overmind/src/config/index.ts @@ -1,4 +1,4 @@ -import { Configuration, TAction } from '../' +import { Configuration, IAction } from '../' type SubType = Pick< Base, @@ -256,7 +256,7 @@ export function lazy( object > & { lazy: { - loadConfig: TAction + loadConfig: IAction } } } { diff --git a/packages/node_modules/overmind/src/derived.test.ts b/packages/node_modules/overmind/src/derived.test.ts index f27e7377..7036ff08 100644 --- a/packages/node_modules/overmind/src/derived.test.ts +++ b/packages/node_modules/overmind/src/derived.test.ts @@ -1,4 +1,4 @@ -import { Overmind, TAction, TDerive, TStateObject } from './' +import { Overmind, IAction, IDerive, TStateObject } from './' type State = { foo: string @@ -19,15 +19,10 @@ describe('Derived', () => { state, } - type Config = { - state: typeof state - } + type Config = typeof config - type Derive = TDerive< - Config, - Parent, - Value - > + interface Derive + extends IDerive {} const app = new Overmind(config) @@ -59,12 +54,9 @@ describe('Derived', () => { } actions: typeof config.actions } - type Action = TAction - type Derive = TDerive< - Config, - Parent, - Value - > + interface Action extends IAction {} + interface Derive + extends IDerive {} const app = new Overmind(config) const trackStateTree = app.getTrackStateTree() @@ -102,19 +94,10 @@ describe('Derived', () => { changeFoo, }, } - type Config = { - state: { - foo: string - upperFoo: string - } - actions: typeof config.actions - } - type Action = TAction - type Derive = TDerive< - Config, - Parent, - Value - > + type Config = typeof config + interface Action extends IAction {} + interface Derive + extends IDerive {} const app = new Overmind(config) @@ -139,19 +122,10 @@ describe('Derived', () => { changeFoo, }, } - type Config = { - state: { - foo: string - upperFoo: string - } - actions: typeof config.actions - } - type Action = TAction - type Derive = TDerive< - Config, - Parent, - Value - > + type Config = typeof config + interface Action extends IAction {} + interface Derive + extends IDerive {} const app = new Overmind(config) diff --git a/packages/node_modules/overmind/src/index.test.ts b/packages/node_modules/overmind/src/index.test.ts index 31eb8365..edf7ce20 100644 --- a/packages/node_modules/overmind/src/index.test.ts +++ b/packages/node_modules/overmind/src/index.test.ts @@ -1,4 +1,4 @@ -import { EventType, Overmind, TAction } from './' +import { EventType, Overmind, IAction } from './' import { namespaced } from './config' function toJSON(obj) { @@ -60,12 +60,9 @@ function createDefaultOvermind() { effects, } - type Config = { - state: typeof state - actions: typeof actions - effects: typeof effects - } - type Action = TAction + type Config = typeof config + + interface Action extends IAction {} const app = new Overmind(config) diff --git a/packages/node_modules/overmind/src/index.ts b/packages/node_modules/overmind/src/index.ts index ddc721a4..02e908b8 100644 --- a/packages/node_modules/overmind/src/index.ts +++ b/packages/node_modules/overmind/src/index.ts @@ -23,12 +23,11 @@ import { import { proxifyEffects } from './proxyfyEffects' import { Configuration, - TAction, - TConfig, - TDerive, - TOperator, + IAction, + IDerive, + IOperator, TValueContext, - TOnInitialize, + IOnInitialize, TStateObject, } from './types' @@ -38,19 +37,14 @@ export * from './types' * typing and then they can import `Action`, `Operation` etc. directly from * overmind. */ -export interface IConfig {} +export interface Config {} -type TheConfig = IConfig & TConfig<{ actions: {} }> +export interface Action extends IAction {} -export type Action = TAction +export interface Derive + extends IDerive {} -export type Derive = TDerive< - TheConfig, - Parent, - Value -> - -export type OnInitialize = TOnInitialize +export interface OnInitialize extends IOnInitialize {} const IS_PRODUCTION = process.env.NODE_ENV === 'production' const IS_DEVELOPMENT = process.env.NODE_ENV === 'development' @@ -302,6 +296,7 @@ export class Overmind implements Configuration { { value, state: tree.state, + actions: this.actions, execution, proxyStateTree: this.proxyStateTree, }, @@ -610,50 +605,50 @@ export class Overmind implements Configuration { OPERATORS needs to be in this file for typing override to work */ -export type Operator = TOperator< - TheConfig, +export type Operator = IOperator< + Config, Input, Output > export function pipe( - aOperator: TOperator -): TOperator + aOperator: IOperator +): IOperator export function pipe( - aOperator: TOperator, - bOperator: TOperator -): TOperator + aOperator: IOperator, + bOperator: IOperator +): IOperator export function pipe( - aOperator: TOperator, - bOperator: TOperator, - cOperator: TOperator -): TOperator + aOperator: IOperator, + bOperator: IOperator, + cOperator: IOperator +): IOperator export function pipe( - aOperator: TOperator, - bOperator: TOperator, - cOperator: TOperator, - dOperator: TOperator -): TOperator + aOperator: IOperator, + bOperator: IOperator, + cOperator: IOperator, + dOperator: IOperator +): IOperator export function pipe( - aOperator: TOperator, - bOperator: TOperator, - cOperator: TOperator, - dOperator: TOperator, - eOperator: TOperator -): TOperator + aOperator: IOperator, + bOperator: IOperator, + cOperator: IOperator, + dOperator: IOperator, + eOperator: IOperator +): IOperator export function pipe( - aOperator: TOperator, - bOperator: TOperator, - cOperator: TOperator, - dOperator: TOperator, - eOperator: TOperator, - fOperator: TOperator -): TOperator + aOperator: IOperator, + bOperator: IOperator, + cOperator: IOperator, + dOperator: IOperator, + eOperator: IOperator, + fOperator: IOperator +): IOperator export function pipe(...operators) { const instance = (err, context, next, final = next) => { @@ -675,12 +670,12 @@ export function pipe(...operators) { operators[operatorIndex++]( runErr, runContext, - runNextOperator, + runNexIOperator, finalClearingAsync ) } - const runNextOperator = (operatorError, operatorContext) => { + const runNexIOperator = (operatorError, operatorContext) => { clearTimeout(asyncTimeout) if (operatorError) return next(operatorError) if (operatorIndex >= operators.length) @@ -705,7 +700,7 @@ export function pipe(...operators) { } } - runNextOperator(null, context) + runNexIOperator(null, context) } } instance[IS_OPERATOR] = true @@ -797,9 +792,9 @@ function createNextPath(next) { } } -export function map( +export function map( operation: (input: TValueContext) => Output -): TOperator ? U : Output> { +): IOperator ? U : Output> { const instance = (err, context, next) => { if (err) next(err) else { @@ -816,10 +811,10 @@ export function map( export function forEach< Input extends any[], - Config extends Configuration = TheConfig + Config extends Configuration = Config >( - forEachItemOperator: TOperator -): TOperator { + forEachItemOperator: IOperator +): IOperator { const instance = (err, context, next) => { if (err) next(err) else { @@ -860,9 +855,9 @@ export function forEach< return instance } -export function parallel( - ...operators: TOperator[] -): TOperator { +export function parallel( + ...operators: IOperator[] +): IOperator { const instance = (err, context, next) => { if (err) next(err) else { @@ -902,9 +897,9 @@ export function parallel( return instance } -export function filter( +export function filter( operation: (input: TValueContext) => boolean -): TOperator { +): IOperator { const instance = (err, context, next, final) => { if (err) next(err) else { @@ -923,9 +918,9 @@ export function filter( return instance } -export function action( +export function action( operation: (input: TValueContext) => void -): TOperator { +): IOperator { const instance = (err, context, next) => { if (err) next(err) else { @@ -978,12 +973,12 @@ export function action( export function fork< Input, - Paths extends { [key: string]: TOperator }, - Config extends Configuration = TheConfig + Paths extends { [key: string]: IOperator }, + Config extends Configuration = Config >( operation: (input: TValueContext) => keyof Paths, paths: Paths -): TOperator { +): IOperator { const instance = (err, context, next) => { if (err) next(err) else { @@ -1013,14 +1008,14 @@ export function when< Input, OutputA, OutputB, - Config extends Configuration = TheConfig + Config extends Configuration = Config >( operation: (input: TValueContext) => boolean, paths: { - true: TOperator - false: TOperator + true: IOperator + false: IOperator } -): TOperator { +): IOperator { const instance = (err, context, next) => { if (err) next(err) else { @@ -1051,9 +1046,9 @@ export function when< return instance } -export function wait( +export function wait( ms: number -): TOperator { +): IOperator { const instance = (err, context, next) => { if (err) next(err) else { @@ -1069,9 +1064,9 @@ export function wait( return instance } -export function debounce( +export function debounce( ms: number -): TOperator { +): IOperator { let timeout let previousFinal const instance = (err, context, next, final) => { diff --git a/packages/node_modules/overmind/src/internalTypes.ts b/packages/node_modules/overmind/src/internalTypes.ts index 9a668a91..e8a74b17 100644 --- a/packages/node_modules/overmind/src/internalTypes.ts +++ b/packages/node_modules/overmind/src/internalTypes.ts @@ -1,5 +1,5 @@ import { IMutation, IMutationTree } from 'proxy-state-tree' -import { Configuration, TAction, TOperator, TStateObject } from './types' +import { Configuration, IAction, IOperator, TStateObject } from './types' export type SubType = Pick< Base, @@ -139,6 +139,7 @@ export interface Events { export type TBaseContext = Config['effects'] & { state: ResolveState + actions: ResolveActions execution: any } @@ -171,8 +172,8 @@ type TOperationValue = T extends ( type NestedActions = | { [key: string]: - | TAction - | TOperator + | IAction + | IOperator | NestedActions } | undefined @@ -182,11 +183,11 @@ export type ResolveActions< > = Actions extends undefined ? {} : { - [T in keyof Actions]: Actions[T] extends TAction + [T in keyof Actions]: Actions[T] extends IAction ? [TActionValue] extends [void] ? () => Promise : (value: TActionValue) => Promise - : Actions[T] extends TOperator + : Actions[T] extends IOperator ? [TOperationValue] extends [void] ? () => Promise : (value: TOperationValue) => Promise @@ -198,8 +199,8 @@ export type ResolveActions< type NestedMockActions = | { [key: string]: - | TAction - | TOperator + | IAction + | IOperator | NestedMockActions } | undefined @@ -211,11 +212,11 @@ export type ResolveMockActions< > = Actions extends undefined ? {} : { - [T in keyof Actions]: Actions[T] extends TAction + [T in keyof Actions]: Actions[T] extends IAction ? [TActionValue] extends [void] ? () => Promise : (value: TActionValue) => Promise - : Actions[T] extends TOperator + : Actions[T] extends IOperator ? [TOperationValue] extends [void] ? () => Promise : (value: TOperationValue) => Promise diff --git a/packages/node_modules/overmind/src/mock.test.ts b/packages/node_modules/overmind/src/mock.test.ts index 13a585db..6a15c8d3 100644 --- a/packages/node_modules/overmind/src/mock.test.ts +++ b/packages/node_modules/overmind/src/mock.test.ts @@ -1,4 +1,4 @@ -import { createMock, TAction } from './' +import { createMock, IAction } from './' type State = { foo: string @@ -13,7 +13,7 @@ describe('Mock', () => { const state: State = { foo: 'bar', } - const test: Action = ({ state, effect }) => { + const test: Action = ({ state, effect, actions }) => { state.foo = effect() } const actions = { test } @@ -25,13 +25,9 @@ describe('Mock', () => { effects, } - type Config = { - state: typeof state - actions: typeof actions - effects: typeof effects - } + type Config = typeof config - type Action = TAction + interface Action extends IAction {} const mock = createMock(config, { effect() { diff --git a/packages/node_modules/overmind/src/types.ts b/packages/node_modules/overmind/src/types.ts index 5e8a2b3c..c8b8016f 100644 --- a/packages/node_modules/overmind/src/types.ts +++ b/packages/node_modules/overmind/src/types.ts @@ -23,14 +23,14 @@ export type TStateObject = [key: string]: | TStateObject | string - | TDerive + | IDerive | number | boolean | object } | undefined -export interface TConfig { +export interface IConfig { state: Config['state'] actions: Config['actions'] effects: Config['effects'] & {} @@ -41,11 +41,7 @@ export type TApp = { // Resolves `Derive` types in state. state: ResolveState actions: ResolveActions - reaction: ( - name: string, - stateCb: (state: TApp['state']) => any, - Function - ) => void + effects: Config['effects'] } // This is the type of the argument passed in actions. @@ -55,18 +51,18 @@ export type TValueContext = TBaseContext< value: Value } -export type TAction = ( - context: TValueContext -) => any +export interface IAction { + (context: TValueContext): any +} -export type TOperator = ( +export type IOperator = ( err: Error | null, val: TValueContext, next: (err: Error | null, val?: TValueContext) => void, final?: (err, Error, val?: TValueContext) => void ) => void -export type TDerive< +export type IDerive< Config extends Configuration, Parent extends TStateObject, Value @@ -75,6 +71,6 @@ export type TDerive< state: ResolveState ) => Value -export type TOnInitialize = ( - context: TValueContext> -) => void +export interface IOnInitialize { + (context: TValueContext>): void +} diff --git a/packages/overmind-website/examples/api/config_lazy.ts b/packages/overmind-website/examples/api/config_lazy.ts index dd4e8310..486c3796 100644 --- a/packages/overmind-website/examples/api/config_lazy.ts +++ b/packages/overmind-website/examples/api/config_lazy.ts @@ -4,7 +4,7 @@ export default (ts) => { fileName: 'overmind.ts', code: ` -import { Overmind, TConfig } from 'overmind' +import { Overmind, IConfig } from 'overmind' import { lazy } from 'overmind/config' import { Config as ModuleAConfig } from './moduleA' import { Config as ModuleBConfig } from './moduleB' @@ -15,7 +15,7 @@ const config = lazy({ }) declare module 'overmind' { - interface IConfig extends TConfig {} + interface Config extends IConfig {} } const overmind = new Overmind(config) diff --git a/packages/overmind-website/examples/api/config_merge.ts b/packages/overmind-website/examples/api/config_merge.ts index 6c0b5a6d..bd182925 100644 --- a/packages/overmind-website/examples/api/config_merge.ts +++ b/packages/overmind-website/examples/api/config_merge.ts @@ -4,7 +4,7 @@ export default (ts) => { fileName: 'overmind.ts', code: ` -import { Overmind, TConfig } from 'overmind' +import { Overmind, IConfig } from 'overmind' import { merge } from 'overmind/config' import * as moduleA from './moduleA' import * as moduleB from './moduleB' @@ -12,7 +12,7 @@ import * as moduleB from './moduleB' const config = merge(moduleA, moduleB) declare module 'overmind' { - interface IConfig extends TConfig {} + interface Config extends IConfig {} } export default new Overmind(config) diff --git a/packages/overmind-website/examples/api/config_namespaced.ts b/packages/overmind-website/examples/api/config_namespaced.ts index cc19abbe..a4d26a11 100644 --- a/packages/overmind-website/examples/api/config_namespaced.ts +++ b/packages/overmind-website/examples/api/config_namespaced.ts @@ -4,7 +4,7 @@ export default (ts) => { fileName: 'overmind.ts', code: ` -import { Overmind, TConfig } from 'overmind' +import { Overmind, IConfig } from 'overmind' import { namespaced } from 'overmind/config' import * as moduleA from './moduleA' import * as moduleB from './moduleB' @@ -15,7 +15,7 @@ const config = namespaced({ }) declare module 'overmind' { - interface IConfig extends TConfig {} + interface Config extends IConfig {} } const overmind = new Overmind(config) diff --git a/packages/overmind-website/examples/api/connect.ts b/packages/overmind-website/examples/api/connect.ts index 5acd55c3..0a317c84 100644 --- a/packages/overmind-website/examples/api/connect.ts +++ b/packages/overmind-website/examples/api/connect.ts @@ -46,7 +46,7 @@ const typescript = { import * as React from 'react' import { connect, Connect } from '../overmind' -const SomeComponent: React.SFC = ({ overmind }) => { +const SomeComponent: React.FunctionComponent = ({ overmind }) => { return (
{overmind.state.foo} diff --git a/packages/overmind-website/examples/guide/connectingcomponents/actions.ts b/packages/overmind-website/examples/guide/connectingcomponents/actions.ts index d053a153..140aa0ff 100644 --- a/packages/overmind-website/examples/guide/connectingcomponents/actions.ts +++ b/packages/overmind-website/examples/guide/connectingcomponents/actions.ts @@ -69,7 +69,7 @@ export const toggleAwesomeApp: Action = ({ state }) => import * as React from 'react' import { Connect, connect } from '../overmind' -const App: React.SFC = ({ overmind }) => ( +const App: React.FunctionComponent = ({ overmind }) => ( diff --git a/packages/overmind-website/examples/guide/connectingcomponents/array_1.ts b/packages/overmind-website/examples/guide/connectingcomponents/array_1.ts index f255598c..15ba03c9 100644 --- a/packages/overmind-website/examples/guide/connectingcomponents/array_1.ts +++ b/packages/overmind-website/examples/guide/connectingcomponents/array_1.ts @@ -42,7 +42,7 @@ const typescript = { import * as React from 'react' import { connect, Connect } from '../overmind' -const List: React.SFC = ({ overmind }) => ( +const List: React.FunctionComponent = ({ overmind }) => (

{overmind.state.items}

) diff --git a/packages/overmind-website/examples/guide/connectingcomponents/array_2.ts b/packages/overmind-website/examples/guide/connectingcomponents/array_2.ts index 62b41993..8329961a 100644 --- a/packages/overmind-website/examples/guide/connectingcomponents/array_2.ts +++ b/packages/overmind-website/examples/guide/connectingcomponents/array_2.ts @@ -50,7 +50,7 @@ const typescript = { import * as React from 'react' import { connect, Connect } from '../overmind' -const List: React.SFC = ({ overmind }) => ( +const List: React.FunctionComponent = ({ overmind }) => (