Writing Advanced CWL JS Expressions in TypeScript

Presenter: Alexis Lucattini, University of Melbourne Centre for Cancer Research (UMCCR) @alexiswl

Schedule:

  • Session 2: :earth_africa: :earth_asia: (EMEA-APAC) Wednesday, March 1st 07:00 - 11:00 UTC / 16:00 - 20:00 Japanese Standard Time
  • Session 3: :earth_asia: :earth_americas: (APAC-Americas) Thursday, March 2nd 19:00 - 23:00 US EST
    Friday, March 3rd 00:00 - 04:00 UTC / 09:00 - 13:00 Japanese Standard Time

Widespread use of CWL JavaScript Expressions is often restricted to simple one-line code fragments.

It is without dispute that writing complex, yet easily readable, ES5.1 conformant, JS code for CWL is inherently very difficult.

For many developers, interaction with CWL objects such as File, Dirent, Directory or custom-made schemas can prove to be a steep-learning curve.
It is therefore no surprise that writing complex CWL JS expressions is generally discouraged.
It is, however, sometimes necessary.

In this presentation we introduce the concept of writing our CWL JS expressions in TypeScript.

We will discuss the benefits of this approach, such as:

  • type-hinting for CWL Objects,
  • compatible β€˜transpilation’,
  • unit-testing with the jest framework
  • auto TypeScript-Interface creation for custom CWL Schemas.

We will view some simple and complex use-cases of CWL JS Expressions, the selection of open CWL TS packages and some caveats to consider for TypeScript in CWL.

We will conclude by noting that writing complex CWL JS expressions is a difficult task and alternative options should be considered. Using TypeScript may alleviate some existing challenges faced by developers writing CWL JS expressions.

Please leave your questions for the presenter below!

As an alternative to YouTube, this presentations is also available on ConfTube

1 Like

Hi Alexis!

Q. Just had a look at GitHub - umccr/cwl-ica: A collection of cwl-ica workflows along with a user guide for the commands to use and contributions guide, and I found some package.json files with ts, jest, etc. Is there any example that demonstrates CWL β†’ TS with tests & coverage?

Q. You mentioned the node_modules in Yarn, but Yarn V3 and PnP could be a possible solution. (You answered that in the meeting, but asking here too for others/posterity).

Thanks!

Hi Bruno,

Is there any example that demonstrates CWL β†’ TS with tests & coverage?

The only CWL β†’ TS is the conversion of CWL schemas to TypeScript interfaces. These exist inside the schemas directory. I don’t have tests for this sorry, but if you start with cwl-ica/bclconvert-settings__4.0.3.ts it shows it can handle very complex schemas.

For example tests showing TS to CWL expressions please checkout the TypeScript wiki page

but Yarn V3 and PnP could be a possible solution

Yes it sure could be, I’ll add something to the TypeScript wiki above, in the typescript expressions directory, yarn will create a file called .yarnrc.yml

You may set this to nodeLinker: pnp and see if that works for you?