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

feat(typescript): compile-time missing secret error #461

Merged
merged 3 commits into from
Mar 30, 2021

Conversation

jablko
Copy link
Contributor

@jablko jablko commented Feb 12, 2021

Should this be a compile-time as well as a run-time error?

--- a/test/unit/middleware-constructor-test.ts
+++ b/test/unit/middleware-constructor-test.ts
@@ -1,5 +1,6 @@
 import { createMiddleware as Middleware } from "../../src/middleware";
 
 test("options: none", () => {
+  // @ts-expect-error
   expect(() => Middleware({})).toThrow();
 });

@jablko jablko changed the title feat(typescript): compile time missing secret error feat(typescript): compile-time missing secret error Feb 12, 2021
src/index.ts Outdated
if (!options || !options.secret) {
throw new Error("[@octokit/webhooks] options.secret required");
}

const state: State = {
const state = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const state = {
const state: State & { secret: string }= {

This needs to be explicitly typed as it's an object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied this change although I confess I don't understand it: why do objects need to be explicitly typed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered in #466 (comment), thanks!

G-Rath
G-Rath previously requested changes Feb 12, 2021
src/middleware/index.ts Outdated Show resolved Hide resolved
wolfy1339
wolfy1339 previously approved these changes Feb 14, 2021
@wolfy1339 wolfy1339 added the Type: Feature New feature or request label Feb 14, 2021
@jablko jablko requested a review from G-Rath February 17, 2021 16:40
Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! We shoudl have that a long time ago! I am sure we will be able to make the types much more elegant once we split out the event handling into its own module

@gr2m gr2m dismissed G-Rath’s stale review March 30, 2021 12:12

resolved

@gr2m gr2m merged commit deefd69 into octokit:master Mar 30, 2021
@github-actions
Copy link
Contributor

🎉 This PR is included in version 8.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants