-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Project Management Automation: Add TypeScript type-checking #20850
Conversation
Size Change: +1.62 kB (0%) Total Size: 857 kB
ℹ️ View Unchanged
|
@@ -77,6 +77,7 @@ | |||
"@babel/runtime-corejs3": "7.8.3", | |||
"@babel/traverse": "7.8.3", | |||
"@octokit/rest": "16.26.0", | |||
"@octokit/webhooks": "7.1.0", |
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.
Out of curiosity, do we include this dev dependency only for type checking?
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.
Yes, that's right.
Related to this guideline:
For packages which do not distribute their own TypeScript types, you are welcomed to install and use the DefinitelyTyped community-maintained types definitions, if one exists.
Though in this case, it's a bit awkward in that it's neither from DefinitelyTyped, nor actually the type of the packages we are using (@octokit/rest
, @actions/github
) or a dependent of those.
The reason for this is that the actual correct typings are neither very useful nor accurate:
https://github.com/actions/toolkit/blob/12f3011/packages/github/src/interfaces.ts#L15-L39
See also: actions/toolkit#147
It's still a bit questionable whether we should do this, since technically there's not a strong guarantee that the payload matches the type from @octokit/webhooks
, aside from the fact that they both purport to represent the structure of a webhook payload.
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.
Nice work here. This PR and your article https://andrewduthie.com/2020/03/15/typescript-types-for-productivity/, they made me think that we should add type definitions to all existing developer-oriented packages.
#18942 😉 |
Part of: #18838
This pull request seeks to enable type-checking for the Project Management Automation package, and improves existing types. GitHub's core modules provide types by default, which we can use to verify types of the implementation of our automation tasks.
Testing Instructions:
Ensure type-checking passes:
cc @sirreal