TypeScript definition for datatables.net-buttons broken
TypeScript definition for datatables.net-buttons broken
I am trying to integrate datatables.net-buttons 3.1.2 into my typescript project, but I am getting a compiler error on line 88 of datatables.net-buttons/types/types.d.ts (it's in the interface definition for DataTablesStaticExtButtons). The error states "Property 'collection' does not exist on type 'Buttons'". Looking at the definition for the Buttons interface, it doesn't have a property named 'collection'. Not sure if this is something that was meant to be implemented in the Buttons interface and was overlooked, or if line 88 was supposed to be collection: CollectionButtons['collection'];
instead of collection: Buttons['collection'];
, since CollectionButtons does have a property called 'collection'. Either way, someone should check this out and fix the definition so it can be used.
This question has accepted answers - jump to:
Answers
What version are you using? It looks like it is working okay with the latest version of DataTables and Buttons with this example.
That said, I did notice that the
action
function properties are un-typed to I need to look into that.If you can link to a test case showing the issue you are seeing, that would be a huge help for me to be able to either fix the issue or help you resolve it.
Allan
I'm not sure I can actually recreate the example in the TypeScript playground as I feel like I probably have a less common use case where I'm not really using modules with the exception of a single global.d.ts file. I'm also using libman to manage the packages in my project instead of NPM (it's for an ASP.NET Core MVC app in Visual Studio, and I'm converting to TS from JS). With the configuration below, I get three errors for datatables.net related things (I realized after I posted this there were a couple more). Hopefully the information below is enough to go by. I've also made some temporary workarounds that seem to be working so far that I have also included.
Error 1: In wwwroot/lib/datatables.net-buttons/types/types.d.ts as I mentioned already. Also the one I'm most unsure about the fix for.
Error 2: In wwwroot/lib/datatables.net-select/types/types.d.ts saying on the import line, saying "TS2614 (TS) Module '"datatables.net"' has no exported member 'ObjectColumnRender'. Did you mean to use 'import ObjectColumnRender from "datatables.net"' instead?". This error is not present in version 2.0.5 but is in version 2.1.0, so I've been using 2.0.5.
Error3: In wwwroot/lib/datatables.net-fixedcolumns/types/types.d.ts. This error is just that the definitions aren't accessible in the same way they are for the other datatables.net extensions. For some reason the type definition is still showing version 3.2 even though I'm importing the 5.0.0 version (I reset the lib folder and re-imported the packages to confirm this). Updating the file to have the same import, export, and declaration as the other latest packages all have (at least the ones that I'm using), fixes the issue.
Error1:
Error1 Fix:
Error2:
Error2 Fix:
Error3:
Error3 Fix:
Relevant files:
tsconfig.json
libman.json
global.d.ts (used to make things globally available that aren't by default)
Funny one this. I haven't been able to reproduce the error, however reading the code, I do agree that there is an error there. I've committed the proposed change.
That one has been fixed and will be released next week.
Thank you - I agree! I've just committed a fix.
Allan
Thank you for addressing these, @allan! I look forward to having these fixed Any idea on when they'll be shipped in a new version? Also, a note on the datatables.net-fixedcolumns one though, the interface called "settings" should be renamed to "Config" in order to merge properly with the main datatables.net definition correctly. As is, if you try to do
$('#dataTable').DataTable({ fixedColumns: true })
TS will give you an error saying that "fixedColumns" does not exist in type 'Config'.Looks like the FixedColumns types have actually fallen behind the implementation. I've committed a fix.
Hopefully not too long until I release the updated packages. Had hoped it would be tomorrow, but other stuff has got in the way!
Allan
Error: node_modules/datatables.net-buttons/types/types.d.ts:88:23 -
Error TS2339: Property 'collection' does not exist on type 'Buttons'. 88
collection: Buttons['collection']
I think , the last version datatables.net-buttons 3.1.2 has the some error !!!
how we can fix it ?
There is indeed an error in the Buttons TS defs at the moment. It has already been fixed in git and I'll push the release with the change in the next few days.
Allan
Good evening,
I thank you for your quick response.
We have a problem in the development and testing phases.
Please correct it as soon as possible.
Good luck
Buttons 3.2.0 is now available. Release notes available here.
Allan
Thanx Dear Allan