I have created multiple interfaces and want to ship them all from a common index.ts
file as shown below:
--pages
------index.interface.ts
--index.ts
Now In my index.ts
I am exporting something like:
export { timeSlots } from './pages/index.interface';
whereas my index.interface.ts
look like this:
export interface timeSlots {
shivam: string;
daniel: string;
jonathan: string;
}
Now when I try to do so, it says me:
Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.ts(1205)
Not sure why this error shows up, can someone help?
CodePudding user response:
You just need to use this syntax when re-exporting types:
export type { timeSlots } from './pages/index.interface';
// ^^^^
// Use the "type" keyword
Or, if using a version of TypeScript >= 4.5
, you can use the type
modifier on the name instead:
export { type timeSlots } from './pages/index.interface';
// ^^^^
// Use the "type" keyword