signalwire-js icon indicating copy to clipboard operation
signalwire-js copied to clipboard

typescript types for ESM

Open tobowers opened this issue 1 year ago • 3 comments

I'm getting this error when adding the realtime sdk

Could not find a declaration file for module '@signalwire/realtime-api'. '/code/speedrun-demo/node_modules/@signalwire/realtime-api/dist/index.node.mjs' implicitly has an 'any' type.
  There are types at '/code/speedrun-demo/node_modules/@signalwire/realtime-api/dist/realtime-api/src/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@signalwire/realtime-api' library may need to update its package.json or typings.ts(7016)

tobowers avatar Feb 13 '24 12:02 tobowers

Please write the steps to reproduce this error.

iAmmar7 avatar Feb 13 '24 14:02 iAmmar7

It’s literally just “use esm” https://github.com/tobowers/demo-broken-signal-wire

tobowers avatar Feb 13 '24 14:02 tobowers

This issue originated due to the TS upgrade and it will be fixed in the next release of our realtime-api SDK.

In the meantime, if you are blocked, there are two ways to fix it temporarily;

  1. Use the ESNext module which is compatible with NodeJS environments.
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "esModuleInterop": true,
    "moduleResolution": "Node",
    ...
  },
  ...
}
  1. Explicitly specify the types path in the tsconfig;
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "NodeNext",
    "esModuleInterop": true,
    "moduleResolution": "NodeNext",
    "paths": {
      "@signalwire/realtime-api": [
        "path_to_your_node_modules/@signalwire/realtime-api/dist/realtime-api/src/index.d.ts"
      ]
    },
    ...
  },
  ...
}

iAmmar7 avatar Apr 16 '24 16:04 iAmmar7

Closing this one, the fixed should be there in the latest version of the Realtime SDK.

iAmmar7 avatar Oct 31 '24 13:10 iAmmar7