tj/connect-redis

RedisStore lacks construct signature with typescript

coraxwolf opened this issue · 6 comments

I am getting an error (possible only a typescript issue) when following with the example in the README.

'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.ts(7009)

I am import connect-redis as such: import RedisStore from 'connect-redis

the full error message generated is:

TypeError: Class constructor RedisStore cannot be invoked without 'new'
    at Object.<anonymous> (/usr/src/app/src/utils/redisSession.ts:19:32)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module.m._compile (/usr/src/app/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.require.extensions.<computed> [as .ts] (/usr/src/app/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/usr/src/app/src/server.ts:3:1)

I cannot duplicate, can you share the full initialization you are using?

All of my code is on my github repo, https://github.com/coraxwolf/Micro-Pen.git, I resolved the issue by reverting back to connect-redis 6.0. I created another branch named RedisStoreError that I put back to redisstore 7.0.1 so using that one should allow you to see the error i am getting.

I'll apologize now for the state of that code. I would suggest copying the code and setting up your own environment to run it, instead of using the docker setup I strung together.

Thx, looks like you are initializing your 7.x code the old way:

https://github.com/coraxwolf/Micro-Pen/blob/12eac1450da9642df6b88bb82d9eaab747f772aa/src/utils/redisSession.ts#L19

See the release notes on how to migrate and that should resolve your issue:

https://github.com/tj/connect-redis/releases/tag/v7.0.0

Any fix for this yet??

This repo publishes release notes (including any breaking changes) on the GitHub release pages. Sounds like this is the resolution. Closing.