type IMethod = 'init' | 'update' | 'destroy';
(function ($) {
let methods: any = {
init: function(settings: ISettings): JQuery {
// code
},
};
$.fn.plugin = function (method: IMethod, value: {}): JQuery {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call( arguments, 1));
} else {
// error
}
return this;
};
}(jQuery));
$('#elementId').plugin('init', {
// settings
});