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

Value TypeScript definition files update

4 Answers 98 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Seyfor
Top achievements
Rank 1
Seyfor asked on 11 Oct 2016, 01:12 PM

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;
 
}

4 Answers, 1 is accepted

Sort by
0
Seyfor
Top achievements
Rank 1
answered on 11 Oct 2016, 01:14 PM

And also for set:

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

0
Dimiter Topalov
Telerik team
answered on 12 Oct 2016, 02:08 PM
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.
0
Seyfor
Top achievements
Rank 1
answered on 13 Oct 2016, 07:08 AM

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"
    ]
}
0
Accepted
Dimiter Topalov
Telerik team
answered on 14 Oct 2016, 11:45 AM
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.
Tags
Date/Time Pickers
Asked by
Seyfor
Top achievements
Rank 1
Answers by
Seyfor
Top achievements
Rank 1
Dimiter Topalov
Telerik team
Share this question
or