@ types/serialport模块未导入ts类 [英] @types/serialport module not import into ts class
问题描述
我已在现有的Angular(ts)项目中安装了 dependency(js)除非将其转换为ts,否则不会对其进行编译.然后,我找到了一个受支持的存储库,它可以管理您对打字稿的支持.但是无论如何,我无法在我的班级中导入那些依赖项
I have installed this dependency(js) in existing Angular(ts) project but you won't compile this code until if it's converted into ts. Then I found a ts supported repository that can manage your back support for typescript . But anyhow I am not able to import those dependency in my class
import { SerialPort } from '@types/serialport';
并抛出一个错误 node_modules/@ types/serialport/index"没有导出的成员"SerialPort".
所以我可以通过其他任何方式导入 serialport 对象吗?请确切地标记我做错的地方.您的帮助将不胜感激. 预先感谢.
So any other way can I import serialport object ? Please give a flag exactly where I am doing wrong. Your help would be highly appreciated. Thanks in advance.
推荐答案
Serialport
类型声明来自绝对输入.
来自 index.d.ts ,它似乎声明了一个命名空间.
From the index.d.ts, it seems to declare a namespace.
尝试:
import * as SerialPort from 'serialport';
注意:您直接从serialport
导入,而不是从@types
NOTE: You directly import from serialport
not from @types
这篇关于@ types/serialport模块未导入ts类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!