Skip to content

Commit 30db239

Browse files
committed
fix(overmind): add strictNullChecks and fix code with this setting
1 parent 7784d03 commit 30db239

File tree

13 files changed

+104
-327
lines changed

13 files changed

+104
-327
lines changed

package-lock.json

Lines changed: 62 additions & 293 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@
7979
"jsdom": "11.12.0",
8080
"lint-staged": "^7.2.0",
8181
"parcel-bundler": "1.9.7",
82-
"prettier": "1.13.7",
82+
"prettier": "1.15.2",
8383
"raw-loader": "0.5.1",
8484
"react-test-renderer": "16.4.1",
8585
"repo-cooker": "^6.2.7",
8686
"rimraf": "2.6.2",
8787
"source-map-loader": "0.2.4",
88-
"ts-jest": "23.0.0",
88+
"ts-jest": "23.10.4",
8989
"ts-loader": "4.4.2",
9090
"tslib": "1.9.3",
91-
"typescript": "2.9.2",
92-
"typescript-eslint-parser": "^18.0.0",
91+
"typescript": "3.1.3",
92+
"typescript-eslint-parser": "^21.0.1",
9393
"url-loader": "1.0.1",
9494
"vue": "2.5.16",
9595
"vue-template-compiler": "2.5.16",

packages/node_modules/action-chain/src/ActionChain.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export class ActionChain<Effects, ExtraEvents = {}> extends EventEmitter<
1919
return proxifyEffects(
2020
this.effects,
2121
this.options.providerExceptions,
22-
(effect) => this.emitAsync('effect', { ...thisExecution, ...effect })
22+
(effect) =>
23+
this.emitAsync('effect', { ...thisExecution, ...effect } as any)
2324
)
2425
}
2526

packages/node_modules/overmind-react/src/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('React', () => {
111111
}
112112
const ConnectedComponent = connect(Component)
113113
const tree = renderer.create(<ConnectedComponent />).toJSON()
114-
const tree2 = renderer.create(<Component app={null} />).toJSON()
114+
const tree2 = renderer.create(<Component app={null as any} />).toJSON()
115115

116116
expect(tree).toMatchSnapshot()
117117
expect(tree2).toMatchSnapshot()

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import { BaseApp, EventType, Overmind, Configuration } from 'overmind'
2-
import * as React from 'react'
1+
import { BaseApp, Configuration, EventType, Overmind } from 'overmind'
32
import {
3+
// @ts-ignore
4+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
5+
ClassicComponentClass,
6+
ComponentClass,
7+
createElement,
8+
PureComponent,
9+
StatelessComponent,
410
// @ts-ignore
511
useEffect,
612
// @ts-ignore
713
useState,
8-
// @ts-ignore
9-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1014
} from 'react'
1115

1216
export type IReactComponent<P = any> =
13-
| React.StatelessComponent<P>
14-
| React.ComponentClass<P>
15-
| React.ClassicComponentClass<P>
17+
| StatelessComponent<P>
18+
| ComponentClass<P>
19+
| ClassicComponentClass<P>
1620

1721
// Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
1822
type Omit<T, K extends keyof T> = Pick<
@@ -182,15 +186,15 @@ export const createConnect = <App extends Overmind<Configuration>>(
182186
}
183187
}
184188

185-
const klass = class extends React.PureComponent<
189+
const klass = class extends PureComponent<
186190
Omit<Props & TConnect<App>, keyof TConnect<App>>
187191
> {
188192
__mutationListener: any
189193
__isUnmounting: boolean
190194
__componentId: number
191195
__componentInstanceId = componentInstanceId++
192196
__reactionFactory = app.createReactionFactory(
193-
Component.name || Component.displayName
197+
Component.name || Component.displayName || 'Component'
194198
)
195199
componentWillUnmount() {
196200
this.__isUnmounting = true
@@ -255,7 +259,7 @@ export const createConnect = <App extends Overmind<Configuration>>(
255259
return value
256260
}
257261
renderClassComponent() {
258-
return React.createElement(Component, Object.assign({}, this.props, {
262+
return createElement(Component, Object.assign({}, this.props, {
259263
app: {
260264
state: app.state,
261265
actions: app.actions,

packages/node_modules/overmind-react/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"newLine": "LF",
99
"lib": ["dom", "es2017"],
1010
"moduleResolution": "node",
11+
"strictNullChecks": true,
1112
"importHelpers": true,
1213
"declaration": true,
1314
"pretty": true,

packages/node_modules/overmind/src/Devtools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function debounce(func, wait) {
4848

4949
export class Devtools {
5050
private buffer: string[] = []
51-
private ws: WebSocket = null
51+
private ws: WebSocket
5252
private isConnected: boolean = false
5353
private doReconnect: boolean = false
5454
private hasWarnedReconnect: boolean = false

packages/node_modules/overmind/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ describe('Overmind', () => {
287287
expect(typeof app.actions.bar.bar).toBe('function')
288288
})
289289
test('should instantiate modules with onInitialize', () => {
290-
const result = []
290+
const result: string[] = []
291291
const app = new Overmind(
292292
modules({
293293
foo: {

packages/node_modules/overmind/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class Overmind<Config extends Configuration> implements BaseApp {
6262
initialized: Promise<any>
6363
eventHub: EventEmitter<Events>
6464
devtools: Devtools
65-
actions: ResolveActions<Config['actions']>
65+
actions: ResolveActions<Config['actions'] & {}>
6666
state: ResolveState<Config['state'] & {}>
6767
effects: Config['effects'] & {}
6868
constructor(configuration: Config, options: Options = {}) {
@@ -224,7 +224,6 @@ export class Overmind<Config extends Configuration> implements BaseApp {
224224
this.eventHub.emit(EventType.OPERATOR_START, {
225225
...execution,
226226
operatorId: 0,
227-
name: undefined,
228227
type: 'action',
229228
})
230229
const scopedTree = this.proxyStateTree.getScopedTree()
@@ -439,7 +438,7 @@ export class Overmind<Config extends Configuration> implements BaseApp {
439438
return this.proxyStateTree.addFlushListener(paths, cb)
440439
}
441440
createReactionFactory(prefix: string) {
442-
const reactions = []
441+
const reactions: Reaction[] = []
443442
const instance = this
444443
return {
445444
add(

packages/node_modules/overmind/src/internalTypes.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface Events {
4646
[EventType.OPERATOR_START]: Execution & {
4747
path: string[]
4848
type: string
49-
name: string
49+
name?: string
5050
}
5151
[EventType.OPERATOR_END]: Execution & {
5252
path: string[]
@@ -119,8 +119,10 @@ export type ResolveState<State extends object> = {
119119
[P in keyof State]: State[P] extends TDerive<any, any>
120120
? ReturnType<State[P]>
121121
: State[P] extends Array<any>
122-
? State[P]
123-
: State[P] extends object ? ResolveState<State[P]> : State[P]
122+
? State[P]
123+
: State[P] extends object
124+
? ResolveState<State[P]>
125+
: State[P]
124126
}
125127

126128
type TActionValue<T> = T extends (a1: infer TContext) => any
@@ -147,10 +149,10 @@ export type ResolveActions<Actions extends NestedActions> = {
147149
? () => Promise<ReturnType<Actions[T]>>
148150
: (value: TActionValue<Actions[T]>) => Promise<ReturnType<Actions[T]>>
149151
: Actions[T] extends TOperator<any, any>
150-
? [TOperationValue<Actions[T]>] extends [void]
151-
? () => Promise<ReturnType<Actions[T]>>
152-
: (
153-
value: TOperationValue<Actions[T]>
154-
) => Promise<ReturnType<Actions[T]>>
155-
: Actions[T] extends NestedActions ? ResolveActions<Actions[T]> : never
152+
? [TOperationValue<Actions[T]>] extends [void]
153+
? () => Promise<ReturnType<Actions[T]>>
154+
: (value: TOperationValue<Actions[T]>) => Promise<ReturnType<Actions[T]>>
155+
: Actions[T] extends NestedActions
156+
? ResolveActions<Actions[T]>
157+
: never
156158
}

0 commit comments

Comments
 (0)