I am working on a web application using TypeScript. For some parts of the application, I would like to define a simple configuration file that specifies certain aspects (for example the color palette).
How would I create such a configuration file? In JavaScript, creating config.js and referencing it in the HTML code is a very simple solution. What would be the best solution for TypeScript? Maybe a separate Config.ts file?
In Solution Explorer, right-click the project node, and then select Add > New Item. The Add New Item dialog box appears. Expand Installed > Visual C# Items. In the middle pane, select the Application Configuration File template.
You can do it the following way.
First define structure of your config file, in lets say config.ts:
export interface Config {     uriPath: string;        port: number;        settings: string[]; }   Then create config.json that actually holds the data:
{     "uriPath": "mgNation",     "port": 1506,     "settings": [         "=[tor.start]",         "=[copp.start]"     ] }   And consume it in your app.ts:
let config: Config = require('./path/to/config.json'); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With