How do I export an object in TypeScript?

In ES6 you are allowed to export names using the export function, or for default you can export anything.
The require format goes like this:

let config = require('config')

And it takes the default export of config file.
In your case, you should do:

export default config[env]

If you want to use the export, you would do something like:

let Environment = config[env];
export {Environment}

The difference would be:

import EnvirmentNameWhatever from "./config"

to

import {Environment} from "./config"
  • Note – when default exporting, you can use whatever name you like, while when just exporting, you have to use the exported name.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)