skunight / nestjs-redis

nestjs redis module
MIT License
321 stars 173 forks source link

Dynamic Module Typescript Error #11

Closed tskweres closed 5 years ago

tskweres commented 5 years ago

I tried to get this up and running based on the readme, but I keep getting an error on npm start:

My App Module:

` import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { SharedModule } from './shared/shared.module'; import { ApiModule } from './api/api.module'; import { ConfigModule } from './config/config.module'; import { TypeOrmModule } from '@nestjs/typeorm'; import { RedisModule } from 'nestjs-redis';

@Module({ imports: [ SharedModule, ApiModule, ConfigModule, TypeOrmModule.forRoot({ type: 'mongodb', host: 'localhost', port: 27017, database: 'test', entities: [__dirname + '/*/.entity{.ts,.js}'], synchronize: true, }), RedisModule.register({ host: 'localhost', port: 6379, db: 1, password: '', keyPrefix: '_backend', }), ], controllers: [AppController], providers: [AppService], }) export class AppModule {}

`

On NPM start, the error I see:

` /Users/tskweres/dev/backend-starter/node_modules/ts-node/src/index.ts:240 return new TSError(diagnosticText, diagnosticCodes) ^ TSError: ⨯ Unable to compile TypeScript: src/app.module.ts:23:5 - error TS2322: Type 'DynamicModule' is not assignable to type 'Type | DynamicModule | Promise | ForwardReference'. Type 'import("/Users/tskweres/dev/backend-starter/node_modules/nestjs-redis/node_modules/@nestjs/common/interfaces/modules/dynamic-module.interface").DynamicModule' is not assignable to type 'import("/Users/tskweres/dev/backend-starter/node_modules/@nestjs/common/interfaces/modules/dynamic-module.interface").DynamicModule'. Types of property 'imports' are incompatible. Type '(DynamicModule | Type | Promise | ForwardReference)[]' is not assignable to type '(Type | DynamicModule | Promise | ForwardReference)[]'. Type 'DynamicModule | Type | Promise | ForwardReference' is not assignable to type 'Type | DynamicModule | Promise | ForwardReference'. Type 'DynamicModule' is not assignable to type 'Type | DynamicModule | Promise | ForwardReference'.

23 RedisModule.register({

 24       host: 'localhost',

... 28 keyPrefix: '_backend',


 29     }),
`
tskweres commented 5 years ago

Fixed

For some reason - using yarn add instead of npm install makes it work.