Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript implementation makes FileTypes and DirectoryTypes difficult to work with #23

Open
alexiswl opened this issue Nov 22, 2022 · 2 comments

Comments

@alexiswl
Copy link
Contributor

alexiswl commented Nov 22, 2022

Hello,

Linking in the following related conversations / docs / issues:

Tagging
@mr-c , @ZimmerA, @kinow as active participants in the issues linked above

Feature Request Summary

Comparing cwl-ts-auto to rabix-cwlts, I have found that the rabix-cwlts repo to be more user friendly for my use case by having File and Directories as simple interfaces.

I wonder if it's possible we could have similar interfaces in the cwl-ts-auto TypeScript module?

cwl-ts-auto example

Typescript using the cwl-ts-auto module can be found here.

https://github.com/umccr/cwl-ica/tree/main/expressions/get-bam-file-from-directory/1.0.1

rabix-cwl-ts example

The equivalent typescript expressions using the rabix-cwl-ts module can be found here.

https://github.com/umccr/cwl-ica/tree/main/expressions/get-bam-file-from-directory/1.0.1-rabix

Differences

Differences include:

Other nuisances

We currently use the sed command to somewhat hack our output JS to a CWL-compatible JS.

The expressions required are shown below (and are described here)

/^exports\.*/d;
/^var\ .*\ =\ require(.*)*/d;
/^Object\.defineProperty(exports*)*/d;
s%//(.*)%/* \1 */%;
s%class_%class%g;
s%:\ %:%g;
s%cwl_ts_auto_1.File_class.FILE%"File"%g;
s%cwl_ts_auto_1.Directory_class.DIRECTORY%"Directory"%g;

Of these expressions, the following are related to cwl-ts-auto specifically

  • /^var\ .*\ =\ require(.*)*/d;
  • s%class_%class%g;
  • s%cwl_ts_auto_1.File_class.FILE%"File"%g;
  • s%cwl_ts_auto_1.Directory_class.%"Directory"%g;

I think there's a lot of potential in the TypeScript in CWL front and would be keen to use this repository more.
However, these discrepancies I've pointed out above do make it harder for CWL users to overcome the learning curve of using TypeScript in their JS expressions. Would be keen to scope out what can be done to improve this!

Alexis

@mr-c
Copy link
Member

mr-c commented Nov 22, 2022

Thank you very much @alexiswl for this review!

I made a PR to update using the latest schema, which makes using hints, and default fields more pleasant, but these were not your issues.

I'll let @ZimmerA comment on allowing class versus class_ as I'm not a TypeScript dev :-)

Is it possible in TypeScript to import all items from a module/namespace? Then all the enum values (like File_class.FILE) could be importable with a single line of code using a new convenience file.

@tetron
Copy link

tetron commented Nov 22, 2022

"class" is a reserved word in both Python and Typescript, although there are probably situations where it can be used as a regular field name which will be different for each language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants