Cannot access the user id in the "message_changed" event with TypeScript

Aperta
#2,026 4 commenti 3 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
api

Direzione di ricerca

Inizia in src/types/events/message-events.ts, intorno alla definizione di MessageChangedEvent alla riga 233, quindi confronta i tipi di message e previous_message con la documentazione dell’evento message_changed di Slack. Il lavoro è completo quando event.message.user viene accettato da TypeScript e le proprietà dell’evento corrispondono alla struttura documentata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:typescript bug enhancement pkg:types semver:major
Reproducible in:
The Slack SDK version

3.13.1

Node.js runtime version

v16.15.1

OS info

ProductName: macOS
ProductVersion: 12.6.5
BuildVersion: 21G531
Darwin Kernel Version 21.6.0: Thu Mar 9 20:08:59 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_X86_64

Steps to reproduce:

The Slack docs say that there should be the message.user key in the message_changed event containing the Slack user id.

The TypeScript interface for the MessageChangedEvent refers to the MessageEvent interface in the message and the previous_message properties that make TypeScript assume that accessing event.message.user is not allowed because not every subtype of the message event contains a user id.

It seems like the reference to the MessageEvent is incorrect because (I suppose) not every message can be edited and moreover it makes the circular dependency in types when the message_changed event can reference to the message_changed event and so on.

Expected result:
  • the message property of the message_changed event has the valid type according to the Slack docs
  • no TypeScript errors when accessing event.message.user for the message_changed event.
Actual result:
TS2339: Property 'user' does not exist on type 'MessageEvent'.
Lingua principale
TypeScript
Stelle
3.4k
Fork
693
Merge medio
1g 1h
PR unite (30g)
67

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di slackapi/node-slack-sdk

Tutte le issue di slackapi/node-slack-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.