0

I'm importing a custom module like this in a .tsx file:

import { LinkContainer } from './typings/LinkContainer';

Visual Studio builds without a problem but when I try to run webpack I get the following error:

ERROR in ./Features/Menu/Menu.tsx
Module not found: Error: Can't resolve './typings/LinkContainer' in 'C:\Users\<user>\Documents\<solution>\<project>\Features\Menu'
 @ ./Features/Menu/Menu.tsx 19:22-56
 @ ./Features/App.tsx
 @ ./Features/index.tsx
 @ multi react-hot-loader/patch ./Features/index.tsx

File content for LinkContainer.d.ts:

import { ComponentClass } from "react";
import { NavLinkProps } from "react-router-dom";

type LinkContainer = ComponentClass<NavLinkProps>;
export const LinkContainer: LinkContainer;
Ogglas
  • 62,132
  • 37
  • 328
  • 418
  • Have you tried including the extension in the import statement, e.g. `import { LinkContainer } from './typings/LinkContainer.tsx';` – Jayce444 May 18 '17 at 10:25
  • @Jayce444 The problem I'm having is that this is not my module, it is a module downloaded from `npm`, `react-router-bootstrap`, located in `node_modules\react-router-bootstrap`. The types downloaded from npm does however not match the module itself. How can I reference my types file to reference this module? – Ogglas May 18 '17 at 10:29

1 Answers1

0

The problem was that only type definitions were loaded and not the module itself. Solved with import { LinkContainer } from 'react-router-bootstrap';. You can read my answer here about custom types which was the reason for creating a custom type in the first place: https://stackoverflow.com/a/44046969/3850405

Community
  • 1
  • 1
Ogglas
  • 62,132
  • 37
  • 328
  • 418