diff --git a/.changeset/polite-meals-drop.md b/.changeset/polite-meals-drop.md new file mode 100644 index 000000000..90471514e --- /dev/null +++ b/.changeset/polite-meals-drop.md @@ -0,0 +1,5 @@ +--- +"mobx-react": minor +--- + +Make mobx-react compatible with TS 4.8+ diff --git a/packages/mobx-react/__tests__/context.test.tsx b/packages/mobx-react/__tests__/context.test.tsx index 5a0ae7fb2..e88dbda85 100644 --- a/packages/mobx-react/__tests__/context.test.tsx +++ b/packages/mobx-react/__tests__/context.test.tsx @@ -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 } diff --git a/packages/mobx-react/__tests__/observer.test.tsx b/packages/mobx-react/__tests__/observer.test.tsx index e7c995267..b4b0285d3 100644 --- a/packages/mobx-react/__tests__/observer.test.tsx +++ b/packages/mobx-react/__tests__/observer.test.tsx @@ -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() { diff --git a/packages/mobx-react/src/inject.ts b/packages/mobx-react/src/inject.ts index d46977998..88e0f3341 100644 --- a/packages/mobx-react/src/inject.ts +++ b/packages/mobx-react/src/inject.ts @@ -80,7 +80,7 @@ export function inject( ): >( target: T ) => T & (T extends IReactComponent ? IWrappedComponent

: never) -export function inject( +export function inject( fn: IStoresToProps ): (target: T) => T & IWrappedComponent