From acbc70cbf6b2ce4b370ed4e49edbc36734cf2df6 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Thu, 14 Nov 2024 16:47:24 +1300 Subject: [PATCH] appease tsc / eslint --- src/actions/recomputeReduxState.js | 3 ++- src/components/controls/choose-metric.js | 1 - src/components/tree/phyloTree/change.ts | 2 -- src/components/tree/phyloTree/layouts.ts | 6 +++--- src/components/tree/phyloTree/phyloTree.ts | 1 - src/components/tree/phyloTree/renderers.ts | 8 +------- src/components/tree/phyloTree/types.ts | 2 ++ src/components/tree/reactD3Interface/callbacks.ts | 5 ++--- src/reducers/controls.ts | 2 -- src/util/partitionIntoStreams.js | 2 +- tsconfig.json | 1 + 11 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index c15017f1a..3461aa766 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -1006,7 +1006,8 @@ export const createStateFromQueryOrJSONs = ({ 'none'; } tree.streams = partitionIntoStreams(controls.showStreamTrees, controls.streamTreeBranchLabel, tree.nodes, tree.visibility, controls.colorScale, controls.absoluteDateMinNumeric, controls.absoluteDateMaxNumeric, controls.distanceMeasure) - console.log("tree.streams", tree.streams) + // eslint-disable-next-line + console.log("tree.streams", tree.streams); // TODO - remove console log /* calculate entropy in view */ if (entropy.loaded) { diff --git a/src/components/controls/choose-metric.js b/src/components/controls/choose-metric.js index f9939cb5a..506d8af2e 100644 --- a/src/components/controls/choose-metric.js +++ b/src/components/controls/choose-metric.js @@ -1,7 +1,6 @@ import React from "react"; import { connect } from "react-redux"; import { withTranslation } from "react-i18next"; -import { CHANGE_DISTANCE_MEASURE } from "../../actions/types"; import { analyticsControlsEvent } from "../../util/googleAnalytics"; import { toggleTemporalConfidence } from "../../actions/tree"; import { toggleStreamTree, changeDistanceMeasure } from "../../actions/streamTrees"; diff --git a/src/components/tree/phyloTree/change.ts b/src/components/tree/phyloTree/change.ts index 20667023d..8a0694b32 100644 --- a/src/components/tree/phyloTree/change.ts +++ b/src/components/tree/phyloTree/change.ts @@ -423,7 +423,6 @@ export const change = function change( this.streamLayout(); // recompute displayOrder values across pivots mapStreamsToScreen(this.streams, this.phyloStreams, this.xScale, this.yScale); // recompute pixels (unneeded for branches/tips) this.drawStreams(); // remove & redraw - this.drawStreamConnectors(); // remove & redraw } // don't have good methods to remove tips etc (yet) for (const name of ['branchLabels', 'branchTee', 'branchStem', 'tips', 'tipLabels', 'vaccines']) { @@ -453,7 +452,6 @@ export const change = function change( this.streamLayout(); // recompute displayOrder values across pivots mapStreamsToScreen(this.streams, this.phyloStreams, this.xScale, this.yScale); // recompute pixels (unneeded for branches/tips) this.drawStreams(); // remove & redraw - this.drawStreamConnectors(); // remove & redraw } // recalculate existing regression if needed if (changeVisibility && this.regression) { diff --git a/src/components/tree/phyloTree/layouts.ts b/src/components/tree/phyloTree/layouts.ts index 8265211f1..d42cd3132 100644 --- a/src/components/tree/phyloTree/layouts.ts +++ b/src/components/tree/phyloTree/layouts.ts @@ -658,9 +658,9 @@ export function mapStreamsToScreen(streams, phyloStreams, xScale, yScale) { /* it's important we only set this up once, as DOM elements will bind to data within, so we need to mutate it */ if (!phyloStream.ripples) { const _area = area() - .x((d) => d.x) - .y0((d) => d.y0) - .y1((d) => d.y1) + .x((d: any) => d.x) // TODO XXX fix types + .y0((d: any) => d.y0) // TODO XXX fix types + .y1((d: any) => d.y1) // TODO XXX fix types .curve(curveCatmullRom.alpha(0.5)) phyloStream.ripples = phyloStream.displayOrderByCategory.map((displayOrderByPivot) => { diff --git a/src/components/tree/phyloTree/phyloTree.ts b/src/components/tree/phyloTree/phyloTree.ts index 0af18fadb..4015dcdec 100644 --- a/src/components/tree/phyloTree/phyloTree.ts +++ b/src/components/tree/phyloTree/phyloTree.ts @@ -67,7 +67,6 @@ PhyloTree.prototype.drawRegression = renderers.drawRegression; PhyloTree.prototype.removeRegression = renderers.removeRegression; PhyloTree.prototype.updateColorBy = renderers.updateColorBy; PhyloTree.prototype.drawStreams = renderers.drawStreams; -PhyloTree.prototype.drawStreamConnectors = renderers.drawStreamConnectors; /* C A L C U L A T E G E O M E T R I E S E T C ( M O D I F I E S N O D E S , N O T S V G ) */ PhyloTree.prototype.setDistance = layouts.setDistance; diff --git a/src/components/tree/phyloTree/renderers.ts b/src/components/tree/phyloTree/renderers.ts index 3d15f4087..e56c2013b 100644 --- a/src/components/tree/phyloTree/renderers.ts +++ b/src/components/tree/phyloTree/renderers.ts @@ -119,7 +119,6 @@ export const render = function render( this.updateTipLabels(); this.drawTips(); this.drawStreams(); - this.drawStreamConnectors(); if (this.params.branchLabelKey) this.drawBranchLabels(this.params.branchLabelKey); if (this.vaccines) this.drawVaccines(); if (this.regression) this.drawRegression(); @@ -357,15 +356,10 @@ export function drawStreams(this: PhyloTreeType): void { .style("fill", "none") .style('visibility', 'visible') .style('cursor', 'pointer') // using a dashed line doesn't play nicely with onhover/onclick behaviour :( - .on("click", this.callbacks.onStreamConnectorClick); + .on("click", this.callbacks.onStreamConnectorClick as any); // TODO - fix type } } -export function drawStreamConnectors() { - console.log("drawStreamConnectors is currently a no-op") -} - - /** * draws the regression line in the svg and adds a text with the rate estimate */ diff --git a/src/components/tree/phyloTree/types.ts b/src/components/tree/phyloTree/types.ts index 9f053110d..5912e3fb9 100644 --- a/src/components/tree/phyloTree/types.ts +++ b/src/components/tree/phyloTree/types.ts @@ -2,6 +2,7 @@ import { Selection } from "d3"; import { Layout, PerformanceFlags, ScatterVariables } from "../../../reducers/controls"; import { ReduxNode, Visibility } from "../../../reducers/tree/types"; import { change, modifySVG, modifySVGInStages } from "./change"; +import { TreeComponent } from "../tree"; import * as confidence from "./confidence"; import * as grid from "./grid"; @@ -47,6 +48,7 @@ export interface Callbacks { onTipHover: NodeCallback onTipLeave: NodeCallback tipLabel: NodeCallback + onStreamConnectorClick: (this: TreeComponent, phyloStream: any) => void } // ---------- PhyloNode ---------- // diff --git a/src/components/tree/reactD3Interface/callbacks.ts b/src/components/tree/reactD3Interface/callbacks.ts index ce626af0a..a84ab79e6 100644 --- a/src/components/tree/reactD3Interface/callbacks.ts +++ b/src/components/tree/reactD3Interface/callbacks.ts @@ -102,9 +102,8 @@ export const onBranchClick = function onBranchClick(this: TreeComponent, d: Phyl this.props.dispatch(updateVisibleTipsAndBranchThicknesses({root, cladeSelected})); }; -export function onStreamConnectorClick(phyloStream) { - console.log("CLICK", phyloStream, this) - const root = [this.state.tree.streams.streams[phyloStream.streamIdx].founderIdx, undefined]; +export function onStreamConnectorClick(this: TreeComponent, phyloStream: any) { + const root = [this.state.tree.streams.streams[phyloStream.streamIdx].founderIdx, undefined] as [number, undefined]; // TODO fix type this.props.dispatch(updateVisibleTipsAndBranchThicknesses({root, cladeSelected: undefined})); // TODO - this zoom is wrong because underneath it all we're zooming to the display Order values of the subtree diff --git a/src/reducers/controls.ts b/src/reducers/controls.ts index 152f4e056..7e0e308dc 100644 --- a/src/reducers/controls.ts +++ b/src/reducers/controls.ts @@ -467,10 +467,8 @@ const Controls = (state: ControlsState = getDefaultControlsState(), action): Con case types.TOGGLE_LEGEND: return Object.assign({}, state, { legendOpen: action.value }); case types.TOGGLE_STREAM_TREE: - console.log("Controls reducer. Show?", action.showStreamTrees, "Label (unchanged):", state.streamTreeBranchLabel); return {...state, showStreamTrees: action.showStreamTrees}; case types.CHANGE_STREAM_TREE_BRANCH_LABEL: - console.log("Controls reducer. Show?", action.showStreamTrees, "Label", action.streamTreeBranchLabel); return {...state, showStreamTrees: action.showStreamTrees, streamTreeBranchLabel: action.streamTreeBranchLabel}; case types.ADD_EXTRA_METADATA: { for (const colorBy of Object.keys(action.newColorings)) { diff --git a/src/util/partitionIntoStreams.js b/src/util/partitionIntoStreams.js index 579bd2688..a8b1e1875 100644 --- a/src/util/partitionIntoStreams.js +++ b/src/util/partitionIntoStreams.js @@ -250,6 +250,6 @@ function getFounderTree(treeNodes, branchLabel) { }) - console.log({founderTree, founderIndiciesToDescendantFounderIndicies, foundersPostorder, streamGroups}) + // console.log({founderTree, founderIndiciesToDescendantFounderIndicies, foundersPostorder, streamGroups}) return {founderTree, founderIndiciesToDescendantFounderIndicies, foundersPostorder, streamGroups}; } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index c6275dc6e..a169a42cc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,6 +14,7 @@ Visit https://aka.ms/tsconfig.json for a detailed list of options. /* Language and Environment */ "jsx": "react", /* Specify what JSX code is generated. */ "target": "es2015", + "lib": ["esnext", "dom"], /* Modules */ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */