Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make mobx-react compatible with TS 4.8+ #3565

Merged
merged 6 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-meals-drop.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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