slackapi / slackapi/node-slack-sdk

web-api: type-safe response properties access

Open
#1,902 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:typescript auto-triage-skip enhancement pkg:web-api question semver:major
Dominant language
TypeScript
Stars
3.4k
Forks
688
Avg merge
15h 31m
Merged PRs (30d)
27

Description

What type of issue is this? (place an x in one of the [ ])
  • bug
Requirements (place an x in each of the [ ])
  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report
const slackUser = await app.client.users.info({
    user: installation.user.id,
})

slackUser.user.name // Object `user` is possibly 'undefined'.

If there was an error here, the function would throw an error and we could catch it somewhere else. It's confusing me and should be a bug that we can't safely access properties after a function is called with no errors.

Should we be having to use if {} else {} to safely access these properties?

Reproducible in:

package version: "@slack/bolt": "^3.12.2",

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.

Research direction

Reproduce the TypeScript example from the report using @slack/bolt 3.12.2, then trace the response type for app.client.users.info and its user property. Done means a successful response can expose its properties without an unnecessary undefined check, with coverage for the reported access pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.