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

Add tree-related types #1864

Merged
merged 31 commits into from
Nov 12, 2024
Merged

Add tree-related types #1864

merged 31 commits into from
Nov 12, 2024

Commits on Nov 6, 2024

  1. Compile for ES2015

    ES2015 allows iteration of sets which is used in this codebase.
    victorlin committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    c4bcae9 View commit details
    Browse the repository at this point in the history
  2. Fix imports from d3-scale

    Use named imports from the package instead of direct imports from
    source. This allows proper typing by the external types/d3 package.
    victorlin committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    d06d095 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1b4c441 View commit details
    Browse the repository at this point in the history
  4. render(): Convert from positional to named parameters

    For improved readability.
    victorlin committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    cb7e657 View commit details
    Browse the repository at this point in the history
  5. Use context-specific dispatch type

    The AppDispatch type is already used elsewhere.
    victorlin committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    fd26d53 View commit details
    Browse the repository at this point in the history

Commits on Nov 12, 2024

  1. Add tree-related types

    Converted most but not all tree-related files. There are many type
    errors exposed by conversion. They will be addressed in subsequent
    commits.
    
    I removed a few comments that are now self-explanatory with the added
    types. I also moved all JSDoc types and descriptions into the function
    signature.
    
    Note that there are many optional properties in the newly defined
    interfaces. This is not ideal and doesn't capture the fact that many
    properties are conditional on things such as layout. But it's a starting
    point to be improved over time.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    7b3a0e1 View commit details
    Browse the repository at this point in the history
  2. Add other tree-related types

    These are not directly used by other TypeScript files, but I've inferred
    them from existing JavaScript files.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    402a5e6 View commit details
    Browse the repository at this point in the history
  3. tsconfig: Disable strictNullChecks

    The conversion done in the previous commits came with hundreds of
    violations of this rule. While this could be addressed by better types,
    it will take some work and can be deferred. A new issue/PR will be
    created after this is merged.
    
    <#1864 (comment)>
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    b1b2488 View commit details
    Browse the repository at this point in the history
  4. Add override keyword for React lifecycle methods

    To satisfy the TypeScript rule noImplicitOverride.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    2e96210 View commit details
    Browse the repository at this point in the history
  5. Add _ prefix for unused variables

    To satisfy the ESLint rule @typescript-eslint/no-unused-vars.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    7d22da0 View commit details
    Browse the repository at this point in the history
  6. Use exported Layout type

    Define the list of layouts in a single place.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    75fd6ad View commit details
    Browse the repository at this point in the history
  7. Use Math.trunc instead of parseInt

    Previous usage of parseInt was to convert float to integer. However,
    this isn't the intended usage of parseInt, which is made apparent with
    type checking - the parameter is expected to be a string type.
    
    Replace it with Math.trunc which is intended for converting float to
    integer.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    e02e0ce View commit details
    Browse the repository at this point in the history
  8. Use Math.min/max instead of min/max

    Thse are typed to return a value that is not undefined.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    a79226e View commit details
    Browse the repository at this point in the history
  9. Use separate variables for array and set of legend values

    This is easier for the TypeScript compiler to understand.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    5f4fe7e View commit details
    Browse the repository at this point in the history
  10. Use null type for domRefs

    D3 expects the empty value to be null, not undefined.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    aa30581 View commit details
    Browse the repository at this point in the history
  11. Properly handle unknown errors when creating color scales

    Previously, there was no guarantee that an unknown error would produce a
    helpful message.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    6083f73 View commit details
    Browse the repository at this point in the history
  12. Properly check for stroke-width

    svgPropsToUpdate is Set<string>, not Set<string[]>.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    83326a2 View commit details
    Browse the repository at this point in the history
  13. Properly check window.event.shiftKey

    Only KeyboardEvent has the shiftKey property.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    25294e8 View commit details
    Browse the repository at this point in the history
  14. Properly set tipSelectedIdx

    calcTipRadii takes a key name of tipSelectedIdx. Previously, the value
    of idx was unused.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    aedce7e View commit details
    Browse the repository at this point in the history
  15. Properly set timeSliceHasPotentiallyChanged

    This should be a boolean, not whatever value newDistance is when
    defined.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    02b7206 View commit details
    Browse the repository at this point in the history
  16. Properly set isSubtreeRoot

    This should be a boolean, not whatever value
    ReduxNode.parentInfo.original is when defined.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    5b81e88 View commit details
    Browse the repository at this point in the history
  17. Properly set PhyloNode.branch to [string, string]

    Not [string], [], [[string], [string]], or [string, [string]].
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    79608a5 View commit details
    Browse the repository at this point in the history
  18. Remove unused parameter to numDate

    The extra value `true` had no effect.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    9d57be8 View commit details
    Browse the repository at this point in the history
  19. Remove unused mapLegendOpen, treeLegendOpen from controls state

    These were initialized with default values but unused in the code.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    5803970 View commit details
    Browse the repository at this point in the history
  20. Remove unused selectedNode from state

    Follow-up to "Lift node-selected modal to redux state" (f7e944d).
    
    This is left over from before we shifted the selected node to redux
    state.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    4d2e633 View commit details
    Browse the repository at this point in the history
  21. Remove unused default value for performanceFlags

    This value was causing a type error because {} is not a Map. Remove it
    entirely since it isn't actually used - the value is created from
    scratch in src/middleware/performanceFlags.js.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    8c6a301 View commit details
    Browse the repository at this point in the history
  22. Remove broken/unused searchNodes parameter

    There is a type error that prevents this from working properly:
    includes() takes a single string, but an array of PhyloNodes is given.
    It's not used on any existing calls to updateTipRadii, so just remove
    it entirely.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    3bd4b55 View commit details
    Browse the repository at this point in the history
  23. Convert RGBColor to hex string

    This previously worked because d3 was able to properly parse a color
    string out of RGBColor. However, it's better to keep things consistent
    and simple. Convert so that range is simply an array of hex color
    strings.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    56b791b View commit details
    Browse the repository at this point in the history
  24. Set default colorings in getDefaultControlsState

    Centralize the defaults for consistency. Also, this avoids the need to
    mark the property as optional on the state.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    5a681ff View commit details
    Browse the repository at this point in the history
  25. Set default value of focus to false

    This is more consistent with other booleans.
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    931f1e6 View commit details
    Browse the repository at this point in the history
  26. Allow setState to take a partial state

    React will shallow merge the provided object into the existing state¹
    which works for our usage. The type definition of setState does not
    allow partial state by default. Use 'never' to configure it to expect no
    fields in particular².
    
    ¹ <https://react.dev/reference/react/Component#setstate-parameters>
    ² <https://stackoverflow.com/a/55824499>
    victorlin committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    9c7644b View commit details
    Browse the repository at this point in the history