node-eventstore-client icon indicating copy to clipboard operation
node-eventstore-client copied to clipboard

Building app with node-eventstore-client fails due to long type in typescript

Open ericlau-solid opened this issue 1 year ago • 1 comments

This works perfectly fine in development. When attempting to run a build (ie. tsc), I get the following errors. Note that "@types/long": "^4.0.1", no longer exists, "long": "^5.2.4", has its own typescript definition. I removed @types/long from my app's package.json, but that only makes it worse. (all errors due to index.d.ts cannot find name 'Long')

Did some digging. Long is having some goofiness with typescript 5.2. https://github.com/dcodeIO/long.js/pull/130.

Ultimately the app should work without any @types/long

node_modules/node-eventstore-client/index.d.ts:2:23 - error TS1261: Already included file name '/Users/ericlau/WebstormProjects/card-club-mgt/api/node_modules/@types/Long/index.d.ts' differs from file name '/Users/ericlau/WebstormProjects/card-club-mgt/api/node_modules/@types/long/index.d.ts' only in casing.
  The file is in the program because:
    Type library referenced via 'Long' from file '/Users/ericlau/WebstormProjects/card-club-mgt/api/node_modules/node-eventstore-client/index.d.ts' with packageId '@types/long/[email protected]'
    Entry point for implicit type library 'long' with packageId '@types/long/[email protected]'

2 /// <reference types="Long" />
                        ~~~~


Found 1 error in node_modules/node-eventstore-client/index.d.ts:2

ericlau-solid avatar Jan 21 '25 06:01 ericlau-solid

I rigged the index.d.ts file in my project, and once I removed this line:

/// <reference types="Long" />

and replace with this line:

import Long = require('long');

I was able to build. The solution isn't the best since it's a workaround. Turning on esModuleInterop is a better fix, but I leave it to you whether you want to do that.

While at it, please upgrade long npm library version to 5.2.4, uuid to 11.0.5

ericlau-solid avatar Jan 21 '25 18:01 ericlau-solid