Disable function code warning

I am using Node red V4.0.9 and the following code

const delta_ms = new Date() - new Date(machines_buffer.timestamp);
genrate a warning but do work!

The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.(2362)

is it possible to remove this warning ?

I removed it:

const delta_ms = new Date().getTime() - new Date(machines_buffer.timestamp).getTime();
1 Like

This is a known limitation of the Monaco editor component from Microsoft. new Date() strictly speaking returns a JavaScript date object, not a number. Even though a date object IS a number! Sometimes JavaScript is just weird. :smiley:

jbudd has shown one way to fix it. Another way would be:

const delta_ms  = Number(new Date()) - Number(new Date(machines_buffer.timestamp));

1 Like