2017-05-31 93 views
2

我已經在現有的Angular(ts)項目中安裝了這個dependency(js),但是如果它被轉換爲ts,你將不會編譯這些代碼。然後我發現支持repository的ts可以管理你對打字稿的支持。不過,無論如何,我無法導入我的課@ types/serialport module not import into ts class

import { SerialPort } from '@types/serialport'; 

的依賴,並拋出一個錯誤 node_modules/@類型/的SerialPort /索引「」沒有出口成員‘的SerialPort’。

所以我任何其他方式可以導入的SerialPort對象嗎?請給一個標誌,正是我做錯了。你的幫助,將不勝感激。 在此先感謝。

回答

3

Serialport型declarat離子來自DefinitelyTyped

the index.d.ts,它似乎宣佈一個命名空間。

嘗試:

import * as SerialPort from 'serialport'; 

注意:你直接從serialport不能導入來自@types