Search code examples
angularkendo-ui-angular2

kendo-upload: inconsistency in FileInfo?


In the example here, in View Source, in upload.component.ts there is the following code:

  public imagePreviews: FileInfo[] = [];

(...)

        reader.onload = function (ev) {
          const image = {
            src: ev.target.result,
            uid: file.uid
          };

          that.imagePreviews.unshift(image);
        };

If I use it, I get the following error:

Argument of type '{ src: any; uid: string; }' is not assignable to parameter of type 'FileInfo'. Property 'name' is missing in type '{ src: any; uid: string; }' but required in type 'FileInfo'.

If I check here, I see that src is not an element of FileInfo and therefore the error I get makes sense, indeed. However, I don't understand why it works in their web-page and how could I make it work.

Thank you!


Solution

  • That is an error, indeed. If you simply change

    imagePreviews: FileInfo[] = [];

    with

    imagePreviews = [];

    it will work without raising any problem.

    Even though the properties of FileInfo and const image don’t match, the properties of FileInfo are not used in image and therefore the program runs as expected (despite the errors).