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

fix: wrong type for StoreFunction of helper #5568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mufanc
Copy link

@Mufanc Mufanc commented Oct 29, 2024

What does it do?

The require actually leads to the imported type becoming any, which will cause some return value of helpers that actually return boolean or complex types to be incorrectly threated as string, yet cannot be detected by eslint, for example here:

const is = require('./is');
helper.register('is_current', is.current);
helper.register('is_home', is.home);
helper.register('is_home_first_page', is.home_first_page);
helper.register('is_post', is.post);
helper.register('is_page', is.page);
helper.register('is_archive', is.archive);
helper.register('is_year', is.year);
helper.register('is_month', is.month);
helper.register('is_category', is.category);
helper.register('is_tag', is.tag);

and here:

const tagcloud = require('./tagcloud');
helper.register('tagcloud', tagcloud);
helper.register('tag_cloud', tagcloud);

And this might lead to some undefined behaviors, so I think the return type of StoreFunction in the helper should be changed to any.

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Copy link

How to test

git clone -b refactor-types https://github.com/Mufanc/hexo.git
cd hexo
npm install
npm test

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

Successfully merging this pull request may close these issues.

1 participant