This is a migrated thread and some comments may be shown as answers.

Describe a Method`s Input Parameters and Output Type exactly

46 Answers 146 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mgs
Top achievements
Rank 1
mgs asked on 17 Mar 2013, 02:58 PM
When reading the documentation I rather often do not know, what datatypes are expected as parameters or which datatype is returned from a method call. I appreciated, if these details were given in the documentation.

Let me make an example. Look at TreeView expand method. The parameter is described as "nodes Selector". What does this mean? Is it a jQuery selector such as "#tree" or "div.tree"? Or is this an DOM object or maybe a jQuery object? The samples show that probably both a selector or a DOM object can be given to the method. If this is so, I would like to read it in the documentation.

A user might also try to find out about method parameters by looking at the TypeScript definition. There he will find...
class TreeView extends kendo.ui.Widget {
    expand(nodes: string): void;
}
Probably this is not correct, as the samples show that also a DOM object can be expanded.

Michael G. Schneider

46 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 18 Mar 2013, 09:22 AM
Hello Michael,

The parameter of the expand/collapse method can be a string, a DOM element, or a jQuery object, because it is internally wrapped in a jQuery object (roughly, parameter = $(parameter)). The documentation will be updated shortly with the proper signature, and the TypeScript definitions have been patched, as noted in the other thread you started.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 20 Mar 2013, 10:39 AM
Hello Alex,

thanks a lot for the answer,

Michael G. Schneiderf
0
mgs
Top achievements
Rank 1
answered on 21 Mar 2013, 05:36 PM
Hello Alex,

please look at TreeView.parent.
  • The parameter is described as "Element". As the sample shows, it can also be a "jQuery".
  • Moreover, from reading the documentation how can I know what comes back? Is it a DOM Element or is it a jQuery Element?
The parameters and the return type should be described exactly. I would really appreciate that. It is rather difficult, to find out by trying. Especially the return types are mostly not well described.

Looking at the TypeScript definition is no real help. Neither the parameter nor the return type seems to be correct.
class TreeView extends kendo.ui.Widget {
    parent(node: Element): void;
}
When seing such problems in the documentation, what should be done? Will these shortcomings be addressed in a service pack on a global basis? Or is it reasonable to create entries here in the forum?

Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 22 Mar 2013, 10:04 AM
Hello Michael,

There have been some discrepancies in the API documentation of the TreeView, which we now fixed. Element always denotes a DOM element, and jQuery denotes a jQuery object. Such shortcomings in the TypeScript will be addressed with each internal build -- but we appreciate every feedback we get, so you are encouraged to let us know if you stumble upon such problems. Your Telerik points have been updated for this bug report.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 27 Mar 2013, 06:19 AM
Hello Alex,

if a method has several signatures, e.g. accepting a "selector string" or a "DOM element" or a "jQuery element", I suggest you do not describe the parameter as "any", but you use overloading instead.

Intellisense would greatly benefit from it.

Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 27 Mar 2013, 01:16 PM
Hello Michael,

Thank you for the feedback. Because implementing this requires a non-trivial effort, we have logged it and will consider it for future releases.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 27 Mar 2013, 02:29 PM
Hello Alex,

thanks a lot for the answer and the points. You might include overloading widget by widget. It need not be done all at once.

Out of curiosity: how do you create the definition file? Is it written by hand? Do you generate it out of some database, containing all classes and methods? Maybe by scanning the comments in the source code?

Michael G. Schneider
0
Accepted
Alex Gyoshev
Telerik team
answered on 27 Mar 2013, 02:55 PM
Hello Michael,

Some of the file is written by hand; most of the definitions are generated from the public API. The methods in question are generated, and creating all correct signatures is the non-trivial task that I mentioned (i.e. taking into account the different types, as well as optional parameters).

All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 28 Mar 2013, 07:10 PM
Hello Alex,

the following definitions are missing

  • kendo.Class
  • kendo.Observable inheriting from kendo.Class
  • kendo.ui.plugin
  • DataSource.create

 Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 01 Apr 2013, 02:36 PM
Hello Michael,

We have added the Class class, as well as the inheritance. Both the kendo.ui.plugin and the DataSource.create methods are not documented and will not be added to the TypeScript definitions until they are.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 01 Apr 2013, 04:23 PM
Hello Alex,

thanks a lot for the answer. Would you please elaborate on...
  • You say that you included the "Class" and the inheritance. Where can I download that file? Or is it for internal use only? I very much appreciated, if the file were always available in its most recent version.
  • I do not understand this "not documented" statement. At least kendo.ui.plugin is documented (please see kendo.ui.plugin).
  • Aren't those two methods officially supported? Shouldn't they be used? After all, they are needed for plugin development.
Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 02 Apr 2013, 07:51 AM
Hello Michael,

I am sorry to have mislead you. Both methods are documented, and have been added to the attached TS file.

All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 02 Apr 2013, 08:23 AM
Hello Alex,

thanks a lot for the answer and the definition file.

One more suggestion: the static method DataSource.create is mentioned in blog entries. However, it is not documented in API Reference. At least, I never saw it somewhere.

Michael G. Schneider

0
Alex Gyoshev
Telerik team
answered on 02 Apr 2013, 08:43 AM
Hello Michael,

Yes, that mislead me that it is not documented. It can be found in both blog posts and the getting started help topic; it will be documented shortly.

All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 06 Apr 2013, 09:52 AM
Hello Alex,

the methods "static fn" and "static extend" should be added to "kendo.Observable" and "kendo.ui.Widget".

I am not sure whether the static methods should automatically be inherited into the two classes per Typescript language definition. Anyway, in reality they are not inherited. Including the definitions into Observable and Widget fixes this.

Even if inheriting the static methods would work, the return type should not be "Object". Calling "init" on "fn" is impossible that way.

Moreover, the options parameter in the Kendo.View's constructor is missing.

Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 10 Apr 2013, 08:34 AM
Hello Michael,

Indeed, static members are not inherited in TypeScript. I'm attaching the latest TS definitions.

Greetings,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 10 Apr 2013, 04:57 PM
Hello Alex,

thanks a lot for the answer and the definition file. I looked at the options for the kendo.View constructor.
  • It has several properties (e.g. title, reload, defaultTransition, etc.) which are not described in the documentation.
  • The documentation describes the properties "tagName" and "wrap", which are not part of the ViewOptions interface.
Maybe the additional properties in the interface do not belong there. Probably, they are from mobile. However, "tagName" and "wrap" should be listed in the interface.

Moreover, the kendo.View constructor has an "Element" parameter in this definition file. However, a string can be passed as the first parameter.

Moreover, calling "widget.fn.init" is not possible. Method "init" is missing.

Moreover, using keno.ui.plugin is not possible due to its first parameter "widget: Function". Type 'Widget' is missing property 'prototype' from type 'Function'.

Michael G. Schneider

0
Accepted
Alex Gyoshev
Telerik team
answered on 12 Apr 2013, 02:30 PM
Hello Michael,

Thank you for your feedback. You can find attached the updated definitions file.

All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 12 Apr 2013, 03:43 PM
Hello Alex,

thanks a lot. I did a quick check and all problems were gone.

Michael G. Schneider
0
mgs
Top achievements
Rank 1
answered on 15 Apr 2013, 08:01 AM
Hello Alex,

  • kendo.ui.ListViewOptions.selectable isn't a string, it is a bool
  • kendo.ui.GridViewOptions.selectable is declared as any, but might be declared bool
Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 16 Apr 2013, 11:24 AM
Hello Michael,

The Grid selectable option can be either a bool or a string ("multiple, row"). The same is valid for the ListView selectable option, so both need to be of any type. The attached definitions address this.

All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 16 May 2013, 08:57 AM
Hello Alex,
  • kendo.ui.WindowOptions.height currently is a "number", shouldn't that be "string" or even "any"
  • same for maxHeight, minHeight, width, ...
  • kendo.fx seems to be missing
  • shouldn't kendo.ui.WindowAnimationClose contain a "reverse"
  • same for WindowAnimationOpen
Regarding the WindowOptions's height/width, the API Reference also describes these parameters as "Number".

Regarding WindowAnimationClose, the API Reference does not mention a "reverse".

Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 18 May 2013, 11:32 AM
Hello Michael,

  • kendo.ui.WindowOptions.height currently is a "number", shouldn't that be "string" or even "any", same for maxHeight, minHeight, width, ...
    This is valid for width and height. The min/maxWidth/Height support only pixel values (i.e. numbers).
  • kendo.fx seems to be missing
    Added.
  • shouldn't kendo.ui.WindowAnimationClose/Open contain a "reverse"
    Added.
All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 13 Jun 2013, 01:34 PM
Hello Alex,

the following seems to be missing.
  • kendo.data.binders
  • kendo.data.Binder.extend
  • kendo.data.Binder.fn
Michael G. Schneider
0
mgs
Top achievements
Rank 1
answered on 13 Jun 2013, 01:35 PM
Hello Alex,

the following seems to be missing.

kendo.data.binders
kendo.data.Binder.extend
kendo.data.Binder.fn

P.S.: I initally created this post with an unordered list. When trying to post, the message "Invalid post content" appeared in red under the input  textarea.

P.S.P.S.: Yesterday the previous post with the bulleted list was not shown. It appeared today.

Michael G. Schneider
0
Alex Gyoshev
Telerik team
answered on 17 Jun 2013, 10:48 AM
Hello Michael,

Thanks for reporting these -- they have been added.

Regards,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 17 Jun 2013, 12:11 PM
Hello Alex,

thanks a lot for the answer. Maybe I am doing something wrong. I also reported...

kendo.data.Binder.extend
kendo.data.Binder.fn

Shouldn't they also be inserted into the file?

Michael G. Schneider


P.S.: Once again the "invalid post content" message appeared, when I posted this text with a bulleted list. Is this a problem on my side or is it a general problem with the forum?
0
mgs
Top achievements
Rank 1
answered on 17 Jun 2013, 12:12 PM
It is impossible to post reliably, "invalid post content" is given.
0
mgs
Top achievements
Rank 1
answered on 17 Jun 2013, 12:18 PM
Post may not contain bullets, must be short
0
mgs
Top achievements
Rank 1
answered on 17 Jun 2013, 12:19 PM
I also reported kendo.data.Binder.extend and kendo.data.Binder.fn. Why are they missing?
0
Alex Gyoshev
Telerik team
answered on 18 Jun 2013, 08:26 AM
Hello Michael,

I am sorry, I just inherited the Binder class from kendo.Class. The members should be present in the attached file.

Thank you for reporting the problem with the forums, we have notified the developers who work on this functionality.

Regards,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 19 Jun 2013, 05:40 PM
Hello Alex,

With Typescript v0.9 some change have to be made to the definition file...

  • error TS1046: 'declare' modifier required for top level element
    for example "module kendo"
  • error TS1038: 'declare' modifier not allowed for code already in an ambient context.
    for example "declare function bind" inside "module kendo"
Michael
0
Atanas Korchev
Telerik team
answered on 20 Jun 2013, 06:36 AM
Hi Michael,

 There is already a thread about this TypeScript 0.9 backwards compatibility issue: http://www.kendoui.com/forums/framework/general-discussions/typescript-0-9-0-support.aspx

 I am closing this one because it digressed from the original topic. Feel free to open new ones if you need to report anything else.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 06:54 AM
Hello Atanas,

thanks a lot for the answer. Would you please check kendo.data.Binder.fn.init, which is marked as an error.

Michael G. Schneider
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 06:54 AM
Hello Atanas, thanks a lot for the answer. Would you please check kendo.data.Binder.fn.init, which is marked as an error. Michael G. Schneider P.S. Again "Invalid Post Content" on multiline posts.
0
Atanas Korchev
Telerik team
answered on 20 Jun 2013, 07:12 AM
Hi Michael,

 I am not sure what "check kendo.data.Binder.fn.init, which is marked as an error" means. Please elaborate.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 07:29 AM
Hello Atanas,

"kendo.data.Binder.fn.init.call(this, element, bindings, options)" is typically done in "init" when extending "kendo.data.Binder".

However, with your definition file the above call is not possible, because the property "init" does not exist on value of type "Binder".

Michael G. Schneider
0
Atanas Korchev
Telerik team
answered on 20 Jun 2013, 07:47 AM
Hello,

 That definition wasn't changed as part of the 0.9 compatibility update. Perhaps this is another breaking change in TypeScript 0.9. You can try using TypeScript inheritance instead.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 08:04 AM
Hello Atanas,

I am not sure it has anything to do with Typescript v0.9. Inside the definition file we can find...
class Binder extends Class {
      static fn: Binder;
      etc.
}
So, if "kendo.data.Binder.fn.init" is to be valid, then "class Binder" must contain a method "init". It does not contain it directly, so it must be part of "class Class", which is definied as... 
class Class {
   static fn: Class;
   static extend(prototype: Object): Class;
}
Also there seems to be no "init". Or do I overlook the obvious?

Michael G. Schneider
0
Atanas Korchev
Telerik team
answered on 20 Jun 2013, 08:09 AM
Hi Michael,

 I repeat that there is no difference between the latest and previous definitions files when it comes to the fn property. You can also use "prototype" instead of it. They are virtually the same. However I still recommend using TypeScript inheritance. Here is a demo:

module kendo.data.binders
{
    export class custom extends kendo.data.Binder
    {
        constructor(element: Element, bindings: { [key: string]: Binding; }, options?: any)
        {
            super(element, bindings, options);
        }

        refresh() {
            var value = this.bindings["custom"].get();
            $(this.element).text(value);
        }
    }
}

$(function () {
    kendo.bind(document.body, {
        value: "custom value"
    })
});


<div id="content" data-bind="custom: value"></div>

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 08:30 AM
Hello Atanas,
thanks a lot for the answer.
- I do know that the definition file for v0.9.0 does not change anything regarding fn.
- The problem with fn has already existed before.
- As you can see with the previous discussion with Alex, several methods regarding "Binder" had been missing.
- Using "prototype" does not change anything. It also brings the error.
- Using Typescript inheritance might be an option later. However, today I just want my existing code to be compiled.
Of course I already made my code compilable, by simply changing...
class Binder extends Class {
   static fn: any;
   // etc.
}
However, I suggest you also change something in the definition file for solving the problem.
Michael G. Schneider
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 08:32 AM
Hello Atanas, thanks a lot for the answer. I do know that the definition file for v0.9.0 does not change anything regarding fn. The problem with fn has already existed before. As you can see with the previous discussion with Alex, several methods regarding "Binder" had been missing. Using "prototype" does not change anything. It also brings the error. Using Typescript inheritance might be an option later. However, today I just want my existing code to be compiled. Of course I already made my code compilable, by simply changing... class Binder extends Class {    static fn: any;    // etc. } However, I suggest you also change something in the definition file for solving the problem. Michael G. Schneider  P.S. the error "Invalid Post Content" kills any fun in using the forum.
0
Atanas Korchev
Telerik team
answered on 20 Jun 2013, 08:44 AM
Hi Michael,

 Using TypeScript inheritance is the supported approach. The init method is replaced with the TypeScript constructor. If you for some reason don't want to use TypeScript constructors you can define the init method manually in the definition file:

init(element: Element, bindings: { [key: string]: Binding; }, options?: any)

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 08:49 AM
Hello Atanas,

sorry, we obviously have a different opinion. I think that the definition file should be written, so any valid Javascript can be inserted into a Typescript file. If this is not so, migration will not be as easy.

Michael G. Schneider
0
mgs
Top achievements
Rank 1
answered on 20 Jun 2013, 09:54 AM
Hello Atanas,

I played with your code using inheritance for binder creation. I have problems making it compile, if it is used in combination with external modules. Just take your code, put it in some Typescript file, add a reference to kendo.all.d.ts, and it will compile fine.

Now, add a module import into the file, and try to compile again. Now, there are several "does not exist" errors.

Michael G. Schneider
0
Atanas Korchev
Telerik team
answered on 20 Jun 2013, 10:50 AM
Hello,

 I cannot reproduce this problem. Since this thread is no longer related to the original subject I am going to close it. Feel free to open a new one and provide an example showing that TypeScript inheritance doesn't work.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
mgs
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
mgs
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or