Лаконично весьма
const addTimeDescription = (str) =>
str.replace(/^.*\b\d\d?:\d\d\b/, '$& (время местное)');
...args: [{ field1: number; field2: number }] | [field1: number, field2: number] - это уже перегрузка
Вот как раз чтобы не гадать с какой суммы начинать и какой шаг разницы должен быть, хочу понять как можно описать это математически.
Я думаю дело в WebStorm
const reserve: Reserve = (from: Date, toOrDest: Date | string, destination?: string): Ticket => {
const ticket: Ticket = {
from,
type: "one-way",
destination: "",
};
if (toOrDest instanceof Date && destination !== undefined) {
ticket.type = "two-way";
ticket.to = toOrDest;
ticket.destination = destination;
} else if (typeof toOrDest === 'string') {
ticket.destination = toOrDest;
}
return ticket;
}