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(typescript): revert #459 & #464 #494

Merged
merged 4 commits into from
Mar 14, 2021

Conversation

oscard0m
Copy link
Member

@oscard0m oscard0m commented Mar 14, 2021

📝 Summary

Reverts the following PR's:

⛱ Motivation and Context

Types for webhooks are broken when a transform function is passed in the options:
octokit/app.js#213 (comment)

Follow up conversation:
#492 (comment)

@oscard0m oscard0m added the Type: Bug Something isn't working as documented, or is being fixed label Mar 14, 2021
@oscard0m oscard0m force-pushed the revert-last-transofmr-method-type-changes branch from c4fc4e4 to b46303a Compare March 14, 2021 18:23
@oscard0m oscard0m force-pushed the revert-last-transofmr-method-type-changes branch from b46303a to 9e002f8 Compare March 14, 2021 18:26
@oscard0m oscard0m requested a review from wolfy1339 March 14, 2021 18:30
@oscard0m oscard0m changed the title This reverts commit aad9b74ba90f8ca633c811231f1f566f59e241bd. reverts: "fix(typescript): #464 and #459" Mar 14, 2021
@wolfy1339 wolfy1339 changed the title reverts: "fix(typescript): #464 and #459" 🚧 reverts: "fix(typescript): #464 and #459" Mar 14, 2021
@wolfy1339
Copy link
Member

This fixes the problem.

What about the scenario brought up in #464? Since we only allow to append to the event and not change it completely.

@oscard0m
Copy link
Member Author

oscard0m commented Mar 14, 2021

This fixes the problem.

I would like to add a test in typescript.validate.ts to cover the case we are fixing so we avoid regressions in the future

What about the scenario brought up in #464? Since we only allow to append to the event and not change it completely.

I would create an issue (I think there was not one before) so we keep discussing this. What do you think?

@wolfy1339
Copy link
Member

I would like to add a test in typescript.validate.ts to cover the case we are fixing so we avoid regressions in the future

That should be as easy, just add an event handler for a certain event (ex: issues), and then try to access a property that exists only on that event (ex in the issues event: issue)

I would create an issue (I think there was not one before) so we keep discussing this. What do you think?

Yes, we should create an issue.

@oscard0m
Copy link
Member Author

I would like to add a test in typescript.validate.ts to cover the case we are fixing so we avoid regressions in the future

That should be as easy, just add an event handler for a certain event (ex: issues), and then try to access a property that exists only on that event (ex in the issues event: issue)

We have this already, and seems it did not prevent us to break types:

webhooks.on("issues", (event) => {
console.log(event.payload.issue);
});

This is the test example you were suggesting right?

@wolfy1339
Copy link
Member

That doesn't have the transform method, but it is the exact sort of test that needs to be added. Look further down, there is another section of the tests where we have the transform method

webhooks.on("issues", (event) => {
// foo is set by options.transform
console.log(event.foo);
});

@wolfy1339 wolfy1339 requested a review from G-Rath March 14, 2021 19:16
@oscard0m
Copy link
Member Author

oscard0m commented Mar 14, 2021

Ok, but with changes introduced by this PR it passes the transform method in L75 to all following lines so we are covering the use case now, right?

@wolfy1339
Copy link
Member

After a second look, I can say that that should do the trick for the purposes of this PR

@oscard0m oscard0m changed the title 🚧 reverts: "fix(typescript): #464 and #459" reverts: "fix(typescript): #464 and #459" Mar 14, 2021
@oscard0m
Copy link
Member Author

oscard0m commented Mar 14, 2021

After a second look, I can say that that should do the trick for the purposes of this PR

Added a comment linking to this PR for that line to give context for other developers before modifying it in the future

Copy link
Member

@G-Rath G-Rath left a comment

Choose a reason for hiding this comment

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

Added a comment linking to this PR for that line to give context for other developers before modifying it in the future

Per my comment here, at some point we should modify the runtime code to prevent this as much as possible.

@wolfy1339 wolfy1339 changed the title reverts: "fix(typescript): #464 and #459" fix(typescript): revert #459 & #464 Mar 14, 2021
@wolfy1339
Copy link
Member

Closes octokit/app.js#213

This was referenced Mar 15, 2021
@wolfy1339 wolfy1339 mentioned this pull request Mar 27, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented, or is being fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing down event name into TransformMethod to allow for the right payload types to be used
3 participants