I want to import the model's interface and at the same time export the model interface from that file.
I wrote the following code to import the model's interface and use it in that file and export that interface externally.
// api/service/post.interface.ts
export import { Post } from '../../model/interface/post.interface.ts;
// -> An import declaration cannot have modifiers.
type PostPayload = Partial<Post>;
// api/service/post_create.ts
import { Post } from './post.interface';
// -> this path has no exported member 'Post'
const a = (title: Post['title']) => {
...
}
What did I make a mistake?
You can't both import something to use locally and export it in a single declaration, they have to be separate ones:
import { Post } from '../../model/interface/post.interface.ts;
export { Post };
Although it's possible to re-export something in a single statement, like this:
export { Post } from '../../model/interface/post.interface.ts;
...it doesn't create a local binding you can use. It's just a re-export, not an import.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With