Datatables/Angular Subsequent property declarations must have the same type.

Datatables/Angular Subsequent property declarations must have the same type.

vikClevikCle Posts: 8Questions: 0Answers: 0

I am using Angular 13 and installed datatables.net@1.11.5
The issue is when I run "ng serve" and there is a compilation error saying:

Error: node_modules/datatables.net/types/types.d.ts:33:9 - error TS2717: Subsequent property declarations must have the same type. Property 'dataTable' must
be of type 'StaticFunctions', but here has type 'jQueryDataTable'.

33 dataTable: jQueryDataTable;
~~~~~~~~~

node_modules/@types/datatables.net/index.d.ts:17:5
17 dataTable: DataTables.StaticFunctions;
~~~~~~~~~
'dataTable' was also declared here.

Does anyone have the same issue?

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    According to this SO thread, it's when the same module is listed twice in different dependencies/versions. The thread isn't specific to DataTables but it looks like there are two solutions there. Could you take a look, please, and see if this sorts you out,

    Colin

  • vikClevikCle Posts: 8Questions: 0Answers: 0

    Thank you Colin!
    You're right the same module is listed twice. And it is related to DataTables.

    in the node_modules/datatables.net/types/types.d.ts file declared interface JQuery and it has property
    dataTable declared as jQueryDataTable;

    interface JQuery {
    DataTable<T = any>(opts?: DataTables.Settings): DataTables.Api<T>;
    dataTable: jQueryDataTable;
    }

    and in the node_modules/@types/datatables.net/index.d.ts file declared interface JQuery and it has property
    dataTable declared as DataTables.StaticFunctions;

    interface JQuery {
    DataTable(opts?: DataTables.Settings): DataTables.Api;
    dataTable: DataTables.StaticFunctions;
    }

    If I install an older version of DataTables like 1.10.19, it does not have this problem.
    Any idea?

  • sparkstersajjadsparkstersajjad Posts: 10Questions: 4Answers: 0
    edited May 2022

    yes, upgrading to latest versions cause this issue. any update ?

  • allanallan Posts: 63,572Questions: 1Answers: 10,482 Site admin

    Sorry, you would mean that you still have node_modules/@types/datatables.net/index.d.ts installed? If so, remove it - DataTables ships with its own type files now.

    Allan

Sign In or Register to comment.