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

Cannot import NodeObject and LinkObject types from 3d-force-graph #693

Open
gs0428 opened this issue Nov 15, 2024 · 0 comments
Open

Cannot import NodeObject and LinkObject types from 3d-force-graph #693

gs0428 opened this issue Nov 15, 2024 · 0 comments

Comments

@gs0428
Copy link

gs0428 commented Nov 15, 2024

Describe the bug
3d-force-graph does not export a NodeObject and LinkObject type.

스크린샷 2024-11-15 오후 3 39 57

above message is : 'NodeObject' is not exported by the module '"3d-force-graph"'. Would you like to import 'NodeObject' from '"3d-force-graph"' instead? ts(2614)

To Reproduce

const ForceGraph3D = (await import("3d-force-graph")).default;
  const graph = ForceGraph3D()(graphRef.current)
    .graphData({
      nodes: [
        { id: 1, color: "#ff0000", name: "red", size: 5 },
        { id: 2, color: "#00ff00", name: "green", size: 5 },
        { id: 3, color: "#0000ff", name: "blue", size: 5 },
        { id: 4, color: "#ffff00", name: "yellow", size: 5 },
      ],
      links: [
        { source: 1, target: 2 },
        { source: 3, target: 2 },
        { source: 4, target: 2 },
      ],
    });

When assigning the color property, the following error occurs (the same happens with size):

Screenshot 2024-11-15 at 3.41.26 PM

above message is : Object literal may only specify known properties, and 'color' does not exist in type 'NodeObject'. ts(2353)

Expected behavior
The library should support specifying types for the instance of ForceGraph3D generated by 3d-force-graph, allowing developers to properly type properties like color, size, etc.

How to Fix
Adding the NodeObject and LinkObject types imported from three-forcegraph to the export in 3d-force-graph.d.ts, both types can be used properly.

Desktop (please complete the following information):

  • OS: Macbook Air M1
  • Version:
    • "3d-force-graph": "^1.73.6"
@gs0428 gs0428 closed this as completed Nov 15, 2024
@gs0428 gs0428 reopened this Nov 15, 2024
@gs0428 gs0428 changed the title There is no NodeObject type in 3d-force-graph There is no NodeObject and LinkObject type in 3d-force-graph Nov 15, 2024
@gs0428 gs0428 changed the title There is no NodeObject and LinkObject type in 3d-force-graph Cannot import NodeObject and LinkObject type from 3d-force-graph Nov 15, 2024
@gs0428 gs0428 changed the title Cannot import NodeObject and LinkObject type from 3d-force-graph Cannot import NodeObject and LinkObject types from 3d-force-graph Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant