In my app, I use a configuration file named conf.ts
to consolidate config values from other files for better organization. By merging these values, it becomes more convenient to access them using Conf.MY_LONG_NAMED_VALUE
rather than
Conf.SubCategory.MY_LONG_NAMED_VALUE
.
import {CoreConf} from './conf/game/core.conf';
import {ViewConf} from './conf/view/view.conf';
import {DebugConf} from './conf/game/debug.conf';
/**
*
* @namespace Conf
*/
export const Conf: {[index: string] : any} = $.extend({},
CoreConf,
DebugConf,
ViewConf
);
As I transition from JavaScript to TypeScript, I have noticed that while code completion worked in WebStorm for JavaScript (thanks to the JSDoc tag @namespace
), TypeScript does not provide autocomplete suggestions for config names within sub categories.
I have considered two solutions - either organizing each config file as an individual object (less structured) or creating an index signature/interface with all config names (more effort). Is there a more efficient way to achieve this?