Closed Mordef closed 2 years ago
If importing all modules from Bootstrap 5, do so like this:
import * as bootstrap from 'bootstrap'
import 'bs5-lightbox'
A better approach would be to only import the components you are using, which would utilize Tree Shaking
import { Dropdown, Toast } from 'bootstrap'
import 'bs5-lightbox'
import * as bootstrap from 'bootstrap'
import 'bs5-lightbox'
Results in
ERROR in [at-loader] ./node_modules/bs5-lightbox/dist/index.d.ts:14:19
TS2503: Cannot find namespace 'bootstrap'.
ERROR in [at-loader] ./node_modules/bs5-lightbox/dist/index.d.ts:15:22
TS2503: Cannot find namespace 'bootstrap'.
ERROR in [at-loader] ./node_modules/bs5-lightbox/dist/index.d.ts:18:12
TS2503: Cannot find namespace 'bootstrap'.
ERROR in [at-loader] ./node_modules/bs5-lightbox/dist/index.d.ts:19:15
TS2503: Cannot find namespace 'bootstrap'.
ERROR in [at-loader] ./node_modules/bs5-lightbox/dist/index.d.ts:39:31
TS2503: Cannot find namespace 'bootstrap'.
ERROR in [at-loader] ./node_modules/bs5-lightbox/dist/index.d.ts:39:56
TS2503: Cannot find namespace 'bootstrap'.
Same with
import { Modal, Carousel, Collapse, Dropdown, Offcanvas } from 'bootstrap';
import 'bs5-lightbox'
This is most likely an issue with your TypeScript config. Without knowing more, I would guess adding this to tsconfig.json might help:
{
"compilerOptions": {
"skipLibCheck": true,
}
}
You might also just exclude the definition file:
{
"exclude": [
"node_modules/bs5-lightbox/dist/index.d.ts"
]
}
@Mordef is your issue resolved?
Sory for the late answer.
Yes, with "skipLibCheck": true,
it works fine
What must i do to use this with webpack? I got allways this:
Cannot find namespace 'bootstrap'
My testcode