redis / ioredis

🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
MIT License
14.31k stars 1.19k forks source link

[BUG] This expression is not constructable. #1809

Closed gipo355 closed 1 year ago

gipo355 commented 1 year ago

Hello! Currently running ioredis 5.3.2 and having this exact error coming up as #1632.

On the same environment type, esm.

Tried the suggested solutions {default as Redis} but the problem persists.

Is there something i missed?

// code
import { default as Redis } from 'ioredis';

import { SECRETS } from '../../environment.js';

export const redisConnection = new Redis(SECRETS.REDIS_URL);
// ERROR: This expression is not constructable.
// Type 'typeof import("/pathtorepo/node_modules/.pnpm/ioredis@5.3.2/node_modules/ioredis/built/index")' has no construct signatures.ts(2351)

tsconfig

{
    "compilerOptions": {
        "incremental": true,
        "target": "ES2022",
        "module": "NodeNext",
        "rootDir": "./src",
        "moduleResolution": "NodeNext",
        "allowJs": true,
        "outDir": "./dist",
        "removeComments": true,
        "verbatimModuleSyntax": true,
        "jsx": "preserve",
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "noImplicitAny": true,
        "experimentalDecorators": true,
        "noUnusedParameters": true,
        "noFallthroughCasesInSwitch": true,
        "emitDecoratorMetadata": true,
        "noImplicitOverride": true,
        "noImplicitThis": true,
        "skipLibCheck": true
    },
    "ts-node": {
        "compilerOptions": {
            "module": "CommonJS"
        },
        "swc": true
    },
    "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"],
    "exclude": ["node_modules", "dist"]
}

no @types/ioredis installed

gipo355 commented 1 year ago

had to actually use import {Redis}