Skip to content

Commit

Permalink
Use type imports in Core and React
Browse files Browse the repository at this point in the history
Use type imports in selected files of the core and react packages.
This helps to avoid circular imports and aids in custom webpack scenarios.
  • Loading branch information
mirismaili authored Dec 22, 2021
1 parent 901b2a6 commit 6d8b63e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/reducers/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import {
import { defaultDataReducer } from './default-data';
import { rendererReducer } from './renderers';
import { JsonFormsState } from '../store';
import type { JsonFormsUISchemaRegistryEntry } from './uischemas';
import {
findMatchingUISchema,
JsonFormsUISchemaRegistryEntry,
uischemaRegistryReducer,
} from './uischemas';
import {
Expand All @@ -59,7 +59,7 @@ export const jsonFormsReducerConfig = {
config: configReducer,
uischemas: uischemaRegistryReducer,
defaultData: defaultDataReducer,
i18n: i18nReducer
i18n: i18nReducer,
};

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/util/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

import isEmpty from 'lodash/isEmpty';
import union from 'lodash/union';
import type { JsonFormsCellRendererRegistryEntry } from '../reducers';
import {
getAjv,
getConfig,
getData,
getErrorAt,
getSchema,
getAjv,
JsonFormsCellRendererRegistryEntry,
getTranslator
getTranslator,
} from '../reducers';
import { AnyAction, Dispatch } from './type';
import {
Expand All @@ -57,7 +57,7 @@ import { JsonFormsState } from '../store';
import { JsonSchema } from '../models';
import { getI18nKeyPrefix } from '../i18n';

export { JsonFormsCellRendererRegistryEntry };
export type { JsonFormsCellRendererRegistryEntry };

export interface OwnPropsOfCell extends OwnPropsOfControl {
data?: any;
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/util/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import get from 'lodash/get';
import { ControlElement, JsonSchema, UISchemaElement } from '../models';
import find from 'lodash/find';
import type {
JsonFormsCellRendererRegistryEntry,
JsonFormsRendererRegistryEntry,
} from '../reducers';
import {
findUISchema,
getAjv,
Expand All @@ -39,19 +43,16 @@ import {
getSubErrorsAt,
getTranslator,
getUiSchema,
JsonFormsCellRendererRegistryEntry,
JsonFormsRendererRegistryEntry,
JsonFormsUISchemaRegistryEntry,
} from '../reducers';
import { RankedTester } from '../testers';
import { isInherentlyEnabled, hasShowRule } from './runtime';
import { hasShowRule, isInherentlyEnabled, isVisible } from './runtime';
import { createLabelDescriptionFrom } from './label';
import { CombinatorKeyword, resolveSubSchemas } from './combinators';
import { moveDown, moveUp } from './array';
import { AnyAction, Dispatch } from './type';
import { Resolve } from './util';
import { composePaths, composeWithUi } from './path';
import { isVisible } from './runtime';
import { CoreActions, update } from '../actions';
import { ErrorObject } from 'ajv';
import { JsonFormsState } from '../store';
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/util/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import isEmpty from 'lodash/isEmpty';
import React from 'react';
import { ComponentType } from 'react';
import Ajv from 'ajv';
import type { UISchemaElement } from '@jsonforms/core';
import {
getAjv,
JsonFormsCellRendererRegistryEntry,
JsonFormsRendererRegistryEntry,
JsonSchema,
OwnPropsOfRenderer,
UISchemaElement
} from '@jsonforms/core';
import { JsonFormsDispatch, useJsonForms } from '@jsonforms/react';
import { Grid, Hidden } from '@mui/material';
Expand Down
15 changes: 8 additions & 7 deletions packages/react/test/renderers/JsonForms.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,31 @@
import React from 'react';
import { combineReducers, createStore } from 'redux';
import { Provider } from 'react-redux';
import {
import type {
ControlElement,
createAjv,
DispatchCellProps,
jsonFormsReducerConfig,
JsonFormsState,
JsonFormsStore,
JsonSchema,
Layout,
RendererProps,
UISchemaElement,
} from '@jsonforms/core';
import {
createAjv,
jsonFormsReducerConfig,
NOT_APPLICABLE,
rankWith,
registerCell,
registerRenderer,
RendererProps,
schemaMatches,
UISchemaElement,
uiTypeIs,
unregisterRenderer,
} from '@jsonforms/core';
import { isEqual } from 'lodash';
import Enzyme from 'enzyme';
import { mount, shallow } from 'enzyme';
import { StatelessRenderer } from '../../src/Renderer';

import type { StatelessRenderer } from '../../src/Renderer';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import {
JsonForms,
Expand Down

0 comments on commit 6d8b63e

Please sign in to comment.