-
Notifications
You must be signed in to change notification settings - Fork 663
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
Draft: Improve types #1228
Draft: Improve types #1228
Conversation
export interface Dialog { | ||
title: string; | ||
callback_id: string; | ||
elements: { | ||
type: 'text' | 'textarea' | 'select'; |
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'm afraid that changing union type to enum may not be fully backward-compatible. I cannot tell what the possible troubles are by this but at least, unions and enums are not the same. To me, just naming the union types would be a safer refactoring. What do you think?
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.
Just my two cents, but I really love enums more than unions aha
I've been playing around with this a bit, and you are totally right. For some reason, I always though of enums as a subset of union types, but it will not work with simple strings. Naming the union types would definitely make the code more structured, but that would be a change that's more internal for your team as opposed to offering value for developers using the SDK. There is one other possibility, to have those values available as imports – export an object literal instead of an enum and create union types that reference the values in those objects. Advantage would be having those available as constants instead of working with strings for those using the package, but not sure if that's in scope. |
What are thoughts on the discriminating union types for more strict type checking? Advantages:
Disadvantages:
|
I am closing this pull request - but have referenced the commits in it extensively! - in favour of having the different discussions about each type of change in this PR separately. They are:
Thank you very much for your work in this PR. I know it has dragged on for literal years, but I think we will actually incorporate at least some of the suggestions from this work into the project! |
Summary
Draft pull request to discussion in this issue around improving @slack/types. See discussion here.
Requirements (place an
x
in each[ ]
)