bootstrap-vue: Typescript imports don't find `index.d.ts` when importing individual components
- Version of Bootstrap-Vue that you are using 2.0.0-rc.11
import bContainer from 'bootstrap-vue/es/components/layout/container';
69:24 Could not find a declaration file for module 'bootstrap-vue/es/components/layout/container'.
'/node_modules/bootstrap-vue/es/components/layout/container.js' implicitly has an 'any' type.
Try `npm install @types/bootstrap-vue` if it exists or add a new declaration (.d.ts) file containing `declare module 'bootst
rap-vue';`
> 69 | import bContainer from 'bootstrap-vue/es/components/layout/container';
| ^
I’m not sure if TypeScript has a way to specify the type declarations. From what I’ve looked into it doesn’t. So to support imports like this a TypeScript definition would need to be made in every component directory.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 16 (5 by maintainers)
This actually works, which is great. But I can only import one component per .d.ts file.
If I try to import multiple components, it either complains, about importing ‘vue’ multiple times:
if I globally import ‘vue’ in the file:
Invalid module name in augmentation. Module 'bootstrap-vue/es/components/button/button' resolves to an untyped module at '/Volumes/git/code/app-prokoo/node_modules/bootstrap-vue/es/components/button/button.js', which cannot be augmented.Is there a way to import all bootstrap-vue typings, but only import individual components into the build?
Version 2.0.0-rc.21 has been released
If you run into any issues with the new types, please open a new issue.
It appears that Typescript has “issues” with resolving sub-modules, and not checking the
package.json‘types’ to load in the sub-module declarations (it ignores the main packages package.json file.We have updated the type declarations to reside in the
/src/directories, next to the individual module index.js files, and copy these files over to the/es/directories during build. This should be available in the upcoming 2.0.0-rc.21 release.It’s not working out of the box with the new plugins, the warning is:
But its easier now, because I have to create only one d.ts file:
@nicolasigot You can create your own definitions in your
shims-vue.d.tsfile.e.g.
Can confirm that this is an issue.