web-api: type-safe response properties access

Offen
#1,902 4 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
typescript
Bereich
api

Rechercherichtung

Reproduziere das TypeScript-Beispiel aus dem Bericht mit @slack/bolt 3.12.2 und verfolge anschließend den Antworttyp für app.client.users.info und dessen user-Eigenschaft. Als erledigt gilt die Aufgabe, wenn eine erfolgreiche Antwort ihre Eigenschaften ohne eine unnötige undefined-Prüfung zugänglich machen kann und das gemeldete Zugriffsmuster abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area:typescript auto-triage-skip enhancement pkg:web-api question semver:major
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",

Vorherrschende Sprache
TypeScript
Sterne
3.4k
Forks
694
Ø Merge
1 T. 10 Std.
Gemergte PRs (30 T.)
75

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus slackapi/node-slack-sdk

Alle Issues in slackapi/node-slack-sdk

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.