Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom parse format doesn't support all constructor types #1342

Open
solomon23 opened this issue Jan 19, 2021 · 0 comments
Open

Custom parse format doesn't support all constructor types #1342

solomon23 opened this issue Jan 19, 2021 · 0 comments

Comments

@solomon23
Copy link

solomon23 commented Jan 19, 2021

Describe the bug

The dayjs constructor takes in an option type as such

export type OptionType = { locale?: string, format?: string, utc?: boolean } | string | string[]

but if you use object format { locale, format, etc} as an input using the customParseFormat it doesn't work as expected

if (typeof format === 'string') {

Only looks at that param as a string or array. So this just silently doesn't work properly. The typescript doesn't give any hints to this because the typing says sending in that format is ok

Expected behavior
Use a { locale, format, utc } should work properly when sent into a customerParseFormat plugin or it should explicitly fail instead of silently failing.

Information

  • Day.js Version [e.g. v1.0.0]
  • OS: [e.g. iOS]
  • Browser [e.g. chrome 62]
  • Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant