-
Notifications
You must be signed in to change notification settings - Fork 93
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
#307 Assign type of any to asMap and asMappedResults #308
base: master
Are you sure you want to change the base?
Conversation
…nt to meaningful specific type
I would suggest we make this a generic so the caller can directly provide a return type instead of introducing 'any'. Thoughts? |
I agree @ShawnTalbert , I've been meaning to do this. @bbahrman , let me know if you need a hand converting this to use Generics. |
@ShawnTalbert @darrenhillconsulting - Thanks for the suggestion to use a generic, new to me, sorry it took a bit for me to get myself understanding what you were trying to do with it. Thanks Darren for the example. I think I just copied and pasted your example in, but wanted to test it out to be sure I understood the why (I trust you, but like to learn). Do either of you feel the need to have the generic type be a named type in some way? I don't think it does, but let me know if you want any further changes. |
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.
Maybe remove unrelated changes? Like the JSDoc changes?
@darrenhillconsulting fair point, sorry those were some errant whitespace changes. I've cleaned them up. |
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 like this change. @ShawnTalbert ?
@MrRob , what's your thoughts on this one? |
I'm still confused on how this works. Can someone record a quick Loom demo? Or, I've updated the example-UserEventScript.ts to have a query in it, the old ("as any") way. Can we update that with an example in this PR? |
…bahrman/typings-suitescript-2.0 into headintheclouddev#307-query-result-map
@MrRob https://www.loom.com/share/96938eb830ec4031aa9ccd28bbe020e0 I'm still trying to figure out a solution for @ShawnTalbert 's question. I tried just renaming LowerCaseKeys back to QueryResultMap. I tried a bunch of other variations but couldn't find a cleaner option that also maintained the validations. In the process I also added in some result validation. Queries don't return booleans which the previous type allowed, results will be string, number, or null. |
@bbahrman , the small change from my replies about is to be sure we type each key to match the type in the user-provided generic - otherwise every key had type |
Assigning type of any to asMap and asMappedResults allows for them to be assigned to meaningful interfaces/types
See: #307