iamkun / iamkun/dayjs

ESLint: Unsafe call of an `any` typed value.(@typescript-eslint/no-unsafe-call)

Open
#1,903 1 comment 11 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

When i using dayjs in React with TypeScript, some errors occur.

- ESLint: Unsafe call of an `any` typed value.(@typescript-eslint/no-unsafe-call)
- ESLint: Unsafe member access .toString on an `any` value.(@typescript-eslint/no-unsafe-member-access)
- ESLint: Unsafe member access .unix on an `any` value.(@typescript-eslint/no-unsafe-member-access)

```typescript
import dayjs from "dayjs";

function getTime(dateTimeStr: string): string {
return dayjs(dateTimeStr).unix().toString();
}
```

스크린샷 2022-05-17 오후 7 43 33

**Expected behavior**
There is no lint errors.

**Information**
- Day.js Version [e.g. v1.0.0]: ^1.11.2
- OS: [e.g. iOS] : MacOS BigSur
- Browser [e.g. chrome 62] : 101.0.4951.64 (x86_64)
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)] KST (korea standard time)
- IDE: WebStorm 2021.2.4
- if you want more information, please notice me! 👏 (e.g. `.eslintrc`, ...)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the TypeScript example with Day.js 1.11.2 and the reported ESLint rules in an equivalent React setup. Inspect the consumer's TypeScript and ESLint configuration to determine whether the errors come from Day.js typings or project setup; done means the listed unsafe-call and unsafe-member-access errors no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, react, typescript
Domain
frontend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.