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
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