Reputation: 1962
This should be such a simple problem but for some reason I can't figure it out.
I have two files:
//Exporter.ts
export module Exporter {
function foo = { return 1; }
}
//Importer.ts
import { foo } from './Exporter';
This gives me a typescript error Exporter has no exported member foo
But it's clearly being exported. What is the problem here?
Upvotes: 1
Views: 567
Reputation: 45252
You don't need the export module...
wrapping code inside Exporter.ts
.
The entirety of Exporter.ts
became a module as soon as you added the export
keyword to it.
Simply write:
// Exporter.ts
export function foo() { return 1; }
// Importer.ts
import { foo } from './Exporter';
Upvotes: 1