Add generic typing and allow components to be typed#186
Add generic typing and allow components to be typed#186Jeremyea3001 merged 10 commits intodevelopfrom
Conversation
There was a problem hiding this comment.
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
useOgmahook to properly propagate generic types via type assertion - Bumped peer dependency
@linkurious/ogmafrom^5.1.0to^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 That's beautiful! Did you check the documentaiton? |
|
I didn't check for documentation yet, but I'll do that tomorrow |
|
The documentation for the components work as well, when they exist |
w8r
left a comment
There was a problem hiding this comment.
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
|
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 |
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
anyorunknown