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

Error with timezone plugin (Typescript) #1367

Closed
yoannsark opened this issue Jan 29, 2021 · 6 comments
Closed

Error with timezone plugin (Typescript) #1367

yoannsark opened this issue Jan 29, 2021 · 6 comments

Comments

@yoannsark
Copy link

Describe the bug
When I try to import the plugin Timezone

import * as dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';

And then extend it

dayjs.extend(utc);
dayjs.extend(timezone);

I get TypeError: Cannot read property '$i' of undefined

Information

  • Day.js Version 1.10.4
  • OS: NestJS project dockerized with node:15.7.0-alpine3.10
@iamkun
Copy link
Owner

iamkun commented Jan 30, 2021

a reproduction repo, please?

@timothyfstephens
Copy link

try just import dayjs from "dayjs";

@hopemanryan
Copy link

try just import dayjs from "dayjs";

yea, Still wont work :(

Argument of type '{ default: PluginFunc<RelativeTimeOptions>; }' is not assignable to parameter of type 'PluginFunc<unknown>'.

@yoannsark
Copy link
Author

yoannsark commented Feb 15, 2021

Solved thank you !

With TypeScript it is necessary to set "esModuleInterop": true in ts-config.ts to be able to import dayjs with import dayjs from "dayjs"; instead of import * as dayjs from "dayjs";.

This error occurs only without this TS config by importing dayjs with import * as dayjs from dayjs, I don't really know if it is a bug.

@HZ-ZY
Copy link

HZ-ZY commented May 10, 2023

已解决 谢谢!

使用 TypeScript 时,必须"esModuleInterop": true在 ts-config.ts 中设置才能导入 dayjsimport dayjs from "dayjs";而不是import * as dayjs from "dayjs";.

只有在没有这个 TS 配置的情况下通过导入 dayjs 才会出现此错误import * as dayjs from dayjs,我真的不知道它是否是一个错误。

完美解决

@stouch
Copy link

stouch commented Apr 19, 2024

已解决 谢谢!
使用 TypeScript 时,必须"esModuleInterop": true在 ts-config.ts 中设置才能导入 dayjsimport dayjs from "dayjs";而不是import * as dayjs from "dayjs";.
只有在没有这个 TS 配置的情况下通过导入 dayjs 才会出现此错误import * as dayjs from dayjs,我真的不知道它是否是一个错误。

完美解决

@HZ-ZY English is an easy language that you, of course, can speak. Please be respectful and answer in english on Github. (Even in France, we make some effort....)

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

6 participants