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

Update readme with type assertion information #310

Merged
merged 2 commits into from
Jan 22, 2020

Conversation

thboop
Copy link
Collaborator

@thboop thboop commented Jan 15, 2020

Related to #147

## Webhook Payload Typescript Definitions
`@octokit/webhooks` provides complete typescript definitions for the payloads associated with each event. You can cast the provided payload to these types for more type information as needed.

To do this, first install the npm module `npm install --save @octokit/webhooks`
Copy link
Contributor

Choose a reason for hiding this comment

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

is --save an option? the docs dont show that option. --save-prod is the default so i dont think we need any save flag at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TIL npm install now does this by default, but the --save command is supported for back compat (its a no-op). You used to have to --save dependencies otherwise they wouldn't appear in your package.json

@@ -55,3 +55,19 @@ const newIssue = await octokit.issues.create({
body: 'Hello Universe!'
});
```

## Webhook Payload Typescript Definitions
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider sentence-case rather than title-case. Sentence-case seems to be the common trend, e.g. here

@@ -55,3 +55,19 @@ const newIssue = await octokit.issues.create({
body: 'Hello Universe!'
});
```

## Webhook Payload Typescript Definitions
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consider blank line separating ## header and paragraph (typical markdown style)

## Webhook Payload Typescript Definitions
`@octokit/webhooks` provides complete typescript definitions for the payloads associated with each event. You can cast the provided payload to these types for more type information as needed.

To do this, first install the npm module `npm install --save @octokit/webhooks`
Copy link
Contributor

Choose a reason for hiding this comment

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

which version of octokit? it should match package.json

import * as Webhooks from '@octokit/webhooks'
if (github.context.eventName === 'push') {
const pushPayload = github.context.payload as Webhooks.WebhookPayloadPush
core.info(`The head commit is: ${pushPayload}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean pushPayload.head?

@@ -55,3 +55,19 @@ const newIssue = await octokit.issues.create({
body: 'Hello Universe!'
});
```

## Webhook Payload Typescript Definitions
`@octokit/webhooks` provides complete typescript definitions for the payloads associated with each event. You can cast the provided payload to these types for more type information as needed.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consider removing unnecessary words. E.g: The npm module @octokit/webhooks provides complete typescript type definitions for the response payloads associated with each event. You can cast the provided payload to these types for more better type information as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants