Reputation: 433
I have a class exported from a typescript file called foo.ts
export default class Foo{
}
And I'm trying to import it in another file in the same directory
import {Foo} from './foo';
Which gives me an error
Module '"foo"' has no exported member 'Foo'.
I've looked around online to solve this, but closest I've got is this github issue https://github.com/Microsoft/TypeScript/issues/16475 which is still unresolved at the time of writing.
Am I missing something obvious here? Shouldn't this be valid code?
Upvotes: 0
Views: 1619
Reputation: 21961
These are the options to export/import things:
// foo.js
export default class Foo{
}
// bar.js
import Foo from './foo'
// foo.js
export class Foo{
}
// bar.js
import {Foo} from './foo'
Have a look at the above and you can see that you've mixed the two approaches in the wrong way.
Upvotes: 3