1
votes

In my angular 8 application I am getting error error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. in the code below at line

const source: any = timer(0, environment.corePingIntervalSeconds * 1000);

const source: any = timer(0, environment.corePingIntervalSeconds * 1000);
    source.subscribe(() => {
       this.checkIfCoreApiIsAvailable()
       .pipe(first())
       .subscribe(resp  => {

       }, err => console.log(err));
     });
3
What is the value / type of environment.corePingIntervalSeconds?Sam

3 Answers

1
votes

You should try to use the Number interface:

timer(0, Number(environment.corePingIntervalSeconds) * 1000);
0
votes

you can use

 +timer(0, environment.corePingIntervalSeconds * 1000)

the plus in front converts it to a number type

0
votes

emphasized textLeft side value of arithmetic operator must be of type number, any, bigint, or enum. In your case value of environment.corePingIntervalSeconds is not belongs to these type. You Should use explicit typecasting in this case.

Your correct syntax will be like below

const source: any = timer(0, (environment.corePingIntervalSeconds as any) * 1000);