You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import*asmfrom'moment';import{DateRange,extendMoment}from'moment-range';constmoment=extendMoment(m);constavailableSince1=moment('2023-04-06T08:00:00.000Z');// ^ TypeError: moment is not a function
constMoment=require('moment');constMomentRange=require('moment-range');constmoment=MomentRange.extendMoment(Moment);Array.from(moment.range('2023-04-06T08:00:00.000Z','2023-04-06T13:30:00.000Z').by('minutes',{step: stepInMinutes})).map((time)=>({date: time.toLocaleString()}));// 'time' is of type 'unknown'.// then I tried to cast to the typeArray.from(moment.range('2023-04-06T08:00:00.000Z','2023-04-06T13:30:00.000Z').by('minutes',{step: stepInMinutes})).map((time)=>({date: time.toLocaleString()}));// 'time' is of type 'unknown'./* Argument of type '(time: m.Moment) => { date: string; }' is not assignable to parameter of type '(value: unknown, index: number, array: unknown[]) => { date: string; }'. Types of parameters 'time' and 'value' are incompatible. Type 'unknown' is not assignable to type 'Moment'. */
The text was updated successfully, but these errors were encountered:
import Moment from "moment";
import { extendMoment } from "moment-range";
// @ts-expect-error - No proper typescript support from moment-range
const moment = extendMoment(Moment);
Array.from(
moment
.range(moment('2023-04-06T08:00:00.000Z'), moment('2023-04-06T13:30:00.000Z'))
.by('minutes', { step: stepInMinutes })
).map((time) => ({ date: time.toLocaleString() }));
There is an issue with typescript usage.
tsconfig.json
some.test.ts
I was trying this approach but another error occurred
The text was updated successfully, but these errors were encountered: