Can't create a simple service
miguelchico opened this issue · comments
Basic setup is throwing an error:
Class constructor NestSchedule cannot be invoked without 'new'
import { Cron, NestSchedule } from '@nestcloud/schedule';
import { Injectable } from '@nestjs/common';
@Injectable()
export class MyScheduler extends NestSchedule {
constructor() {
super();
}
@Cron('* * * * *')
clear() {
console.log('print log ...');
}
}
import { Module } from '@nestjs/common';
import { MyScheduler } from './my.scheduler';
@Module({
providers: [MyScheduler]
})
export class MyModule {}
Nestjs version: 5.5.0
Typescript version: 3.2.4
Can you send me an example project? Thanks. @miguelchico
This is what I am getting:
TS2322: Type 'typeof MyScheduler' is not assignable to type 'Provider<any>'.
Type 'typeof MyScheduler' is not assignable to type 'Type<any>'.
Cannot assign a 'protected' constructor type to a 'public' constructor type.
Add a constructor to your service, then it should work.
export class ScheduleService extends NestSchedule {
constructor() {
super(); // Remember to call the parent constructor.
}
}