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

Update entropy types #1915

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Update entropy types #1915

wants to merge 10 commits into from

Conversation

victorlin
Copy link
Member

@victorlin victorlin commented Nov 21, 2024

Description of proposed changes

Updates TypeScript usage to be consistent with #1864, etc.

I thought of these changes after adding 6215591.

Checklist

This allows for more specific type narrowing.
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.
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.
@victorlin victorlin self-assigned this Nov 21, 2024
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-victorlin-updat-jrdeox November 21, 2024 01:36 Inactive
end?: number
start?: number
segments?: JsonSegmentRange[]
strand?: Strand
Copy link
Contributor

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?

Copy link
Member Author

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:

createGenomeMap(json.meta.genome_annotations),

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.
@victorlin victorlin temporarily deployed to auspice-victorlin-updat-jrdeox November 21, 2024 19:39 Inactive
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