-
Notifications
You must be signed in to change notification settings - Fork 399
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
Fix #894 Unable to build options request objects in TypeScript #900
Conversation
Codecov Report
@@ Coverage Diff @@
## main #900 +/- ##
=======================================
Coverage 66.19% 66.19%
=======================================
Files 13 13
Lines 1204 1204
Branches 355 355
=======================================
Hits 797 797
Misses 338 338
Partials 69 69
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few comments for reviewers
export interface OptionsRequest<Source extends OptionsSource = OptionsSource> extends StringIndexed { | ||
export type OptionsSource = 'interactive_message' | 'dialog_suggestion' | 'block_suggestion'; | ||
|
||
export type SlackOptions = BlockSuggestion | InteractiveMessageSuggestion | DialogSuggestion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may sound a bit unnatural but this is consistent with other union types (e.g., SlackAction, SlackEvent, SlackShortcut, SlackViewAction)
type: Source; | ||
} | ||
|
||
type OptionsPayloadFromType<T extends string> = KnownOptionsPayloadFromType<T> extends never |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same approach with Events API payload handling.
/** | ||
* external data source in blocks | ||
*/ | ||
export interface BlockSuggestion extends StringIndexed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to remove StringIndexed but it's not backward compatible.
team: { | ||
id: string; | ||
domain: string; | ||
enterprise_id?: string; // undocumented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"undocumented " here could be outdated comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Summary
This pull request resolves #894 by correcting the types for external data source request payloads. @trevor-gullstad flagged this issue by sending pull request #893 (thank you very much!). Refer to the issue and my comments in this pull request for more details.
Requirements (place an
x
in each[ ]
)