node-redlock icon indicating copy to clipboard operation
node-redlock copied to clipboard

Added missing ESM types export condition first

Open jonaskello opened this issue 2 years ago • 1 comments

Fixes #173

Supersedes #214 since types expression needs to come first.

jonaskello avatar Sep 13 '22 17:09 jonaskello

This is a rather small change but a total blocker for using node16/nodenext module resolution in typescript. There is no workaround as according to the typescript team this should be fixed by package maintainers:

In short: if you encounter any package with a types package json entry but not types in a provided export map - report it as an issue on that package; they've (likely unintentionally) broken TS support.

@mike-marcacci Would it be possible to have this merged and released in an patch version?

jonaskello avatar Sep 20 '22 07:09 jonaskello

I also ran into the same issue and need this fix in order to be able to use nodenext module resolution. @mike-marcacci any chance this could get merged and released soon?

mogzol avatar Dec 09 '22 00:12 mogzol

I would need this fixed as well, I would appreciate this being released soon too.

SirBernardPhilip avatar Feb 13 '23 16:02 SirBernardPhilip

The workaround I did was to copy all the type definitions from index.d.ts in the redlock package into a redlock.d.ts file in my typings folder, wrapping them in a declare module ...:

declare module "redlock" {
    // Types from node_modules/redlock/dist/index.d.ts go here, with the "declare" keywords removed

    import { EventEmitter } from "events";
    import { Redis as IORedisClient, Cluster as IORedisCluster } from "ioredis";
    type Client = IORedisClient | IORedisCluster;
    // ...
}

For that to work you also have to add your typings folder into the typeRoots property in your tsconfig:

{
  "compilerOptions": {
    "typeRoots": ["./node_modules/@types", "./typings"],
  }
}

I would really appreciate this PR being merged and released soon, but at least in the meantime this works.

mogzol avatar Feb 13 '23 18:02 mogzol

@mike-marcacci FYI this PR only adds a single line to package.json, so it should not be much work to review.

jonaskello avatar Feb 13 '23 19:02 jonaskello

Our project migration to esm is currently blocked on this, can we have this merged @mike-marcacci ?

Not in favor of having a copy of the declaration file within our project.

binsonc avatar Feb 17 '23 05:02 binsonc

@mike-marcacci FYI this PR only adds a single line to package.json, so it should not be much work to review.

Have been running with this change for months and can verify it is sound.

ryan-gies-agilysys avatar Jun 07 '23 19:06 ryan-gies-agilysys

@mike-marcacci Can we get a release with this?

CarsonF avatar Jul 26 '23 21:07 CarsonF

When is the release of this?

joonaskaustel avatar Sep 04 '23 09:09 joonaskaustel

Does not seem to be a big change, could this be released soon please? Our esm transformation is put on hold because of one package :/

raimoa1 avatar Sep 11 '23 13:09 raimoa1

I cannot use this package in my typescript ESM project because this issue has not been released.

dgg avatar Nov 01 '23 13:11 dgg

Also waiting on this to be realeased.

In the meantime, you can use this in your package.json to use the ESM update:

"dependencies": {
  "redlock": "git+https://github.com/mike-marcacci/node-redlock.git"
}

nkeil avatar Jan 06 '24 01:01 nkeil

Is this project abandoned? There seems to be no chance of an npm release anytime soon?

williamoverton avatar May 31 '24 10:05 williamoverton