Typescript types with Bootstrap variants
Typescript types with Bootstrap variants
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
Yes. The
datatables.net
package is the core package and is a dependency ofdatatables.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.:
Rather than:
It is basically exactly the same - the first just more compact
Allan
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 thisAnd 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
versione.g
import { Config } from "datatables.net-bs"
Scrap that. I was thinking the extension hadn't been imported, but I see it has. Looking into it more...
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
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
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
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
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