Skip to content

Add generic typing and allow components to be typed#186

Merged
Jeremyea3001 merged 10 commits intodevelopfrom
dev/types
Dec 23, 2025
Merged

Add generic typing and allow components to be typed#186
Jeremyea3001 merged 10 commits intodevelopfrom
dev/types

Conversation

@Jeremyea3001
Copy link
Copy Markdown
Contributor

This is to allow the user to have the correct props suggested and have the correct types when using this library, since before ND and ED were always any or unknown

@Jeremyea3001 Jeremyea3001 requested a review from Copilot December 17, 2025 14:23
@Jeremyea3001 Jeremyea3001 self-assigned this Dec 17, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances TypeScript support by adding generic type parameters (ND and ED) throughout the library, allowing proper type inference for node and edge data. Previously, these types defaulted to any or unknown, but now users can specify custom types for better type safety and IDE autocomplete.

Key changes:

  • Added default type parameters (= any) to component functions to support generic usage
  • Created type aliases for exported components to preserve generic parameters through forwardRef
  • Updated useOgma hook to properly propagate generic types via type assertion
  • Bumped peer dependency @linkurious/ogma from ^5.1.0 to ^5.3.7

Reviewed changes

Copilot reviewed 20 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/transformations/nodeGrouping.tsx Added default generic types and type alias for NodeGrouping component
src/transformations/nodeFilter.tsx Added type alias to preserve generics through forwardRef
src/transformations/nodeCollapsing.tsx Added type alias to preserve generics through forwardRef
src/transformations/neighborMerging.tsx Added type alias to preserve generics through forwardRef
src/transformations/neighborGeneration.tsx Added type alias to preserve generics through forwardRef
src/transformations/edgeGrouping.tsx Added type alias to preserve generics through forwardRef
src/transformations/edgeFilter.tsx Added type alias to preserve generics through forwardRef
src/styles/nodeStyle.tsx Added default generic types to component and subcomponents; created type alias
src/styles/edgeStyle.tsx Added default generic types to component and subcomponents; created type alias
src/styles/classStyle.tsx Restructured to use forwardRef earlier and added type alias
src/overlay/tooltip.tsx Added ND/ED generics and typed state/parameters; added type alias
src/overlay/popup.tsx Added ND/ED generics to component; added type alias
src/overlay/overlay.tsx Added ND/ED generics to props and component; added type alias
src/overlay/layer.tsx Added ND/ED generics to component; added type alias
src/overlay/canvas.tsx Added ND/ED generics to component; added type alias
src/ogma.tsx Updated state typing and added type alias for Ogma component
src/hooks/useEvent.ts Removed default types from generics; added explicit return type
src/context.tsx Updated context typing to use generics with type assertion in useOgma
package.json Updated peer dependency and dev dependencies versions; removed unused @types/leaflet
demo/src/App.tsx Updated component usages with explicit generic type parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Jeremyea3001 Jeremyea3001 requested a review from w8r December 17, 2025 16:19
@w8r
Copy link
Copy Markdown
Contributor

w8r commented Dec 17, 2025

@Jeremyea3001 That's beautiful! Did you check the documentaiton?

@Jeremyea3001
Copy link
Copy Markdown
Contributor Author

I didn't check for documentation yet, but I'll do that tomorrow

@Jeremyea3001
Copy link
Copy Markdown
Contributor Author

The documentation for the components work as well, when they exist

Copy link
Copy Markdown
Contributor

@w8r w8r left a comment

Choose a reason for hiding this comment

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

I would avoid any like pest. Can you use unknown as default type parameters? also let's do an internal release and check how much does it break in Ogma's examples

@w8r
Copy link
Copy Markdown
Contributor

w8r commented Dec 19, 2025

and let's not change Ogma peer dependency or people would have to update in order to use your new wrapper, and they really don't want to

@w8r w8r added the ci:upload Trigger Upload artifacts in CI label Dec 19, 2025
@Jeremyea3001 Jeremyea3001 requested a review from w8r December 22, 2025 10:17
@Jeremyea3001 Jeremyea3001 merged commit b52a637 into develop Dec 23, 2025
8 checks passed
@Jeremyea3001 Jeremyea3001 deleted the dev/types branch December 23, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:upload Trigger Upload artifacts in CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants