Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/type metadata branch #91

Merged
merged 65 commits into from
Feb 15, 2022
Merged

Feature/type metadata branch #91

merged 65 commits into from
Feb 15, 2022

Conversation

meganrm
Copy link
Contributor

@meganrm meganrm commented Feb 11, 2022

Problem

In the last PR, both @schoinh and @toloudis suggested typing things that ended up introducing a lot more changes.

Solution

Pulled this into a separate PR with these changes:

  1. Fully typed both selectionStateBranch and metaStateBranch
  2. Typed the return of every selector
  3. Fixed all resulting errors

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)/ Maintenance

Keyfiles (delete if not relevant):

Start with all the selectors.ts files and the state types: src/state/selection/types.ts, src/state/metadata/types.ts

if (feature && feature.discrete) {
const categoryValues = map(feature.options, (_, key) => Number(key));
const totals = reduce(
measuredData[categoryToColorBy],
measuredData.values[categoryToColorBy],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a mistake I found by correctly typing everything

Base automatically changed from feature/cell-lines-as-feature to main February 14, 2022 21:17
},
measuredFeaturesDefs: [],
viewerChannelSettings: undefined,
viewerChannelSettings: {} as ViewerChannelSettings,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should initialState be typed as MetadataStateBranch?
export const initialState: MetadataStateBranch = {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be, it gets typed in State at the creation of the store, so if anything is mistyped here it would cause an error, but I can add it here for clarity

labels: PerCellLabels;
};
measuredFeaturesDefs: MeasuredFeatureDef[];
viewerChannelSettings: ViewerChannelSettings;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment on lines +49 to +52
export const getPlotByOnX = (state: State): string => state.selection.plotByOnX;
export const getPlotByOnY = (state: State): string => state.selection.plotByOnY;
export const getGroupByCategory = (state: State): string => state.selection.groupBy;
export const getClickedCellsFileInfo = (state: State): FileInfo[] => state.selection.selectedPoints;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, are the return types not automatically inferred/enforced if we don't specify them here? Now that SelectionStateBranch is typed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are, I didn't check, but I thought it would be a good rule to just have every selector have a return type because it makes it clearer when you look at the selector what you're getting

@@ -59,15 +60,15 @@ export function receiveFileInfoData(payload: FileInfo[]): ReceiveCellFileInfoAct
};
}

export function receiveMetadata(payload: MetadataStateBranch): ReceiveAction {
export function receiveDataForPlot(payload: DataForPlot): ReceiveAction {
return {
payload,
type: RECEIVE_METADATA,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should RECEIVE_METADATA also be renamed for clarity?

@@ -157,12 +160,14 @@ const INITIAL_COLOR_AND_GROUP_BY = "cell-line";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can featureData above (ln 140) be typed as DataForPlot now?

Copy link
Contributor

@schoinh schoinh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! Seems like this is something we should do in simularium-website too 🤔

@meganrm meganrm merged commit 187c96b into main Feb 15, 2022
@meganrm meganrm deleted the feature/type-metadata-branch branch February 15, 2022 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants