Reputation: 147
I'm used to using ES6 syntax. I tend to aggregate my React Component files into one "import" file which I use as the index.js of my Components folder. This allows me to write destructing imports like so:
import { App, Ticker, Timer } from "./components"
Inside of my index.js file I can easily write export from import commands like so:
export App from "./app"
export Ticker from "./ticker"
export Timer from "./timer"
Is there a way I can do this in TypeScript? I can't seem to get index.ts to be recognized as the default file in a module. Is there also any syntax to export an import in TypeScript?
Upvotes: 6
Views: 2609
Reputation: 4185
Just add curly braces like so:
export { App } from "./app";
export { Ticker } from "./ticker";
export { Timer } from "./timer";
Hope it helped
Upvotes: 0
Reputation: 275867
Is there a way I can do this in TypeScrip
Just use the es6 export *
syntax:
export * from "./components";
Alternatively you can still do:
export {App,Ticker,Timer} from "./compoents"
Upvotes: 8