Typescript types with Bootstrap variants

Typescript types with Bootstrap variants

geometrygeometry Posts: 22Questions: 6Answers: 0

We have started to use the internal Typescript type definitions provided with DataTables but have run into some issues specifically with the Bootstrap variants

Both datatables.net and datatables.net-bs export a Config type but yet all the -bs plugin variants seem to extend the non -bs Config? Is this correct? Should we be just using the Config type from the core datatables.net and ignore the one from datatables.net-bs

Hopefully that makes sense

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Is this correct?

    Yes. The datatables.net package is the core package and is a dependency of datatables.net-bs. The -bs (and other styling packages) just set a bunch of default parameters on the DataTable object in order to make the theming suitable for the styling framework.

    The styling packages just re-export the core file.

    Generally you should just import the style package - since the core file is a dependency, there is no need to import it directly - e.g.:

    import DataTable from 'datatables.net-bs5';
    import 'datatables.net-buttons-bs5';
    

    Rather than:

    import DataTable from 'datatables.net';
    import 'datatables.net-bs5';
    import 'datatables.net-buttons';
    import 'datatables.net-buttons-bs5';
    

    It is basically exactly the same - the first just more compact :)

    Allan

  • geometrygeometry Posts: 22Questions: 6Answers: 0

    Ok so what you're saying is that I should just use the types from the -bs variants only and that makes sense to me but we are seeing errors like this

    And this one isn't the only plugin with strange errors. The responsive one also shows this when using the Config type from the the -bs version
    e.g import { Config } from "datatables.net-bs"

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    edited May 2023

    Scrap that. I was thinking the extension hadn't been imported, but I see it has. Looking into it more...

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Right I see the error. The styling packages are incorrectly including their own copy of the DataTables core type information. So when a package such as Select extends DataTables core, it does the core, but not the styling package. The styling package should inherit from the core, so it would also be extended.

    I need to change our build process to fix this - apologies.

    Allan

  • geometrygeometry Posts: 22Questions: 6Answers: 0

    No worries @allan. Thanks for the follow up and the confirmation we weren't on the wrong track. We'll keep our eyes open for an update :smile:

  • geometrygeometry Posts: 22Questions: 6Answers: 0

    Hey @allan don't want to be a pest but any idea when we can expect a new version addressing this issue? Just a vague date would be great for our future planning

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Answer ✓

    Move likely the week of the 3rd July. That's the current target - I'm making a number of wide ranging changes at the moment, which needs a whole load of things to align before I can get the releases out. Apologies for the delay!

    Allan

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    edited July 2023

    Hi,

    Just to say that with DataTables 1.13.5 and all of the other releases I did yesterday, this should now be addressed. The Typescript playground example appears good (looks like it just automatically pulls in the latest version of each library).

    Allan

Sign In or Register to comment.