-
Notifications
You must be signed in to change notification settings - Fork 162
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
Update entropy types #1915
base: master
Are you sure you want to change the base?
Update entropy types #1915
Conversation
This allows for more specific type narrowing.
Improves readability.
Improves readability.
This allows some code editors to show the comment on hover. I also added two new types (Phase, Frame) to replace some comments.
For consistency.
These were not consistent in the same file. I've also opted to not use them in the tree component types.
The previous error message code indicated the possibility that this property is unset. Express that directly in the type annotation and simplify the error message code.
Checking against undefined is more direct.
end?: number | ||
start?: number | ||
segments?: JsonSegmentRange[] | ||
strand?: Strand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making sure this needed to become optional to match some usage somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 2d3a331 the matched usage was Object.prototype.hasOwnProperty.call(annotation, "strand")
which to me indicates that it is optional. It's hard to tell from other usage because the entire JsonAnnotation
object is represented by json.meta.genome_annotations
here:
auspice/src/actions/recomputeReduxState.js
Line 819 in a7578d2
createGenomeMap(json.meta.genome_annotations), |
auspice/src/actions/recomputeReduxState.js
Line 870 in a7578d2
entropy = entropyCreateState(json.meta.genome_annotations); |
@jameshadfield might have a better idea.
At first, I disabled @typescript-eslint/consistent-type-assertions for the type assertion in the original code, but that ended up polluting the _frame() function with details unrelated to the direct purpose of the function. Extracting the modulus operation into a separate function and adding the details there felt like a better scope.
Description of proposed changes
Updates TypeScript usage to be consistent with #1864, etc.
I thought of these changes after adding 6215591.
Checklist
If making user-facing changes, add a message in CHANGELOG.md summarizing the changes in this PR(to be done by a Nextstrain team member) Create preview PRs on downstream repositories.