dayjs
dayjs copied to clipboard
Fix for UTC plugin type definitions in combination with CustomParseFormat plugin
Using the CustomParseFormat plugin together with the UTC plugin seems possible:
const dayjs = require('dayjs');
const utc = require('dayjs/plugin/utc');
const customParseFormat = require('dayjs/plugin/customParseFormat');
dayjs.extend(customParseFormat);
dayjs.extend(utc);
dayjs.utc('2025-4-05', ['YYYY-M-D', 'YYYY-MM-D', 'YYYY-M-DD', 'YYYY-MM-DD'], true).day();
// 5
dayjs.utc('2025-04-5', ['YYYY-M-D', 'YYYY-MM-D', 'YYYY-M-DD', 'YYYY-MM-DD'], true).day();
// 5
But the types don't line up, giving me an error in my TS project:
Seems to be an easy fix by just orienting on what's already defined as function parameters in index.d.ts.
Thanks