type Schemas<P extends keyof paths> = paths[P]['post'] extends {requestBody: infer R} ? R : never;const addTimeDescription = (str) =>
str.replace(/\b\d{1,2}:\d{2}\b(?!.*?\b\d{1,2}:\d{2}\b)/, '$& (время местное)');
// пример использования
const originalString = " с 14:01 к 15:00 работать по плановому";
const updatedString = addTimeDescription(originalString); // ' с 14:01 к 15:00 (время местное) работать по плановому'/^.*\b\d\d?:\d\d\b/ export function getDocuments<T>(slug: ''): Promise<T[]>;
export function getDocuments<T>(slug: string): Promise<T>;
export function getDocuments<T>(): Promise<T[]>;
export function getDocuments(slug = ''): Promise<unknown> {
const endpoint = `/documents/${slug}`
return getPosts(endpoint);
}class DataService {
method(callsStore) {
...
callsStore.setCall(...);
}
}export const setFrame = (titlle: string): setFrameActionType => ({ type: 'SETFRAME', payload: { titlle } });const columns = [
{
key: "name",
label: "NAME",
},
{
key: "role",
label: "ROLE",
},
{
key: "status",
label: "STATUS",
},
] as const;
type ColumnsType = typeof columns;
const rows: Array<Record<ColumnsType[number]['key'], string> & {key: string}> = [
{
key: "1",
name: "Tony Reichert",
role: "CEO",
status: "Active",
},
{
key: "2",
name: "Zoey Lang",
role: "Technical Lead",
status: "Paused",
},
];const [field, updateField] = useReducer(fieldReducer, []); работает без ошибок, применяется перегрузкаfunction useReducer<R extends Reducer<any, any>>(
reducer: R,
initialState: ReducerState<R>,
initializer?: undefined
): [ReducerState<R>, Dispatch<ReducerAction<R>>]; type Reserve = {
(from: Date, to: Date, destination: string): Ticket;
(from: Date, destination: string): Ticket
};
const reserve: Reserve = (from: Date, ...args: [toOrDest: Date, destination: string] | [destination: string]): Ticket => {
const isOne = args.length === 1;
return {
type: isOne ? "one-way" : "two-way",
from,
destination: isOne ? args[0] : args[1],
...(isOne ? {} : {to: args[0]})
};
};Reserve. Но тогда при наведении мыши на reserve будет не совсем понятная подсказка (хотя автокомплит вполне корректный).setItems((prev) => {
const i = prev.findIndex(item => item.id === id);
if (i < 0 || prev[i].isClicked) {
return prev;
}
const newArr = [...prev];
newArr[i] = {...prev[i], isClicked: true};
return newArr;
});