Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript build error - what is wrong with this?

Tags:

typescript

I have recently updated VS2017 and I am seeing a lot of typescript build errors.

The errors are all the same, and all relate to the validity of d.ts files.

Here is the some code in a d.ts file that is causing a typescript compilation error (TS2411):

interface JQueryAjaxSettings {
}

interface DataSourceTransportCreate extends JQueryAjaxSettings {
    cache?: boolean;
    contentType?: string;
    data?: any;
    dataType?: string;
    type?: string;
    url?: any;
}

interface DataSourceTransport {
    create?: DataSourceTransportCreate;
    destroy?: DataSourceTransportDestroy;
    push?: Function;
    read?: DataSourceTransportRead;
    signalr?: DataSourceTransportSignalr;
    update?: DataSourceTransportUpdate;

    parameterMap?(data: DataSourceTransportParameterMapData, type: string): any;
}

interface DataSourceTransportOptions {
    success: (data?: any) => void;
    error: (error?: any) => void;
    data: any;
}

interface DataSourceTransportWithFunctionOperations extends DataSourceTransport {
    create?: (options: DataSourceTransportOptions) => void;
    destroy?: (options: DataSourceTransportOptions) => void;
    read?: (options: DataSourceTransportReadOptions) => void;
    update?: (options: DataSourceTransportOptions) => void;
}

The error is:

TS2430 (TS) Interface 'DataSourceTransportWithFunctionOperations' incorrectly extends interface 'DataSourceTransport'. Types of property 'create' are incompatible. Type '(options: DataSourceTransportOptions) => void' has no properties in common with type 'DataSourceTransportCreate'. Scripts (tsconfig project) C:\Users****\typings\kendo\kendo.all.d.ts 1202 Active "

This error is repeated for a whole host of other properties.

My question is - is this definition valid? Has there been some change that would cause this to suddenly become invalid (i.e shown as a build error in VS)?

like image 800
Darrell Avatar asked Mar 14 '26 18:03

Darrell


1 Answers

No, the definition is not valid. DataSourceTransportWithFunctionOperations's override of create(options: DataSourceTransportOptions): void is not compatible with the base create: DataSourceTransportCreate, which isn't a function at all, but an options bag.

Typescript has only detected these errors with option bags since 2.4, and this particular one maybe only since 2.5, since it involves a method type. The change is probably that your latest VS update switched you from Typescript 2.3 or 2.4 or higher.

The underlying problem is that the kendo typings are out of date. As you found, the official typings got a fix in August. If you update your typings, most should be fixed to compile without errors on newer versions of Typescript.

like image 73
Nathan Shively-Sanders Avatar answered Mar 16 '26 09:03

Nathan Shively-Sanders



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!