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

Potential typing issue with datastore API #81

Open
filmaj opened this issue Jul 14, 2023 · 1 comment
Open

Potential typing issue with datastore API #81

filmaj opened this issue Jul 14, 2023 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@filmaj
Copy link
Contributor

filmaj commented Jul 14, 2023

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'
}
@filmaj filmaj added the question Further information is requested label Jul 14, 2023
@filmaj filmaj self-assigned this Jul 14, 2023
@WilliamBergamin
Copy link
Contributor

This does seems correct our typeahead for datastores is not as capable as the one found for input parameters in functions

Screenshot 2023-07-14 at 3 11 18 PM
Screenshot 2023-07-14 at 3 11 38 PM

Where with input functions we properly predict the type

Screenshot 2023-07-14 at 3 14 11 PM

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

No branches or pull requests

2 participants