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

Missing type declarations for HomeView #1454

Closed
4 of 10 tasks
JustStanix opened this issue May 14, 2022 · 5 comments · Fixed by #1455
Closed
4 of 10 tasks

Missing type declarations for HomeView #1454

JustStanix opened this issue May 14, 2022 · 5 comments · Fixed by #1455
Assignees
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific
Milestone

Comments

@JustStanix
Copy link

Description

TS2339: Property 'team_id' does not exist on type 'View'.   Property 'team_id' does not exist on type 'HomeView'.

From my understanding of the Slack API documentation, the app_home_opened event should always contain a team_id in event.view. If so then HomeView is missing type declarations for this.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

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

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 3.3.0

node version: v16.4.2

OS version(s): Windows 11 Pro, WSL 2 (Ubuntu LTS)

Steps to reproduce:

  1. Create an app_home_opened event listener.
  2. Try to read team_id from event.view

Expected result:

What you expected to happen: TypeScript is happy :))

Actual result:

What actually happened: TypeScript is angy :(

@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific labels May 14, 2022
@seratch seratch added this to the 3.11.2 milestone May 14, 2022
@seratch
Copy link
Member

seratch commented May 14, 2022

Hi @JustStanix, thanks for taking the time to report this issue. You are right that the type definition for body.event.view of app_home_opened events is incomplete. We will improve this in future versions.

Apart from that, I would suggest using context.teamId instead. You can use the property as the way to know team_id for any type of event.

app.event('app_home_opened', async ({ context }) => {
  console.log(`context.teamId: ${context.teamId}`);
});

@JustStanix
Copy link
Author

Hi @seratch! Thank you for the suggestion, that fixes my issue.

@AlexisTonneau
Copy link

I also noticed that HomeView type doesn't include some fields, such as view.id whereas returned payload includes an id that could be used to update the view.

My received payload is

  view: {
    id: 'V03GMKH4T5E',
    team_id: 'T01PY724468',
    app_id: 'A034D9Y4U5T',
    app_installed_team_id: 'T01PY724468',
    bot_id: 'B03GMK1H5AL',
    type: 'home',
    blocks: [ [Object], [Object], [Object] ],
    state: { values: {} },
    hash: '1652879745.kmcdqLgk',
    private_metadata: '',
    callback_id: '',
    root_view_id: 'V03GMKH4T5E',
    external_id: '',
    title: { type: 'plain_text', text: 'View Title', emoji: true },
    close: null,
    submit: null,
    previous_view_id: null,
    clear_on_close: false,
    notify_on_close: false
  }

whereas HomeView is declared as

export interface HomeView {
    type: 'home';
    blocks: (KnownBlock | Block)[];
    private_metadata?: string;
    callback_id?: string;
    external_id?: string;
}

@filmaj
Copy link
Contributor

filmaj commented May 18, 2022

Hey @AlexisTonneau I posted your comment as an issue in the appropriate repo housing that particular type: slackapi/node-slack-sdk#1486.

We can continue discussion on your observation / issue over there.

@jakob-lilliemarck
Copy link

jakob-lilliemarck commented Jun 15, 2023

hey,
Why is this issue closed? The type for SlackEventMiddlewareArgs<'app_home_opened'> is still inaccurate and is missing declaration for view.team_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants