Automating things with Javascript (MacOS, IOS) - Questions about workflows and tools

Dabbling with Javascript in various places (Keyboard Maestro, Scriptable widgets, Drafts, Omnigraffle, and more), I feel like I am missing a point:

  • I have a fair understanding of the syntax and programming concepts (classes, variables, functions, data structures, loops, etc…) which is enough to get me going.
  • But it feels like I am struggling on how to discover the interfaces that a program would expose (classes, methods,… ) which is even more key to the automation
    I mean, some of the documentations are helpful but it still feel very cumbersome to context-switch all the time to check which methods I can call in a script based on what I am doing.
    For example, recently playing with Scriptable Widget for IOS14, it took me quite some time to get something going just because I was having some issues understanding which parameters I could call, which type of entity I was referring to in my code and I am sure it could be much smoother.

–> Do you have some tools or methods that help you with some of the areas listing above? Like some IDE suited for Javascript in an IOS/MacOS automation context (ie: making scripts rather than full projects)? Maybe there is some obscure equivalence between AppleScript and Javascript where I could use an app dictionary to move around?
Really any helpful suggestion about tools, techniques, places to learn more about the workflow rather thanJS itself would be super welcome!

Thanks a lot!

I know there are definition files for Scriptable and Drafts.

I use the Drafts definitions on my Mac within Visual Studio Code. It is very rare for Scriptable I code anything off of i*OS as I can’t test it properly on the Mac.

But, honestly, I tend to keep the relevant documentation open alongside in case I need to reference something in detail or search for something. That is the purpose of the documentation after all. I would argue that switching or viewing alongside is part of most developers workflow; but as they learn more they reference it less - but things also change over time and that is ignored at your peril :wink:

I do also have a post relating to some actions I created to support easier JavaScript coding in Drafts.

Hope that helps.


Hi @sylumer! I’m new to definition files and trying to get them set up in Visual Studio Code.

However after a fair bit of poking around (with the Drafts one at first, since I at least know that should work in theory) I haven’t successfully worked out how to use the definitions file in VSC. Any chance you could point me in the right direction, or to any resources etc I should look at? I’m sure I’m missing something obvious.

I tried to follow this guide and muddled my way through eventually, but I don’t seem to have any definitions available. (For Step 5 I get a squiggly red error line, but I think I did read somewhere that that reference line is no longer required? I’m not getting anything either way.)

(I did find one for OmniFocus too, I think, which I would love to try out if I can figure out what I’m doing:

I think I just followed the details on the VS site. Installed Typescript, set-up the tsconfig.json file for the project, and then put the definition files in the same project root folder. Honestly, it’s been a few years since I did it but I think that is all I did originally.

But I’m also using my own TypeScript definition files to generate documentation for my Drafts library, so I probably have some extra parts in my config that wouldn’t be required for intellisense only use.

Hope that helps.

Thanks. I think I’m a little out of my depth (knowing nothing of Typescript whatsoever) – I think since a second round of “fiddling” has been unsuccessful I will have to put this on the “look into further some other day” list!