Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@types/serialport module not import into ts class

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';

And throw an error node_modules/@types/serialport/index"' has no exported member '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.

like image 654
QuokMoon Avatar asked Dec 06 '25 10:12

QuokMoon


1 Answers

Serialport type declarations are from DefinitelyTyped.

From the index.d.ts, it seems to declare a namespace.

Try:

import * as SerialPort  from 'serialport';

NOTE: You directly import from serialport not from @types

like image 137
Suraj Rao Avatar answered Dec 08 '25 02:12

Suraj Rao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!