This is probably a long shot, but I'm hitting a brick wall and this may not be possible, but I at least want a second opinion before I give up.
I'm building a library where I want the user to initialize it using a settings object for their custom settings:
interface IGuildSettings {
[key: string]: ISetting;
}
Is there any way (and if so, what is the best way?) to make the object they put in be used in other functions throughout the library? For example, if the user does:
mylib.initialize({ hello: {...stuff here...} });
would there be a way to make it so
mylib.setSetting('hello', 1); // Works
mylib.setSetting('nope', 1); // TypeScript errors because nope isn't valid
I would share code, but I got pretty far using a generic/singleton before I realized that obviously that type wouldn't carry over between functions. Any advice?