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?
Asked
Active
Viewed 3,062 times
2

Talha Rahman
- 720
- 4
- 12
- 27

Hiep Nguyen
- 183
- 5
- 17
-
Possible duplicate of [Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type](https://stackoverflow.com/questions/41292559/could-not-find-a-declaration-file-for-module-module-name-path-to-module-nam) – tony19 Sep 17 '18 at 16:15
2 Answers
5
You 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.

Danijel
- 1,145
- 8
- 15
2
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.

Ohgodwhy
- 49,779
- 11
- 80
- 110