-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Refactor types #5178
Refactor types #5178
Conversation
How to testgit clone -b refactor-types https://github.com/Pcrab/hexo.git
cd hexo
npm install
npm test |
lib/plugins/console/index.ts
Outdated
@@ -1,4 +1,6 @@ | |||
export = function(ctx) { | |||
import Hexo from '../../hexo'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import Hexo from '../../hexo'; | |
import type Hexo from '../../hexo'; |
Use import type
for type only imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3ad806d.
Maybe we should add a rule in .eslintrc.json
to enforce this style?
{
"rules": {
"@typescript-eslint/consistent-type-imports": "warn",
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you :)
What does it do?
Add types to Hexo class and extend apis.
Only types are changed except for
lib/extend/tag.ts
, where I added an intermediate variable. All these changes should have no effect on runtime behavior.This may help plugin authors who can now add hexo as devdependency and add
declare var hexo: import("hexo")
toglobal.d.ts
to get better type inference.Screenshots
After adds
I can get better type inference like this:
which used to be just any type.
Pull request tasks