dts-google-apps-script icon indicating copy to clipboard operation
dts-google-apps-script copied to clipboard

Update your generator to emit ts type "number" for "Integer"

Open hess-g opened this issue 9 years ago • 3 comments

You need to map Apps Script's "Integer" datatype to ts' "number" primitive. It looks like you are already correctly handling the casing of boolean and string (upper case in gas docs, lower case in ts types).

You might also take a look to see if you want to emit "any" instead of "Object". There may be cases where an Apps Script developer is used to calling prototype methods on the return, which in turn the Apps Script runtime is pretty good at handling. The ts compiler would fail on Object, but would allow on 'any'.

hess-g avatar Jan 01 '16 16:01 hess-g

Thank you for pointing out, I believe there's a hand-written type alias for Integer at https://github.com/motemen/dts-google-apps-script/blob/782478f/google-apps-script/google-apps-script.types.d.ts#L9 , which cannot be simply replaced to number as we want to keep the information that an argument is an integer, not a number including floats.

For the Object case, it seems reasonable to replace or assign Object to 'any'. If you don't mind providing some test cases, it would be easier to implement this. Thanks!

motemen avatar Jan 04 '16 05:01 motemen

Since you are just mapping Apps Script's Integer to ts' number type, it probably is OK doing that explicitly, but you could wait on for more votes than just my 1. I also saw a few instances of String[] that need to be lowercased. For example, in the spreadsheet class DataValidationBuilder#requireValueInList.

hess-g avatar Jan 04 '16 21:01 hess-g

@hess-g I created PR GH-9 to fix the String and Boolean array issue

PopGoesTheWza avatar Dec 28 '18 07:12 PopGoesTheWza