iamkun / iamkun/dayjs

dayjs(undefined).isValid() show devHelper warn in development

Open
#1,240 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
This is not a bug

**Expected behavior**
> // English

I think the motivation for executing the `isvalid()` function is to verify that the input parameter value is valid. Because it makes no sense to execute `dayjs().isvalid()` in the production environment.
When the input parameter is `undefined`, it is more likely that the input parameter is `undefined `rather than the value is not passed.

Since there is no way to tell whether the input parameter is undefined or not passed in, I recommend that you provide a warning in development mode.

> // Chinese

我认为执行 `isValid()` 函数时的动机是验证入参值是否为有效。因为在生产环境执行 `dayjs().isvalid()` 是没有意义的。
当入参为 `undefined `时多半是因为入参为 `undefined`,而非未传值。

因为无法区分入参为`undefined`还是入参未传入,因此我建议在开发模式提供警告。


**Information**
- Day.js Version 1.9.6
- OS: Windows
- Browser Chrome 86
- Time zone: UTC+08:00

Contributor guide

Open the contributing guide

Research direction

Start from the dayjs(undefined).isValid() entry point and review how the devHelper warning behavior is handled in development mode. The requested outcome is a development warning for an undefined input while preserving normal validity behavior; the issue does not name a file or test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.