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

Day.js plugins and Typescript #2417

Closed
lhsazevedo opened this issue Oct 28, 2020 · 6 comments · Fixed by #2954
Closed

Day.js plugins and Typescript #2417

lhsazevedo opened this issue Oct 28, 2020 · 6 comments · Fixed by #2954
Assignees
Labels
org/keep Issues we want to keep open
Milestone

Comments

@lhsazevedo
Copy link
Contributor

Originally posted at #2391

Even not using directly, we need to import relativeTime dayjs plugin at js/src/common/utils/humanTime.ts. Without this import, typescript can't pick up tipes for the fromNow() method and complains.
The code still works though, because relativeTime plugin is installed at js/src/common/index.js:

https://github.com/flarum/core/blob/2ff46f5a2ebe2532f780f6e60a921beb41876d69/js/src/common/index.js#L12-L16

We can avoid this import if we move this plugin installation process to a separated dayjs library module, something like:

// js/src/common/lib/dayjs.ts

import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime';

dayjs.extend(relativeTime)

export default dayjs


// js/src/common/utils/humanTime.ts

// no need import relativeTime from 'dayjs/plugin/relativeTime';
import dayjs from '../../common/lib/dayjs'
@stale
Copy link

stale bot commented Jan 31, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum.
In any case, thanks for taking an interest in this software and contributing by opening the issue in the first place!

@stale stale bot added the stale Issues that have had over 90 days of inactivity label Jan 31, 2021
@stale
Copy link

stale bot commented Mar 20, 2021

We are closing this issue as it seems to have grown stale. If you still encounter this problem with the latest version, feel free to re-open it.

@stale stale bot closed this as completed Mar 20, 2021
@askvortsov1 askvortsov1 reopened this Mar 20, 2021
@stale stale bot removed the stale Issues that have had over 90 days of inactivity label Mar 20, 2021
@stale
Copy link

stale bot commented Jun 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum.
In any case, thanks for taking an interest in this software and contributing by opening the issue in the first place!

@stale stale bot added the stale Issues that have had over 90 days of inactivity label Jun 22, 2021
@davwheat davwheat added org/keep Issues we want to keep open and removed stale Issues that have had over 90 days of inactivity labels Jun 22, 2021
@davwheat
Copy link
Member

A better option is to include this plugin in the TS global typings file we have jQuery and such in at the moment.

@davwheat davwheat self-assigned this Jun 22, 2021
@lhsazevedo
Copy link
Contributor Author

I would like to try this! Would you mind if I do?

@davwheat
Copy link
Member

Go for it!

@SychO9 SychO9 added this to the 1.0.5 milestone Jul 5, 2021
@SychO9 SychO9 modified the milestones: 1.0.5, 1.1 Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
org/keep Issues we want to keep open
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants