TypeScript error TS2305: has no exported member when importing a function

8.1k views Asked by At

I have 2 TS files then export just functions (no clesses, interfaces, etc), for example:

// the-folder/file1.ts
export function func1() { ... };

// the-folder/file2.ts
export function func2() { ... };

and I created a barrel index.ts:

// the-folder/index.ts
export * from "./file1";
export * from "./file2";

Now, I wanted to use it in another TS file, simply importing those func1() and func2():

// different-folder/some-other-file.ts
import { func1, func2 } from "../the-folder";

But here I get the error:

TS2305: Module has no exported member 'func1'

and same for func2.

What am I missing?

UPDATE

I created a stackblitz - and it works there! But not in the project.

UPDATE 1

If I change the import to:

import { func1, func2 } from "../the-folder/index";

it works.

0

There are 0 answers