I'm fairly new to TS and wanted some advice on how to pass an object literal to a method in the most efficient manner.
E.g. (called in html)
<script>
app.setOptions({
width: 820,
height: 450,
bgColor: '#fff'
});
</script>
In main.ts
module app {
app.setOptions = function(options: { width: number, height: number, bgColor: string}) {
options.width = options.width || 600,
options.height = options.height || 300,
options.bgColor = options.bgColor || '#fff';
initializeApp(options);
}
}
Note: This works fine, although I'm warned about 'the property setOptions does not exist on type 'typeof app'. I'm going to add loads more options too.