Skip to content

Commit 6d8b63e

Browse files
authored
Use type imports in Core and React
Use type imports in selected files of the core and react packages. This helps to avoid circular imports and aids in custom webpack scenarios.
1 parent 901b2a6 commit 6d8b63e

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

packages/core/src/reducers/reducers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import {
3232
import { defaultDataReducer } from './default-data';
3333
import { rendererReducer } from './renderers';
3434
import { JsonFormsState } from '../store';
35+
import type { JsonFormsUISchemaRegistryEntry } from './uischemas';
3536
import {
3637
findMatchingUISchema,
37-
JsonFormsUISchemaRegistryEntry,
3838
uischemaRegistryReducer,
3939
} from './uischemas';
4040
import {
@@ -59,7 +59,7 @@ export const jsonFormsReducerConfig = {
5959
config: configReducer,
6060
uischemas: uischemaRegistryReducer,
6161
defaultData: defaultDataReducer,
62-
i18n: i18nReducer
62+
i18n: i18nReducer,
6363
};
6464

6565
/**

packages/core/src/util/cell.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
import isEmpty from 'lodash/isEmpty';
2727
import union from 'lodash/union';
28+
import type { JsonFormsCellRendererRegistryEntry } from '../reducers';
2829
import {
30+
getAjv,
2931
getConfig,
3032
getData,
3133
getErrorAt,
3234
getSchema,
33-
getAjv,
34-
JsonFormsCellRendererRegistryEntry,
35-
getTranslator
35+
getTranslator,
3636
} from '../reducers';
3737
import { AnyAction, Dispatch } from './type';
3838
import {
@@ -57,7 +57,7 @@ import { JsonFormsState } from '../store';
5757
import { JsonSchema } from '../models';
5858
import { getI18nKeyPrefix } from '../i18n';
5959

60-
export { JsonFormsCellRendererRegistryEntry };
60+
export type { JsonFormsCellRendererRegistryEntry };
6161

6262
export interface OwnPropsOfCell extends OwnPropsOfControl {
6363
data?: any;

packages/core/src/util/renderer.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
import get from 'lodash/get';
2727
import { ControlElement, JsonSchema, UISchemaElement } from '../models';
2828
import find from 'lodash/find';
29+
import type {
30+
JsonFormsCellRendererRegistryEntry,
31+
JsonFormsRendererRegistryEntry,
32+
} from '../reducers';
2933
import {
3034
findUISchema,
3135
getAjv,
@@ -39,19 +43,16 @@ import {
3943
getSubErrorsAt,
4044
getTranslator,
4145
getUiSchema,
42-
JsonFormsCellRendererRegistryEntry,
43-
JsonFormsRendererRegistryEntry,
4446
JsonFormsUISchemaRegistryEntry,
4547
} from '../reducers';
4648
import { RankedTester } from '../testers';
47-
import { isInherentlyEnabled, hasShowRule } from './runtime';
49+
import { hasShowRule, isInherentlyEnabled, isVisible } from './runtime';
4850
import { createLabelDescriptionFrom } from './label';
4951
import { CombinatorKeyword, resolveSubSchemas } from './combinators';
5052
import { moveDown, moveUp } from './array';
5153
import { AnyAction, Dispatch } from './type';
5254
import { Resolve } from './util';
5355
import { composePaths, composeWithUi } from './path';
54-
import { isVisible } from './runtime';
5556
import { CoreActions, update } from '../actions';
5657
import { ErrorObject } from 'ajv';
5758
import { JsonFormsState } from '../store';

packages/material/src/util/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import isEmpty from 'lodash/isEmpty';
2626
import React from 'react';
2727
import { ComponentType } from 'react';
2828
import Ajv from 'ajv';
29+
import type { UISchemaElement } from '@jsonforms/core';
2930
import {
3031
getAjv,
3132
JsonFormsCellRendererRegistryEntry,
3233
JsonFormsRendererRegistryEntry,
3334
JsonSchema,
3435
OwnPropsOfRenderer,
35-
UISchemaElement
3636
} from '@jsonforms/core';
3737
import { JsonFormsDispatch, useJsonForms } from '@jsonforms/react';
3838
import { Grid, Hidden } from '@mui/material';

packages/react/test/renderers/JsonForms.test.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,31 @@
2525
import React from 'react';
2626
import { combineReducers, createStore } from 'redux';
2727
import { Provider } from 'react-redux';
28-
import {
28+
import type {
2929
ControlElement,
30-
createAjv,
3130
DispatchCellProps,
32-
jsonFormsReducerConfig,
3331
JsonFormsState,
3432
JsonFormsStore,
3533
JsonSchema,
3634
Layout,
35+
RendererProps,
36+
UISchemaElement,
37+
} from '@jsonforms/core';
38+
import {
39+
createAjv,
40+
jsonFormsReducerConfig,
3741
NOT_APPLICABLE,
3842
rankWith,
3943
registerCell,
4044
registerRenderer,
41-
RendererProps,
4245
schemaMatches,
43-
UISchemaElement,
4446
uiTypeIs,
4547
unregisterRenderer,
4648
} from '@jsonforms/core';
4749
import { isEqual } from 'lodash';
4850
import Enzyme from 'enzyme';
4951
import { mount, shallow } from 'enzyme';
50-
import { StatelessRenderer } from '../../src/Renderer';
51-
52+
import type { StatelessRenderer } from '../../src/Renderer';
5253
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
5354
import {
5455
JsonForms,

0 commit comments

Comments
 (0)