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

hexo.theme.config property should not be of type object #5403

Closed
5 tasks done
zkz098 opened this issue Jan 20, 2024 · 0 comments · Fixed by #5398
Closed
5 tasks done

hexo.theme.config property should not be of type object #5403

zkz098 opened this issue Jan 20, 2024 · 0 comments · Fixed by #5398

Comments

@zkz098
Copy link

zkz098 commented Jan 20, 2024

Check List

  • I have already read Docs page & Troubleshooting page.
  • I have already searched existing issues and they are not help to me.
  • I examined error or warning messages and it's difficult to solve.
  • I am using the latest version of Hexo. (run hexo version to check)
  • My Node.js is matched the required version.

Expected behavior

The hexo.theme.config should be of type any or another type that allows access to unknown properties. For example, the following line of code works well on Hexo 7.0.0:

const VendorsCfg = hexo.theme.config.vendors as VendorsConfig;

Actual behavior

But in Hexo 7.1.0, this code cannot pass TypeScript compilation because hexo.theme.config is of type object, and this type does not allow access to unknown properties. When compiling the above code with Hexo 7.1.0, the result is:

Error: utils.ts(24,40): error TS2339: Property 'vendors' does not exist on type 'object'.

If I want to make it compile in Hexo 7.1.0, I have to use the following code snippet:

const VendorsCfg = (hexo.theme.config as any).vendors as VendorsConfig;

How to reproduce?

Accessing any custom property of hexo.theme.config in TypeScript.

Is the problem still there under Safe mode?

This issue occurs in the development environment and is unrelated to Safe Mode.

Your Node.js & npm version

v20.11.0
10.2.4

Your Hexo and Plugin version

This issue occurs in the development environment, so I am unable to provide specific details for this item.

Your package.json

I provide the `package.json` for this development environment as the content for this item:
{
    "name": "hexo-theme-shokax",
    "version": "0.3.12",
    "description": "a hexo theme based on shoka",
    "main": "index.js",
    "repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
    "author": "zkz098",
    "license": "AGPL-3.0-or-later",
    "scripts": {
        "test": "tsc --build --verbose",
        "build": "cd ./source && tsc --build --verbose && cd ../scripts && tsc --build --verbose"
    },
    "devDependencies": {
        "@types/fancybox": "^3.5.6",
        "@types/jquery": "^3.5.29",
        "@types/js-yaml": "^4.0.9",
        "@types/lozad": "^1.16.4",
        "@types/node": "^20.11.5",
        "@typescript-eslint/eslint-plugin": "^6.19.0",
        "@typescript-eslint/parser": "^6.19.0",
        "eslint": "^8.56.0",
        "eslint-config-standard": "~17",
        "eslint-plugin-import": "^2.29.1",
        "eslint-plugin-n": "^16.6.2",
        "eslint-plugin-promise": "^6.1.1",
        "eslint-plugin-vue": "^9.20.1",
        "instantsearch.js": "^4.64.0",
        "typescript": "^5.3.3",
        "vue": "^3.4.15"
    },
    "dependencies": {
        "esbuild": "^0.19.11",
        "hexo": "^7.0.0",
        "hexo-fs": "^4.1.1",
        "hexo-pagination": "^3.0.0",
        "hexo-util": "^3.2.0",
        "js-yaml": "^4.1.0",
        "lozad": "^1.16.0",
        "mouse-firework": "^0.0.4",
        "theme-shokax-anime": "^0.0.6",
        "theme-shokax-pjax": "^0.0.3"
    },
    "engines": {
        "node": ">=18.0.0"
    },
    "engineStrict": true
}

Your site's _config.yml (Optional)

No response

Others

No response

@D-Sketon D-Sketon mentioned this issue Jan 20, 2024
2 tasks
@D-Sketon D-Sketon linked a pull request Jan 20, 2024 that will close this issue
2 tasks
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 a pull request may close this issue.

1 participant