You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect typings of @serialport/bindings-cpp when using ESM #2705
Install @serialport/bindings-cpp via Yarn Berry 3.6.3 with PnP
Use with TypeScript 5.2.2, set up with --module ESNext and --module-resolution bundler
Import the AutoDetectTypes type
What happens?
The type is reduced to any as TypeScript fails to load the BindingInterface type from @serialport/bindings-interface
What should have happened?
The type union should get correctly imported and not get reduced to any.
Additional information
I'm aware that Yarn PnP is an experimental feature, however that doesn't seem to be the cause, other modules work totally fine. It seems to be simply an out of date/incomplete package.json exports definition of the @serialport/bindings-interface package.
There is a pull request for the very package, soon about to celebrate its first birthday, that resolves this issue: serialport/bindings-interface#32
I'm opening this issue as the author of the mentioned PR seems to not have done so, or perhaps missed the readme asking to open issues here instead.
Reacted by Krzysztof Rosiński, Alistair Smith, Henri Hollmann, Mikael Finstad, Isaac Richter, Julian Wowra, KARASZI István, AKI and Noah Ignacio Smith
changed the title [-]Can't import @serialport/bindings-cpp when using ESM[/-][+]Incorrect typings of @serialport/bindings-cpp when using ESM[/+]on Sep 16, 2023
without patching, we can re-export the SerialPort class
// copy and paste the contents of node_modules/@serialport/bindings-interface/dist/index.d.ts hereimport{AutoDetectTypes}from"@serialport/bindings-cpp";import{StreamOptions}from"@serialport/stream";import{SerialPort}from"serialport";exporttypeSerialPortOpenOptions<TextendsAutoDetectTypes>=Omit<StreamOptions<T>,"binding">&OpenOptionsFromBinding<T>;classSerialPortWrapperextendsSerialPort{constructor(options: SerialPortOpenOptions<AutoDetectTypes>){super(options);}staticlist(): Promise<PortInfo[]>{returnsuper.list();}}export{SerialPortWrapperasSerialPort};
Activity
[-]Can't import @serialport/bindings-cpp when using ESM[/-][+]Incorrect typings of @serialport/bindings-cpp when using ESM[/+]yinghaochan commentedon Feb 27, 2026
without patching, we can re-export the SerialPort class