Comments (7)
Sorry, I didn't realize you were using @octokit/app
.
The solution you posted is almost entirely correct.
You don't have to pass the event to HandlerFunction<E, TTransformed>
The first parameter is the event name, the second is the value that is added onto the event object in the internals of the type.
The T & { octokit: Octokit }
is extraneous
You can simply do it this way:
type _HandlerFunction<T extends EmitterWebhookEventName> = HandlerFunction<
T,
{ octokit: Octokit }
>
from webhooks.js.
Your example has a syntax error.
I'm not sure why you would want to do that.
All the types for HandlerFunction
are exported
You can simply do:
const onDeploymentStatus: HandlerFunction<"deployment_status"> = (event) => {
// ...
}
app.on('deployment_status', onDeploymentStatus)
from webhooks.js.
HandlerFunction
doesn't appear to be exported in "@octokit/webhooks": "^12.0.3"
. Am I missing something?
from webhooks.js.
It isn't directly exported.
You have to import it from a specific file,
import type { HandlerFunction } from "@octokit/webhooks/dist-types/types.d";
from webhooks.js.
That works but octokit
isn't provided by HandlerFunction
import type { HandlerFunction } from "@octokit/webhooks/dist-types/types.d"
const onPullRequestClosed: HandlerFunction<
"pull_request.opened",
unknown
> = async ({ octokit, payload }) => { ... }
from webhooks.js.
Can you share what versions of Probot/Octokit packages you are using
from webhooks.js.
I'm using @octokit/[email protected]
, but HandlerFunction
is coming from @octokit/[email protected]
. Maybe I need the version from the @octokit/app
package.
import type { HandlerFunction } from "@octokit/webhooks/dist-types/types.d"
const onPullRequestOpened: HandlerFunction<
"pull_request.opened",
unknown
> = async ({ octokit, payload }) => {}
Update:
Here's what I did to get it working with Octokit
import { Octokit } from "@octokit/rest"
import type { EmitterWebhookEventName } from "@octokit/webhooks"
import type { HandlerFunction } from "@octokit/webhooks/dist-types/types.d"
type _HandlerFunction<T extends EmitterWebhookEventName> = HandlerFunction<
T,
T & { octokit: Octokit }
>
const onPullRequestOpened: _HandlerFunction<"pull_request.opened"> = async ({
octokit,
payload,
}) => { ... }
from webhooks.js.
Related Issues (20)
- [DOCS]: Provide an example of usage within Deno HOT 4
- [BUG]: Express middleware aborts on non-POST requests in v11 HOT 12
- How to disable secret verification? HOT 3
- [FEAT]: Add support for deployment_protection_rule event HOT 2
- [FEAT]: Export type MiddlewareOptions
- [BUG]: signature does not match event payload and secret HOT 4
- [DOCS]: Smee setup documentation has an error HOT 3
- The automated release is failing 🚨 HOT 1
- Avoid parsing JSON payload twice. HOT 4
- Memory leak/recursive loop in 12.0.7 in the types HOT 6
- [FEAT]: Export createNodeHandler HOT 11
- [BUG]: google-cloud-function, can not verify payload HOT 4
- [BUG]: bodyparser in get-payload potentially buggy HOT 2
- [MAINT]: Investigate performance loss due to data conversions HOT 8
- [BUG]: Current documentation still refers to outdated 'path' in Middleware options instead of the new `pathPrefix` HOT 5
- [BUG]: Preparsed payloads are not handled correctly, here Vercel HOT 4
- [BUG]: Type discrepencies vs actual code HOT 3
- [BUG]: webhooks.js v12.0.10 onward breaks compatibility with @fastify/middie middleware library HOT 4
- [MAINT]: drop aggregate-error dependency HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webhooks.js.