Value TypeScript definition files update

5 posts, 1 answers
  1. Matjaž
    Matjaž avatar
    80 posts
    Member since:
    Jul 2015

    Posted 11 Oct Link to this post

    I think you should fix value when getting date value to return Date | null:

    class DatePicker extends kendo.ui.Widget {
     
        static fn: DatePicker;
     
        options: DatePickerOptions;
     
     
        element: JQuery;
        wrapper: JQuery;
     
        static extend(proto: Object): DatePicker;
     
        constructor(element: Element, options?: DatePickerOptions);
     
     
        close(): void;
        destroy(): void;
        enable(enable: boolean): void;
        readonly(readonly: boolean): void;
        max(): Date;
        max(value: Date): void;
        max(value: string): void;
        min(): Date;
        min(value: Date): void;
        min(value: string): void;
        open(): void;
        setOptions(options: any): void;
        value(): Date;                  //!!! OR null
        value(value: Date): void;
        value(value: string): void;
     
    }

  2. Matjaž
    Matjaž avatar
    80 posts
    Member since:
    Jul 2015

    Posted 11 Oct Link to this post

    And also for set:

    value(): Date | null;
    value(value: Date | null): void;
    value(value: string | null): void;

  3. Kendo UI is VS 2017 Ready
  4. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    348 posts

    Posted 12 Oct Link to this post

    Hello ,

    Thank you for the observations and the suggestion, but null, returned from a method with return type of Date is valid TypeScript. For example:

    https://www.typescriptlang.org/play/index.html 

    Change the greet() function return type to Date, and return null, e.g.: 

    greet():Date {
    return null; // no TypeScript warning
        }

    Let us know if you have other questions or comments, regarding Kendo UI.

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
  5. Matjaž
    Matjaž avatar
    80 posts
    Member since:
    Jul 2015

    Posted 13 Oct in reply to Dimiter Topalov Link to this post

    This is not true.

    get value(): Date
    {
        return null;      
    }

    raise error on build:

    ErrorBuild:Type 'null' is not assignable to type 'Date'.

    You can check it in Visual studio 15 preview 4 with this tsconfig.json options:

    {
      "compilerOptions": {
        "module": "amd",
        "noEmitOnError": true,
        "noImplicitAny": true,
        "removeComments": true,
        "sourceMap": true,
        "strictNullChecks": true,
        "target": "es6",
        "experimentalDecorators": true
      },
        "exclude": [
            "node_modules",
            "wwwroot"
        ]
    }
  6. Answer
    Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    348 posts

    Posted 14 Oct Link to this post

    Hi Matjaž,

    The described behavior occurs with strictNullChecks enabled only. We do not fully support all possible compiler options and TypeScript versions, but I have logged an issue in our GitHub repository, based on the provided information, and you can expect the updated definitions in a future release:

    https://github.com/telerik/kendo-ui-core/issues/2312

    Meanwhile disabling the strictNullChecks should prevent the described error.

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top
Kendo UI is VS 2017 Ready