I am in the process of translating some of my code over, and I have noticed a peculiar behavior with the typing enforcement. I am not sure it is 'peculiar', it may very well be expected, but I am curious as to how to get around it.
For this example, I am using Kendo UI
's kendoWindow
widget, but almost any 'type' from any kind of library is sufficient to demonstrate it.
export function UserWindow(options) {
var settings = $.extend({
// default settings
}, options);
var $WINDOW = <kendo.ui.Window> {};
$WINDOW = $("<div id='kendo-editor-window' />")
.kendoWindow(settings) // this is where we have now declared the type, basically
.data("kendoWindow");
// here, I want to add my own little method to kendoWindow for the purpose of how
// I intend to use it!
$WINDOW.databind = function(e) { // this is where we run into trouble!
// some code goes here
}
return $WINDOW;
}
Now under normal Javascript, this does not give me any trouble. But .databind(e)
is not a defined function of kendoWindow
, and therefore it is actually balking at me adding it like this.
I have been able to get around it by not declaring the variable as a type of kendo.ui.Window
, but I would like to discover how to APPROPRIATELY handle this situation, in other words, extend the type properly so that I get intellisense and the whole type safety thing if it is at all possible.