Thursday, 18 May 2017

Typescript version of a config.js file

Typically I'll have a config.js file that looks something like this:

config.js

module.exports = {
  secret: "sdlfjlsdjkflsdjfsdjflsdjf",
  terminal_id: '39493843',
  transaction_key: 'asdfsldkfjdslkfjsdl'
};

And I'll use it like this:

index.js

const config = require('./config');
console.log(config.secret);

What is the typescript way of doing this? What does the config.ts file look like and how do I import it in the index.ts file?



via Dave

No comments:

Post a Comment