Working with date type field

In my application I calculate the duration as follows:
doo.model.duration.value = (doo.model.end.value - doo.model.start.value)/3600000;

When I switch to the New TypeScript editor, the entire expression is underlined with a red wavy line. And the message "The left-hand side of an arithmetic operation must be of type ‘any’. ‘number’. …
The calculation in the form works correctly, but NaN is printed on the console.
If I create Duration as calculated field: end - start, the result is always 0001-01-01, for Formula output Date and -1 for Formula output Number.
Can you please advise me how to fix the calculation. Thank you

In case you need to calculate the difference in hours, you can use a script like this:

const start = new Date(doo.model.start.value);
const end = new Date(doo.model.end.value);
const diff = end.valueOf() - start.valueOf();
const duration = diff / (1000 * 60 * 60);

This is an example tested in On model change part. Not as calculated field.
For a calculated field is would be someting like this:

(new Date(End).valueOf() - new Date(Start).valueOf()) / (1000 * 60 * 60)