There is the following class given in Javascript:
'MyInsetsProvider': new yfiles.lang.ClassDefinition(function() {
/** @lends {DemoGroupStyle.MyInsetsProvider.prototype} */
return {
'$with': [yfiles.input.INodeInsetsProvider],
/** @return {yfiles.geometry.Insets} */
'getInsets': function(/**yfiles.graph.INode*/ item) {
var margin = 5;
return new yfiles.geometry.Insets(
BORDER_THICKNESS + margin, HEADER_THICKNESS + margin,
BORDER_THICKNESS + margin, BORDER_THICKNESS + margin);
}
};
}),
I have three questions to it:
1, what is the 'function()' at the beginning? Is it a class and a function at the same time?
2, what does the '$with' mean?
3, how can we migrate it into TypeScript?
function()
defines a function. In this case it looks like a callback that when called returns an object. Nope, it's not a "proper" class although it appears to define a yfiles class."$with"
is a string being used as an object key.ts
and run it through a TypeScript compiler and it'll work.