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-typesVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to define and use a `graphology` graph with custom type-safe node and edge attributes using `graphology-types`.
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.
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.
Refactor code to use supported graph conversion methods or ensure only documented APIs are accessed. Consult the `graphology` documentation for official upgrade paths.
Review usage of `setEdgeAttribute`, `getEdgeAttribute`, etc., and ensure they conform to the updated (and officially documented) function signatures for attribute handling.
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.
Extend `NodeAttributes` or `EdgeAttributes` with your custom properties, e.g., `interface MyNodeAttrs extends NodeAttributes { xyz: string; }` and use `Graph<MyNodeAttrs>`.Ensure that the values passed to `addNode`, `setNodeAttribute`, etc., strictly conform to the types defined in your custom attribute interfaces.
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.