headintheclouddev / typings-suitescript-2.0

TypeScript typings for SuiteScript version 2.0
MIT License
145 stars 92 forks source link

Update asMappedResults() and asMap() functions #242

Closed accountingnerd closed 1 year ago

accountingnerd commented 1 year ago

The functions asMappedResults() and asMap() both had overloads that extended Object. This change creates a new type (QueryResultMap) that allows us to further narrow the possible types returned by the Query object.

accountingnerd commented 1 year ago

@ShawnTalbert -- I was pondering life in the shower the other day, and realized my mistake with the previous pull request. What do you think about this one? I dropped the "Extends" from the type argument.

ShawnTalbert commented 1 year ago

Hi. Might want to export QueryResultsMap so it can be referenced outside this file.

Just going by memory, is null a value that actually gets returned by asMappedResults()?

This also gets me thinking - we should probably have unit tests for all changes - they would act as documentation on how to use these types as well as protecting against regression. I see we have some work there under the /spec folder but looks like it's just a start?

accountingnerd commented 1 year ago

Addressing the questions:

gabrielgortabns commented 1 year ago

Hello, can we also export that type? I would like to type inside my library as QueryResultMap.

I don't know that we need to export the type. It should be local to the module, and becomes available for use when (and if) you call the asMap() and asMappedResults() functions.

I think it should be, for example I use type string | number | boolean rn, for my library that use asMap()...

MrRob commented 1 year ago

@GabrielGorta I don't see why not, do you want to do a pull request for that?