Skip to content

Commit df096d1

Browse files
committed
fix: incorrect typings for ViewModelsProvider component
1 parent b2bbe61 commit df096d1

File tree

11 files changed

+34
-22
lines changed

11 files changed

+34
-22
lines changed

.changeset/icy-radios-wear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"mobx-view-model": patch
3+
---
4+
5+
fixed incorrect typings for `ViewModelsProvider` component

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './only-view-model.js';
2+
export * from './view-models-provider.js';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { ComponentType, ReactNode } from 'react';
2+
import { ViewModelsContext } from '../contexts/index.js';
3+
import type { ViewModelStore } from '../view-model/index.js';
4+
5+
export const ViewModelsProvider =
6+
ViewModelsContext.Provider as unknown as ComponentType<{
7+
value: ViewModelStore;
8+
children?: ReactNode;
9+
}>;

src/config/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import type { ComponentType } from 'react';
22
import type { AnyObject, Class, DeepPartial, Maybe } from 'yummies/utils/types';
33

44
import type { ViewModelHocConfig } from '../hoc/with-view-model.js';
5-
import type { ViewModelCreateConfig } from '../view-model/view-model.store.types.js';
65
import type {
76
AnyViewModel,
87
PayloadCompareFn,
9-
} from '../view-model/view-model.types.js';
8+
ViewModelCreateConfig,
9+
} from '../view-model/index.js';
1010

1111
import type { ObservableAnnotationsArray } from './utils/apply-observable.js';
1212

src/hoc/with-lazy-view-model.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from 'react-simple-loadable';
77
import { type PackedAsyncModule, unpackAsyncModule } from 'yummies/imports';
88
import type { Class, Maybe, MaybePromise } from 'yummies/utils/types';
9-
import { viewModelsConfig } from '../config/global-config.js';
9+
import { viewModelsConfig } from '../config/index.js';
1010
import type { AnyViewModel, AnyViewModelSimple } from '../view-model/index.js';
1111

1212
import {

src/hoc/with-view-model.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import type {
1212
IsPartial,
1313
Maybe,
1414
} from 'yummies/utils/types';
15-
import { viewModelsConfig } from '../config/global-config.js';
15+
import { viewModelsConfig } from '../config/index.js';
1616
import {
1717
ActiveViewModelContext,
1818
ViewModelsContext,
1919
} from '../contexts/index.js';
2020
import {
2121
type UseCreateViewModelConfig,
2222
useCreateViewModel,
23-
} from '../hooks/use-create-view-model.js';
23+
} from '../hooks/index.js';
2424
import type {
2525
AnyViewModel,
2626
AnyViewModelSimple,

src/hooks/use-create-view-model.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { useContext, useLayoutEffect } from 'react';
22
import type { Class, IsPartial, Maybe } from 'yummies/utils/types';
3-
4-
import { viewModelsConfig } from '../config/global-config.js';
53
import type {
64
CreateViewModelFactoryFn,
75
GenerateViewModelIdFn,
86
} from '../config/index.js';
9-
import { ActiveViewModelContext } from '../contexts/active-view-context.js';
10-
import { ViewModelsContext } from '../contexts/view-models-context.js';
11-
import { useIsomorphicLayoutEffect } from '../lib/hooks/use-isomorphic-layout-effect.js';
12-
import { useValue } from '../lib/hooks/use-value.js';
13-
import { isViewModelClass } from '../utils/typeguards.js';
14-
import type { ViewModelCreateConfig } from '../view-model/view-model.store.types.js';
7+
import { viewModelsConfig } from '../config/index.js';
8+
import {
9+
ActiveViewModelContext,
10+
ViewModelsContext,
11+
} from '../contexts/index.js';
12+
import { useIsomorphicLayoutEffect, useValue } from '../lib/hooks/index.js';
13+
import { isViewModelClass } from '../utils/index.js';
1514
import type {
1615
AnyViewModel,
1716
AnyViewModelSimple,
18-
} from '../view-model/view-model.types.js';
19-
import type { ViewModelSimple } from '../view-model/view-model-simple.js';
17+
ViewModelCreateConfig,
18+
ViewModelSimple,
19+
} from '../view-model/index.js';
2020

2121
export interface UseCreateViewModelConfig<TViewModel extends AnyViewModel>
2222
extends Pick<

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import { ViewModelsContext } from './contexts/index.js';
2-
31
export * from './components/index.js';
42
export * from './config/index.js';
53
export * from './hoc/index.js';
64
export * from './hooks/index.js';
75
export * from './utils/index.js';
86
export * from './view-model/index.js';
9-
10-
export const ViewModelsProvider = ViewModelsContext.Provider;

src/lib/hooks/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './use-isomorphic-layout-effect.js';
2+
export * from './use-value.js';

src/utils/typeguards.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AnyObject, Class, EmptyObject } from 'yummies/utils/types';
2-
import type { ViewModel } from '../view-model/view-model.js';
2+
import type { ViewModel } from '../view-model/index.js';
33

44
export const isViewModel = <TPayload extends AnyObject = EmptyObject>(
55
value: AnyObject,

0 commit comments

Comments
 (0)