I'm studying typescript. I get some errors when I tried import some packages. I was check in node_modules
folder, it downloaded but this don't have a *.d.ts
file. How can I import them?
I'm studying typescript. I get some errors when I tried import some packages. I was check in node_modules
folder, it downloaded but this don't have a *.d.ts
file. How can I import them?
- Possible duplicate of Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type – tony19 Commented Sep 17, 2018 at 16:15
2 Answers
Reset to default 5You can put all your custom imports in my own file. For instance, create shared/types/imports.d.ts file.
declare module "vue-multiselect";
declare module "vue-notification";
And in your tsconfig.json file include those imports with the following lines.
"typeRoots": [
"node_modules/@types", "VueApp/shared/types"
],
And of course, restart your IDE because sometimes it doesn't detect the change immediately.
Make modules for them. Make sure to include the path to your types
directory locally:
declare module 'vue-cookie' {
}
All module declarations
need to be in their own, separate files. For instance, the vue-cookie file should be named something to the effect of vue-cookie.d.ts
.
Also, as you go through the module, you can start typing it correctly.