Skip to content

Commit 1016d85

Browse files
committed
improve some typing
1 parent 9eeede6 commit 1016d85

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

frontend/javascripts/oxalis/view/action-bar/download_modal_view.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,17 @@ export default function DownloadModalView(props: Props): JSX.Element {
116116
// const layers = chooseSegmentationLayer ? getSegmentationLayers(dataset) : getColorLayers(dataset);
117117
const tracing = useSelector((state: OxalisState) => state.tracing);
118118
const dataset = useSelector((state: OxalisState) => state.dataset);
119-
const [startedExports, setStartedExports] = useState([]);
119+
const [startedExports, setStartedExports] = useState<string[]>([]);
120120
const layers = getDataLayers(dataset);
121121

122122
const isMergerModeEnabled = useSelector(
123-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
124-
(state) => state.temporaryConfiguration.isMergerModeEnabled,
123+
(state: OxalisState) => state.temporaryConfiguration.isMergerModeEnabled,
125124
);
126125
const activeMappingInfos = useSelector(
127-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
128-
(state) => state.temporaryConfiguration.activeMappingByLayer,
126+
(state: OxalisState) => state.temporaryConfiguration.activeMappingByLayer,
129127
);
130128

131-
const [selectedLayerName, setSelectedLayerName] = useState("");
129+
const [selectedLayerName, setSelectedLayerName] = useState<string | null>(null);
132130
const [selectedBoundingBoxID, setSelectedBoundingBoxId] = useState(-1);
133131

134132
const handleOk = async () => {
@@ -137,11 +135,11 @@ export default function DownloadModalView(props: Props): JSX.Element {
137135
downloadAnnotation(annotationId, annotationType, hasVolumeFallback, {}, includeVolumeData);
138136
onClose();
139137
} else if (activeTabKey === "export") {
140-
const missingSelection = selectedLayerName === "" || selectedBoundingBoxID === -1;
138+
const missingSelection = selectedLayerName == null || selectedBoundingBoxID === -1;
141139
const basicWarning = "Starting an export job with the chosen parameters was not possible.";
142140
const missingSelectionWarning = " Please choose a layer and a bounding box for export.";
143141

144-
if (missingSelection) {
142+
if (selectedLayerName == null || selectedBoundingBoxID === -1) {
145143
Toast.warning(basicWarning + missingSelectionWarning);
146144
} else {
147145
const selectedLayer = getLayerByName(dataset, selectedLayerName);

frontend/javascripts/oxalis/view/right-border-tabs/export_bounding_box_modal.tsx

+6-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, { useState } from "react";
44
import type { APIDataset, APIDataLayer } from "types/api_flow_types";
55
import type { BoundingBoxType } from "oxalis/constants";
66
import { MappingStatusEnum } from "oxalis/constants";
7-
import type { Tracing, AnnotationType, HybridTracing } from "oxalis/store";
7+
import type { OxalisState, Tracing, AnnotationType, HybridTracing } from "oxalis/store";
88
import { getResolutionInfo, getMappingInfo } from "oxalis/model/accessors/dataset_accessor";
99
import { getVolumeTracingById } from "oxalis/model/accessors/volumetracing_accessor";
1010
import { startExportTiffJob } from "admin/admin_rest_api";
@@ -112,11 +112,10 @@ export async function handleStartExport(
112112
dataset: APIDataset,
113113
layerInfos: LayerInfos,
114114
boundingBox: BoundingBoxType,
115-
startedExports: never[],
116-
setStartedExports?: React.Dispatch<React.SetStateAction<never[]>>,
115+
startedExports: string[],
116+
setStartedExports?: React.Dispatch<React.SetStateAction<string[]>>,
117117
) {
118118
if (setStartedExports) {
119-
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
120119
setStartedExports(startedExports.concat(exportKey(layerInfos)));
121120
}
122121

@@ -139,22 +138,19 @@ export async function handleStartExport(
139138
}
140139

141140
function ExportBoundingBoxModal({ handleClose, dataset, boundingBox, tracing }: Props) {
142-
const [startedExports, setStartedExports] = useState([]);
141+
const [startedExports, setStartedExports] = useState<string[]>([]);
143142
const isMergerModeEnabled = useSelector(
144-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
145-
(state) => state.temporaryConfiguration.isMergerModeEnabled,
143+
(state: OxalisState) => state.temporaryConfiguration.isMergerModeEnabled,
146144
);
147145
const activeMappingInfos = useSelector(
148-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
149-
(state) => state.temporaryConfiguration.activeMappingByLayer,
146+
(state: OxalisState) => state.temporaryConfiguration.activeMappingByLayer,
150147
);
151148

152149
const allLayerInfos = dataset.dataSource.dataLayers.map((layer: APIDataLayer) =>
153150
getLayerInfos(layer, tracing, activeMappingInfos, isMergerModeEnabled),
154151
);
155152
const exportButtonsList = allLayerInfos.map((layerInfos) => {
156153
const parenthesesInfos = [
157-
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
158154
startedExports.includes(exportKey(layerInfos)) ? "started" : null,
159155
layerInfos.mappingName != null ? `using mapping "${layerInfos.mappingName}"` : null,
160156
!layerInfos.hasMag1 ? "resolution 1 missing" : null,
@@ -169,7 +165,6 @@ function ExportBoundingBoxModal({ handleClose, dataset, boundingBox, tracing }:
169165
}
170166
disabled={
171167
// The export is already running or...
172-
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
173168
startedExports.includes(exportKey(layerInfos)) || // The layer has no mag 1 or...
174169
!layerInfos.hasMag1 || // Merger mode is enabled and this layer is the volume tracing layer.
175170
(isMergerModeEnabled && layerInfos.tracingId != null)

frontend/javascripts/oxalis/view/right-border-tabs/starting_job_modals.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function LayerSelection({
8585
tracing: HybridTracing;
8686
fixedLayerName?: string;
8787
layerType?: string;
88-
setSelectedLayerName?: React.Dispatch<React.SetStateAction<string>>;
88+
setSelectedLayerName?: React.Dispatch<React.SetStateAction<string | null>>;
8989
style?: React.CSSProperties;
9090
}): JSX.Element {
9191
const onSelect = setSelectedLayerName

0 commit comments

Comments
 (0)