Registry / type-stubs / graphology-types

graphology-types

JSON →
library0.24.8jsnpmunverified

graphology-types provides comprehensive TypeScript declaration files for the `graphology` graph manipulation library. Its current stable version is 0.26.0, released in alignment with `graphology`'s development, ensuring type definitions are up-to-date with the core library's API. This package is crucial for developers building type-safe applications with `graphology` in TypeScript environments, offering static checking for graph structures, node and edge attributes, and various graph operations. As an official types package, it guarantees accurate and reliable type information, distinguishing it from community-maintained declaration files which might fall out of sync with library updates. It helps prevent common runtime errors by catching type mismatches at compile time, enhancing developer experience and code maintainability.

npm install graphology-types
INSTALL
IMPORT
SIG · GRAPHOLOGY-TYPES
G
graphology-types
type-stubsjavascriptv0.24.8
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Graph
import { Graph } from 'graphology-types';
import Graph from 'graphology-types';
Imports the Graph *interface* for type declarations, not the Graph class itself. The actual Graph class is imported from 'graphology'.
NodeAttributes
import { NodeAttributes } from 'graphology-types';
Standard import for the base interface representing node attributes. Extend this interface for custom attribute types.
EdgeAttributes
import { EdgeAttributes } from 'graphology-types';
Standard import for the base interface representing edge attributes. Extend this interface for custom attribute types.

Demonstrates how to define and use a `graphology` graph with custom type-safe node and edge attributes using `graphology-types`.

import Graph from 'graphology'; import { Graph as GraphType, NodeAttributes, EdgeAttributes } from 'graphology-types'; // Define custom interfaces for node and edge attributes interface MyNodeAttributes extends NodeAttributes { name: string; weight?: number; } interface MyEdgeAttributes extends EdgeAttributes { type: 'friend' | 'family'; since: Date; } // Instantiate a graph with specific types for node and edge attributes const graph: GraphType<MyNodeAttributes, MyEdgeAttributes> = new Graph<MyNodeAttributes, MyEdgeAttributes>(); // Add nodes with type-checked attributes graph.addNode('john', { name: 'John Doe', weight: 80 }); graph.addNode('jane', { name: 'Jane Smith' }); // Add edges with type-checked attributes graph.addEdge('john', 'jane', { type: 'friend', since: new Date('2020-01-01') }); // Access attributes with type inference const johnsName: string = graph.getNodeAttribute('john', 'name'); const edgeType: 'friend' | 'family' = graph.getEdgeAttribute('john', 'jane', 'type'); console.log(`John's name: ${johnsName}`); console.log(`Relationship type: ${edgeType}`); console.log(`Graph order: ${graph.order}`); console.log(`Graph size: ${graph.size}`);
Debug
Known issues
breakingVersion `0.26.0` introduces ESM support across the `graphology` ecosystem. While `graphology-types` primarily provides declaration files, this change in the underlying library may impact how `graphology` is imported and subsequently how types are resolved in mixed CJS/ESM projects.
fix
Ensure your project's module resolution (e.g., `tsconfig.json` `moduleResolution`) is configured correctly for 'NodeNext' or 'Bundler' if using ESM, and update `graphology` to a compatible version if facing runtime import issues.
affects: >=0.26.0
breakingThe `obliterator` dependency was removed in version `0.26.0`. While this is primarily an internal change, if any type definitions from `obliterator` were inadvertently exposed or relied upon in custom extensions, their removal could lead to type errors.
fix
Review custom type definitions or interfaces that might have implicitly relied on `obliterator` types. Update code to use standard JavaScript iteration protocols or `graphology`'s native iteration methods.
affects: >=0.26.0
breakingVersion `0.24.0` removed undocumented methods `#.upgradeToMixed` and `#.upgradeToMulti` from the `Graph` class. Although undocumented, if these methods were used, their removal will result in type and runtime errors.
fix
Refactor code to use supported graph conversion methods or ensure only documented APIs are accessed. Consult the `graphology` documentation for official upgrade paths.
affects: >=0.24.0
breakingVersion `0.24.0` also includes 'Dropping some irrelevant arities for edge attribute' setters/getters. This could lead to type mismatches if custom attribute functions or specific parameter counts were expected when interacting with edge attributes.
fix
Review usage of `setEdgeAttribute`, `getEdgeAttribute`, etc., and ensure they conform to the updated (and officially documented) function signatures for attribute handling.
affects: >=0.24.0
Errors
Common errors & fixes
TS2307: Cannot find module 'graphology-types' or its corresponding type declarations.
The `graphology-types` package has not been installed or TypeScript cannot locate its declaration files.
fix
Run `npm install graphology-types` or `yarn add graphology-types`. Ensure `tsconfig.json` includes `node_modules/@types` in its `typeRoots` or that the package is correctly referenced.
Property 'xyz' does not exist on type 'NodeAttributes'.
Attempting to access a node or edge attribute that has not been explicitly defined in the custom `NodeAttributes` or `EdgeAttributes` interface.
fix
Extend `NodeAttributes` or `EdgeAttributes` with your custom properties, e.g., `interface MyNodeAttrs extends NodeAttributes { xyz: string; }` and use `Graph<MyNodeAttrs>`.
Argument of type 'number' is not assignable to parameter of type 'string'.
A type mismatch occurs when setting or retrieving an attribute, where the value provided does not match the type defined in the custom `NodeAttributes` or `EdgeAttributes` interface.
fix
Ensure that the values passed to `addNode`, `setNodeAttribute`, etc., strictly conform to the types defined in your custom attribute interfaces.
Module 'graphology-types' has no exported member 'X'. Did you mean 'Y'?
An incorrect named import was used, or the symbol 'X' does not exist in the `graphology-types` package.
fix
Verify the exact name of the type or interface you are trying to import from the `graphology-types` documentation or its `d.ts` files. Ensure you are using named imports for interfaces and types.
Upgrade
Version history
0.24.8latest on npm
Audit
Dependencies
graphologyrequiredProvides type definitions for the graphology library; typically used as a peer dependency alongside the main graphology package.
Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources