The left -hand and right hand side of an arithmetic operation must be of type 'any', 'number' or an enum type

I have found out the issue.

The code you have written works only in Javascript

Math.abs(new Date() - new Date(lastConnect)) .

In order to make it work in Typescript, update the code as shown below:

Math.abs(Date().getTime() - new Date(lastConnect).getTime());

The simplest answer would be

Math.abs(<any>new Date() - <any>new Date(lastConnect));

Another great way:

Math.abs((new Date() as any) - (new Date(lastConnect) as any));