Datatables/Angular Subsequent property declarations must have the same type.
Datatables/Angular Subsequent property declarations must have the same type.
in DataTables
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?
This discussion has been closed.
Replies
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
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?
yes, upgrading to latest versions cause this issue. any update ?
Sorry, you would mean that you still have
node_modules/@types/datatables.net/index.d.tsinstalled? If so, remove it - DataTables ships with its own type files now.Allan