[英]How can I import third party package without d.ts file?
You can put all your custom imports in my own file. 您可以将所有自定义导入内容放入我自己的文件中。 For instance, create shared/types/imports.d.ts file. 例如,创建shared / types / imports.d.ts文件。
declare module "vue-multiselect";
declare module "vue-notification";
And in your tsconfig.json file include those imports with the following lines. 并在您的tsconfig.json文件中包括带有以下行的那些导入。
"typeRoots": [
"node_modules/@types", "VueApp/shared/types"
],
And of course, restart your IDE because sometimes it doesn't detect the change immediately. 当然,请重新启动IDE,因为有时它不会立即检测到更改。
Make modules for them. 为他们制作模块。 Make sure to include the path to your types
directory locally: 确保在本地包含您的types
目录的路径:
declare module 'vue-cookie' {
}
All module declarations
need to be in their own, separate files. 所有module declarations
必须位于各自独立的文件中。 For instance, the vue-cookie file should be named something to the effect of vue-cookie.d.ts
. 例如,应将vue-cookie文件命名为vue-cookie.d.ts
。
Also, as you go through the module, you can start typing it correctly. 另外,在浏览模块时,您可以开始正确键入它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.