From 9f281c20dd1f349c89b3d6b189e56eaf036ac624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastien?= Date: Tue, 28 Jan 2020 16:06:19 +0530 Subject: [PATCH] Fix TS issues --- .../components/load_mappings/load_mappings_provider.test.tsx | 5 +++-- .../components/load_mappings/load_mappings_provider.tsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx index bd737f8698909..34647af38865d 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx @@ -19,7 +19,7 @@ jest.mock('@elastic/eui', () => ({ ), })); -import { registerTestBed, nextTick } from '../../../../../../../../../test_utils'; +import { registerTestBed, nextTick, TestBed } from '../../../../../../../../../test_utils'; import { LoadMappingsProvider } from './load_mappings_provider'; const ComponentToTest = ({ onJson }: { onJson: () => void }) => ( @@ -38,11 +38,12 @@ const setup = (props: any) => defaultProps: props, })(); -const openModalWithJsonContent = ({ find, component }) => async json => { +const openModalWithJsonContent = ({ find, component }: TestBed) => async (json: any) => { find('load-json-button').simulate('click'); component.update(); // Set the mappings to load + // @ts-ignore await act(async () => { find('mockCodeEditor').simulate('change', { jsonString: JSON.stringify(json), diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx index 18a0e907579f5..49411861d5214 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx @@ -133,7 +133,7 @@ const areAllObjectKeysValidParameters = (obj: { [key: string]: any }) => export const LoadMappingsProvider = ({ onJson, children }: Props) => { const [state, setState] = useState({ isModalOpen: false }); const [totalErrorsToDisplay, setTotalErrorsToDisplay] = useState(MAX_ERRORS_TO_DISPLAY); - const jsonContent = useRef['0'] | undefined>(); + const jsonContent = useRef['0'] | undefined>(undefined); const view: ModalView = state.json !== undefined && state.errors !== undefined ? 'validationResult' : 'json'; const i18nTexts = getTexts(view, state.errors?.length);