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

Reviewing Types #1542

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Reviewing Types #1542

wants to merge 5 commits into from

Conversation

filmaj
Copy link
Contributor

@filmaj filmaj commented Oct 4, 2022

⚠️ DO NOT MERGE

Summary

This is my first pass at reviewing the types in this repo in preparation for wanting to consume them in the deno-slack-sdk.

I used the following api.slack.come pages as part of this review:

I tried to organize a majority of the types in this module into roughly three categories based on the above api.slack.com pages.

Added some missing properties, updated what is optional and what is not based on the above api.slack.com pages. I left some TODOs in, as well, based on what issues I saw that I did not feel like tackling immediately.

TODO

I do want to split this file up into smaller, more focussed/thematic files - but I will do that in a follow-up PR. I want to also put in some time to add nice JSDoc comments to all interfaces and types, I think that would improve the developer experience as well. Initially, however, I just want the properties to be reflected accurately so that I can test this repo in bolt-js, web-api and in deno-slack-sdk apps, and see how they work together.

Testing

Speaking of testing: I tested this with both the @slack/web-api and @slack/bolt repos. Both repos' unit tests pass without issue. That said, I am wondering if this is a false negative... likely needs more testing in a real app.

Releasing

Not sure if this should be released / merged into main, or if this should maybe be released as a RC/alpha/beta style release on npm in the short term, until more complete manual testing can be complete. Thoughts?

…composition objects), updated optional/required state on many properties, added missing properties on some interfaces.
@filmaj filmaj added enhancement M-T: A feature request for new functionality area:typescript issues that specifically impact using the package from typescript projects pkg:types applies to `@slack/types` labels Oct 4, 2022
@filmaj filmaj self-assigned this Oct 4, 2022
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving this!

initial_user?: string;
placeholder?: PlainTextElement;
placeholder: PlainTextElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure that this is optional, so this change should be reverted. The document is wrong! See a Block Kit Builder example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct! I was very surprised but confirmed that for all these Block Elements, both placeholder and action_id are optional. I am working on a PR to update the docs. Thanks for pointing this out, I have updated these to set placeholder and action_id to optional.

initial_users?: string[];
placeholder?: PlainTextElement;
placeholder: PlainTextElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

max_selected_items?: number;
confirm?: Confirm;
focus_on_load?: boolean;
}

export interface StaticSelect extends Action {
type: 'static_select';
placeholder?: PlainTextElement;
placeholder: PlainTextElement;
action_id: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: when you build a block element, setting action_id is optional (auto-generated one will be used in the case). thus, strictly speaking, this can be optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure action_id is optional? The docs say it is required. I know block_id is optional and one will be auto-generated for you in that case.
I will test this today in real apps and report back!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow I can't believe it, action_id is optional 😆

initial_options?: PlainTextOption[];
options?: PlainTextOption[];
options?: PlainTextOption[]; // TODO: options and option_groups are mutually exclusive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point but i am unsure how we can represent this type of constraints in a simple way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will ask Neil who is the deno-slack-sdk type master 😄

@seratch
Copy link
Member

seratch commented Oct 4, 2022

@filmaj For better testing, checking the compatibility with actual production payload data may be helpful. I have been doing so for python/java projects, which is quite beneficial for detecting errors in real life.

@filmaj
Copy link
Contributor Author

filmaj commented Oct 5, 2022

@seratch sounds good, I was planning on doing that yesterday but ran out of time. I will do so today.

@filmaj filmaj requested a review from seratch October 5, 2022 16:47
Co-authored-by: Sarah Jiang <sarahjiang@slack-corp.com>
@@ -226,6 +241,7 @@ export interface ExternalSelect extends Action {

export interface MultiExternalSelect extends Action {
type: 'multi_external_select';
// event to return option data. so de-facto this is necessary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain I understand what this comment means! Is this a note to self?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL it was a much longer comment that I had before that I then decided to remove which I clearly didn't do a great job of 😆

*/
block_id?: string; // TODO: in event payloads, this property will always be present. When defining a block, however,
// it is optional. If not defined when the block is created, Slack will auto-assign a block_id for you - thus why it
// is always present in payloads. So: how can we capture that? Differentiate between the event payload vs. the block
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably have to, since I don't see a world where this particular behavior changes - and the behavior seems reasonable. Were you thinking that this Block Kit type could somehow be used to model event payload responses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly! At least, I was consider if that would be possible! If you look at the block_actions payload event's fields, you'll see that there is an array of actions provided in the payload. These actions are the exact block kit elements that were interacted with - so I was considering if it would be possible to re-use the types in this repo to try to model the items of that actions array in the block_actions payload.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the item in actions in a block_actions payload, we already have complete types in bolt-js. If we would like to have it, we can consider moving the ones in bolt-js into this repo. Reusing Action and so on here may cause unnecessary complexity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seratch Yes I would like to eventually move as many types for things shared across repos as possible into this repo. For the block_actions payload, for example, I know right now we only need it in bolt-js. However, in deno-slack-sdk, it is also needed. So all of this work is in prep for trying to consolidate not just around our existing node projects, but across our newer deno ones too.

Copy link
Member

@srajiang srajiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review add and so glad you're working on this (mostly because of all the adjacent improvements to our documentation this work becomes a forcing function too...)! I don't have much to add wrt to correctness of these types but:

wrt: Testing
👍 to more manual testing needed, and wondering whether we can spin off a couple of concrete tasks around incorporating into sample apps.

wrt: release strategy
An rc release of this off a branch while we're testing sounds good to me! Any strong benefit you see to incorporating into main at this early stage?

@filmaj
Copy link
Contributor Author

filmaj commented Oct 5, 2022

An rc release of this off a branch while we're testing sounds good to me! Any strong benefit you see to incorporating into main at this early stage?

RC release seems safe to me at this stage, yeah. I do plan on adding a ton of niceties to this repo (JSdocs, links to api.slack.com, etc.), so releasing to main at some point would be a nice little present for our devs 😊

Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me so far

@filmaj
Copy link
Contributor Author

filmaj commented Oct 6, 2022

So maybe instead of merging this PR into the main branch, I keep this work on the branch it currently exists on (centralized-types) and create beta / release-candidate tags off of this branch for the time being?

@filmaj filmaj marked this pull request as draft October 7, 2022 13:31
@filmaj
Copy link
Contributor Author

filmaj commented Oct 7, 2022

I've started to release this branch under the 2.8.0-centralized.X suite of git tags and the centralized dist-tag on npm.

@filmaj filmaj modified the milestones: types@3.x, types@3.0 Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typescript issues that specifically impact using the package from typescript projects enhancement M-T: A feature request for new functionality pkg:types applies to `@slack/types`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants