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

Module not found: Can't resolve 'vis-network/dist/types/vis-types' in '/home/jamie/programs/vis-test/src' #76

Open
jamietwells opened this issue Aug 24, 2019 · 1 comment
Labels
question Further information is requested TypeScript

Comments

@jamietwells
Copy link

Hi, I seem to be unable to use the DataSet.

Steps to reproduce:

Run the commands:

yarn create react-app vis-test --typescript
cd vis-test
yarn add vis-data
yarn add vis-network

Replace the src/App.tsx file with the following:

import React from 'react';
import './App.css';
import { Network } from 'vis-network';
import { DataSet } from 'vis-network/dist/types/vis-types';

class App extends React.Component<{}, { networkElement?: HTMLDivElement }> {
  constructor(props: {}) {
    super(props);
    this.state = {};
  }
  
  render() {
    const instance = this;

    if (instance.state.networkElement) {
      const nodes = new DataSet([{ id: 'a' }, { id: 'b' }]);
      const edges =  new DataSet([{ from: 'a', to: 'b' }]);
      const data = { nodes, edges };
      new Network(instance.state.networkElement, data);
    }

    function refCallback(elem: HTMLDivElement | null) {
      if (elem && !instance.state.networkElement)
        instance.setState({ networkElement: elem });
    }

    return (
      <div className="App">
        <div ref={refCallback} ></div>
      </div>
    );
  }
}

export default App;

run the command:

yarn start

See runtime error:

Failed to compile.

./src/App.tsx
Module not found: Can't resolve 'vis-network/dist/types/vis-types' in '/home/jamie/programs/vis-test/src'
@micahstubbs micahstubbs added the bug Something isn't working label Aug 26, 2019
@micahstubbs
Copy link
Member

thanks for reporting this @jamietwells, as well as the steps to reproduce.

That said, we don't current ship TypeScript types for visjs-network. You might have luck making a custom module declaration for visjs-network in your project, and then dropping in these generated types #52 (comment)

Like you see in #52, we're thinking about implementing more robust support for TypeScript. If that is something that you are interested in, we welcome contributions 😄

@micahstubbs micahstubbs added question Further information is requested TypeScript and removed bug Something isn't working labels Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants