serialport / bindings-interface

Bindings typescript types
MIT License
0 stars 7 forks source link

Could not find a declaration file for module '@serialport/bindings-interface'. #52

Open rosek86 opened 10 months ago

rosek86 commented 10 months ago

Hello,

I get the following error when I try to use serialport in esm, is it something that can be adjusted in @serialport/bindings-interface.

error TS7016: Could not find a declaration file for module '@serialport/bindings-interface'. '(...)/node_modules/@serialport/bindings-interface/dist/index-esm.mjs' implicitly has an 'any' type.
  There are types at '(...)/node_modules/@serialport/bindings-interface/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@serialport/bindings-interface' library may need to update its package.json or typings.

4 import { PortInfo } from '@serialport/bindings-interface';
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

NOTE: when I copy index.d.ts file to index-esm.d.mts the error disappears.

Azq2 commented 4 months ago

Same problem.

@reconbot Can you fix this?

volkmarnissen commented 3 months ago

I was not able to build the module after sync and npm install, that's why I was not able to create a pull request. I hat issues with rollup

However, if you use bindings-interface in a ESM based project (packge.jscon -> "type": "module" You will get errors like the above.

"Solution": I copied the dist-ts/index.s.ts file to dist/index.d.ts file and changed the export section to

  "exports": {
    "require": "./dist/index.js",
    "types": "./dist/index.d.ts",
    "default": "./dist/index-esm.mjs"
 },

The same needs to be done for bindings-mock.