headintheclouddev / typings-suitescript-2.0

TypeScript typings for SuiteScript version 2.0
MIT License
148 stars 93 forks source link

Why not use `declare module` typings? #269

Open pauldraper opened 8 months ago

pauldraper commented 8 months ago

Path mappings work, but are rarely used since every downstream TypeScript project also has to set them.

More typical is module declarations.

declare module "N/log" {
}

These are then added by one of:

  1. Installing under @types as a npm alias (or having the project in DefinitelyTyped to begin with)
  2. Adding typeRoots.
  3. Referencing the types via tripe slash /// <reference types="..." />

Note that module declarations is how Node.js typings work (@types/node).

btonasse commented 1 month ago

This might be worth a fork

ShawnTalbert commented 1 month ago

I'd always be in favor of making these types easier for end users to adopt in their projects.

If either of you ( @btonasse, @pauldraper) have explored this in a fork, feel free to suggest a PR?

Have we previously considered adding this to DefinitelyTyped? If so, why isn't this there? If not, it's worth looking into.

MrRob commented 4 weeks ago

Sounds interesting, I don't know if it was ever considered, we'd have to ask @johnogle222

johnogle222 commented 3 weeks ago

I am far from qualified to comment on the best way to declare typescript definitions these days. There's no particular reason why this project is setup using the conventions that it is other than it worked for me at the time and others grew it from there. If there is a better way to structure it that makes the project easier to adopt and use then by all means don't let me get in the way :)

btonasse commented 3 weeks ago

Hi @ShawnTalbert I'm also far from a typescript expert, so I don't know if anything I did there is good practice, but I actually did create a fork: https://github.com/btonasse/suitescript-types

pauldraper commented 3 weeks ago

Re "best practice": The most user-friendly thing to do is to get types in https://github.com/DefinitelyTyped/DefinitelyTyped, as @types/suitescript.

Similar to @types/node https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node .