Skip to content

Typescript error with module esnext and moduleResolution bundler. #2770

Open
@mousseq

Description

@mousseq

SerialPort Version

12.0.0

Node Version

20.2

Electron Version

No response

Platform

Linux pi4-1r 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux

Architecture

ARM

Hardware or chipset of serialport

FTDI

What steps will reproduce the bug?

tsconfig.json contains:
module: "esnext"
moduleResolution: "bundler"

File sp.ts:
import { SerialPort } from "serialport";

let port = new SerialPort(
{
path: "foobar",
baudRate: 115200
}
);

Transpile with tsc and get:

What happens?

$ ./node_modules/typescript/bin/tsc
node_modules/@serialport/bindings-cpp/dist/darwin.d.ts:2:10 - error TS2305: Module '"."' has no exported member 'BindingPortInterface'.

2 import { BindingPortInterface } from '.';
~~~~~~~~~~~~~~~~~~~~

node_modules/@serialport/bindings-cpp/dist/linux.d.ts:4:10 - error TS2305: Module '"."' has no exported member 'BindingPortInterface'.

4 import { BindingPortInterface } from '.';
~~~~~~~~~~~~~~~~~~~~

node_modules/@serialport/bindings-cpp/dist/win32.d.ts:2:10 - error TS2305: Module '"."' has no exported member 'BindingPortInterface'.

2 import { BindingPortInterface } from '.';
~~~~~~~~~~~~~~~~~~~~

node_modules/serialport/dist/serialport.d.ts:2:27 - error TS2305: Module '"@serialport/bindings-cpp"' has no exported member 'OpenOptionsFromBinding'.

2 import { AutoDetectTypes, OpenOptionsFromBinding } from '@serialport/bindings-cpp';
~~~~~~~~~~~~~~~~~~~~~~

Found 4 errors in 4 files.

Errors Files
1 node_modules/@serialport/bindings-cpp/dist/darwin.d.ts:2
1 node_modules/@serialport/bindings-cpp/dist/linux.d.ts:4
1 node_modules/@serialport/bindings-cpp/dist/win32.d.ts:2
1 node_modules/serialport/dist/serialport.d.ts:2

What should have happened?

Transpilation should have succeeded.

Additional information

Either of these configurations works:
"module": "esnext"
"moduleResolution": "node"
or
"module": "nodenext"
"moduleResolution": "nodenext"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions