Sandbox: https://codesandbox.io/s/typescript-export-question-tlbd2
error will be on export type {
type abc = {
a: string;
};
type bbc = {bbb: string}
export type {
abc,
bbc,
}
Is exporting types something not suppose to be done? I am trying to reuse types as much as I can. If there is better alternatives plz let me know
If you are trying to export the types so that you can import them like this:
import { abc, bbc } from './my-types';
You can simply export when declaring them:
export type abc = {
a: string;
};
export type bbc = {bbb: string}
But you might also be looking for TypeScript namespace
, if that is the case please look at the documentation here .
I think your only issue is adding the keyword type
to your export:
type abc = {
a: string;
};
type bbc = {bbb: string}
export { abc, bbc }
Does this work for you or do you still get the same error?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.