slackapi / slackapi/deno-slack-api

Potential typing issue with datastore API

Open
#81 1 comment 0 reactions 1 assignee View on GitHub

@filmaj is already working on this.

Since Jul 14, 2023.

question
Dominant language
TypeScript
Stars
45
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Need to reproduce as a first step!

But, as reported in a feedback session by a community developer, with the following datastore:

export const OldestCodeReviewDatastore = DefineDatastore({
  name: 'code_review_datastore',
  attributes: {
    id: {
      type: Schema.types.string
    },
    timestamp: {
      type: Schema.types.string
    }
  },
  primary_key: 'id'
})

This code apparently returns an any type.

async function getOldestReview(client: SlackAPIClient, channel: string) {
  const oldestReview = await client.apps.datastore.get<typeof OldestCodeReviewDatastore.definition>({
    datastore: 'code_review_datastore',
    id: 'oldest_review_' + channel
  })

  if (!oldestReview.ok) {
    console.log('Error during request apps.datastore.get!', oldestReview)
    return '0'
  }

  return oldestReview?.item?.timestamp ?? '0'
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.