Skip to content

Commit

Permalink
Make mobx-react compatible with TS 4.8+ (#3565)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Nov 14, 2022
1 parent fe25cfe commit 7aab223
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-meals-drop.md
@@ -0,0 +1,5 @@
---
"mobx-react": minor
---

Make mobx-react compatible with TS 4.8+
2 changes: 1 addition & 1 deletion packages/mobx-react/__tests__/context.test.tsx
Expand Up @@ -71,7 +71,7 @@ test("getDerivedStateFromProps works #447", () => {
}
}

const MainInjected = inject(({ store }) => ({ thing: store.thing }))(Main)
const MainInjected = inject(({ store }: { store: { thing: number } }) => ({ thing: store.thing }))(Main)

const store = { thing: 3 }

Expand Down
2 changes: 1 addition & 1 deletion packages/mobx-react/__tests__/observer.test.tsx
Expand Up @@ -326,7 +326,7 @@ test("observer component can be injected", () => {
)

// N.B, the injected component will be observer since mobx-react 4.0!
inject(() => {})(
inject(() => ({}))(
observer(
class T extends React.Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion packages/mobx-react/src/inject.ts
Expand Up @@ -80,7 +80,7 @@ export function inject(
): <T extends IReactComponent<any>>(
target: T
) => T & (T extends IReactComponent<infer P> ? IWrappedComponent<P> : never)
export function inject<S, P, I, C>(
export function inject<S extends IValueMap = {}, P extends IValueMap = {}, I extends IValueMap = {}, C extends IValueMap = {}>(
fn: IStoresToProps<S, P, I, C>
): <T extends IReactComponent>(target: T) => T & IWrappedComponent<P>

Expand Down

0 comments on commit 7aab223

Please sign in to comment.