chore(client): tsmigrate getTargetEditor.js (#45090)

This commit is contained in:
Krzysztof G
2022-02-14 00:12:04 +01:00
committed by GitHub
parent 5f56e08c3f
commit f644c239c1
4 changed files with 19 additions and 16 deletions

View File

@ -9,7 +9,7 @@ import {
consoleOutputSelector,
visibleEditorsSelector
} from '../redux';
import { getTargetEditor } from '../utils/getTargetEditor';
import { getTargetEditor } from '../utils/get-target-editor';
import './editor.css';
import Editor from './editor';

View File

@ -4,7 +4,7 @@ import { createAction, handleActions } from 'redux-actions';
import { getLines } from '../../../../../utils/get-lines';
import { challengeTypes } from '../../../../utils/challenge-types';
import { completedChallengesSelector } from '../../../redux';
import { getTargetEditor } from '../utils/getTargetEditor';
import { getTargetEditor } from '../utils/get-target-editor';
import { actionTypes, ns } from './action-types';
import codeLockEpic from './code-lock-epic';
import codeStorageEpic from './code-storage-epic';

View File

@ -0,0 +1,17 @@
import { isEmpty } from 'lodash-es';
import { sortChallengeFiles } from '../../../../../utils/sort-challengefiles';
import { ChallengeFiles, FileKey } from '../../../redux/prop-types';
export function getTargetEditor(
challengeFiles: ChallengeFiles
): FileKey | null {
if (isEmpty(challengeFiles)) return null;
const targetEditor = challengeFiles?.find(
({ editableRegionBoundaries }) => !isEmpty(editableRegionBoundaries)
)?.fileKey;
// fallback for when there is no editable region.
/* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
return targetEditor || sortChallengeFiles(challengeFiles)[0].fileKey;
}

View File

@ -1,14 +0,0 @@
import { isEmpty } from 'lodash-es';
import { sortChallengeFiles } from '../../../../../utils/sort-challengefiles';
export function getTargetEditor(challengeFiles) {
if (isEmpty(challengeFiles)) return null;
else {
let targetEditor = challengeFiles.find(
({ editableRegionBoundaries }) => !isEmpty(editableRegionBoundaries)
)?.fileKey;
// fallback for when there is no editable region.
return targetEditor || sortChallengeFiles(challengeFiles)[0].fileKey;
}
}