Skip to content

Commit ee7bed7

Browse files
Merge pull request cerebral#116 from cerebral/context
simplify types
2 parents 825c67f + c7793fb commit ee7bed7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+573
-613
lines changed

packages/demos/react-todomvc/src/app/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import App from 'overmind'
1+
import Overmind from 'overmind'
22
import createConnect from 'overmind-react'
33
import * as effects from './effects'
44
import * as actions from './actions'
55
import * as state from './state'
66

7-
const app = new App({
7+
const app = new Overmind({
88
state,
99
actions,
1010
effects,

packages/demos/react-typescript-todomvc/src/app/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as React from 'react'
22
import { Action } from 'overmind'
3-
import { Todo } from './state'
4-
import * as operations from './operations'
53
import * as mutations from './mutations'
4+
import * as operations from './operations'
5+
import { Todo } from './state'
66

77
type ChangeEvent = React.ChangeEvent<HTMLInputElement>
88

9-
export const changeNewTodoTitle: Action<ChangeEvent> = (action) =>
9+
export const changeNewTodoTitle: Action<ChangeEvent, string> = (action) =>
1010
action.map(operations.getEventValue).mutate(mutations.setNewTodoTitle)
1111

1212
export const addTodo: Action<React.FormEvent> = (action) =>
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import App from 'overmind'
2-
import createConnect, { TConnect } from 'overmind-react'
3-
import * as effects from './effects'
1+
import { Overmind, TApp } from 'overmind'
2+
import { TConnect, createConnect } from 'overmind-react'
3+
44
import * as actions from './actions'
5+
import * as effects from './effects'
56
import * as state from './state'
67

78
const config = {
@@ -11,14 +12,11 @@ const config = {
1112
}
1213

1314
declare module 'overmind' {
14-
interface IState extends TState<typeof config> {}
15-
interface IEffects extends TEffects<typeof config> {}
15+
interface App extends TApp<typeof config> {}
1616
}
1717

18-
const app = new App(config)
18+
export const app = new Overmind(config)
1919

2020
export type Connect = TConnect<typeof app>
2121

2222
export const connect = createConnect(app)
23-
24-
export default app
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { Mutate } from 'overmind'
1+
import { Operation } from 'overmind'
22
import { Todo } from './state'
33

44
let nextTodoId = 0
55

6-
export const setNewTodoTitle: Mutate<string> = ({ state, value }) =>
6+
export const setNewTodoTitle: Operation.Mutate<string> = ({ state, value }) =>
77
(state.newTodoTitle = value)
88

9-
export const addTodo: Mutate = ({ state }) =>
9+
export const addTodo: Operation.Mutate = ({ state }) =>
1010
state.todos.unshift({
1111
id: String(nextTodoId++),
1212
title: state.newTodoTitle,
1313
completed: false,
1414
})
1515

16-
export const clearNewTodoTitle: Mutate = ({ state }) =>
16+
export const clearNewTodoTitle: Operation.Mutate = ({ state }) =>
1717
(state.newTodoTitle = '')
1818

19-
export const toggleCompleted: Mutate<Todo> = ({ value: todo }) =>
19+
export const toggleCompleted: Operation.Mutate<Todo> = ({ value: todo }) =>
2020
(todo.completed = !todo.completed)

packages/demos/vue-todomvc/src/app/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import App from 'overmind'
1+
import Overmind from 'overmind'
22
import createConnect from 'overmind-vue'
33
import * as effects from './effects'
44
import * as actions from './actions'
55
import * as state from './state'
66

7-
const app = new App(
7+
const app = new Overmind(
88
{
99
state,
1010
actions,

packages/node_modules/action-chain/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"sourceMap": true,
1414
"inlineSources": true
1515
},
16-
"exclude": ["node_modules", "dist", "es", "lib"]
16+
"exclude": ["node_modules", "dist", "es", "lib", "src/**/*.test.ts"]
1717
}

packages/node_modules/betsy/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"sourceMap": true,
1414
"inlineSources": true
1515
},
16-
"exclude": ["node_modules", "dist", "es", "lib"]
16+
"exclude": ["node_modules", "dist", "es", "lib", "src/**/*.test.ts"]
1717
}

packages/node_modules/overmind-angular/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import OvermindApp, { EventType } from 'overmind'
1+
import { BaseApp, EventType, Overmind } from 'overmind'
22

3-
export type TConnect<App extends OvermindApp<any, any>> = {
3+
export type TConnect<App extends BaseApp> = {
44
app: {
55
state: App['state']
66
actions: App['actions']
@@ -14,7 +14,7 @@ export type TConnect<App extends OvermindApp<any, any>> = {
1414

1515
let nextComponentId = 0
1616

17-
export default <App extends OvermindApp<any, any>>(app: App) => () => {
17+
export const createConnect = <App extends Overmind<any>>(app: App) => () => {
1818
const componentId = nextComponentId++
1919
let componentInstanceId = 0
2020

packages/node_modules/overmind-angular/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"sourceMap": true,
1515
"inlineSources": true
1616
},
17-
"exclude": ["node_modules", "dist", "es", "lib"]
17+
"exclude": ["node_modules", "dist", "es", "lib", "src/**/*.test.ts"]
1818
}

packages/node_modules/overmind-devtools/src/BackendConnector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ipcRenderer } from 'electron'
2+
23
import { AppMessage } from './app/types'
34

45
type Message = {
@@ -8,7 +9,7 @@ type Message = {
89

910
type MessageCallback = (message: Message) => void
1011

11-
class BackendConnector {
12+
export class BackendConnector {
1213
port: string
1314
messageCallback: MessageCallback
1415
constructor() {

0 commit comments

Comments
 (0)