Can we have type aliases?
See original GitHub issueI would like to be able to create type aliases, namely something like this:
...
type PathToFastq = File
type PathToFasta = File
...
task bwa {
input {
PathToFastq read1
PathToFastq read2
PathToFasta fasta
...
}
...
}
What do other folks think? It would make reading the inputs a lot clearer and would allow folks to alias File
to their favorite genomic file format (ex. BED, BAM, XLSX …).
I’d be happy to make a PR; since this is my first time adding to the spec, I wouldn’t mind some help figuring out where it would go.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
How To Use Type Aliases in TypeScript - DigitalOcean
In this tutorial, you will refactor code that uses string literals to include aliases. You will be able to use and understand TypeScript...
Read more >TypeScript | Type Aliases - Codecademy
In TypeScript, type aliases create type definitions, using the `type` keyword and a name, that can be reused throughout the code.
Read more >Is it OK to have type aliases for primitive types in TypeScript?
In many cases a plain type alias is not the correct choice because there's probably something else you should use instead. But it...
Read more >What are type aliases and how to create it in Typescript
In Typescript, Type aliases give a type a new name. They are similar to interfaces in that they can be used to name...
Read more >Documentation - Advanced Types - TypeScript
Type aliases create a new name for a type. Type aliases are sometimes similar to interfaces, but can name primitives, unions, tuples, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I strongly agree with @patmagee here, names should indicate what the value of the variable represents and types should only indicate how they can be used. If your naming relies on the type to be understandable, you will have to look up its declaration whenever you encounter it at some other point in your code:
In addition, these custom type names will make it harder for a third party to read you wdl files:
I also wonder how this will interact with structs, this looks like it might create some ambiguity in the syntax.
Just as a note, typing has many benefits without clearifying what a variable represents.
It can speed up run/compile time, as you only need to check whether the type is approriate for a certain operation, not what the type actually is. I image it also simplifies how variables (and the underlying memory management) are handeled by the compiler/interpreter/execution-engine. It also lets other developers know what type should be used as parameter to function calls. This greatly reduces the chance of unexpected behavior and errors resulting from functions getting called with types the author of the function didn't expect. It allows IDEs to check and warn you of these kinds of mistakes and suggest functions that can be used for a given variable.I think the question here is really what does the type alias hope to accomplish that proper naming of the variable would not? IMO if you are using the type to infer meaning of the varibale to the user then you are not naming your variables properly.
Its also worth noting that the way you are naming the
File
varibale (PathToFastq
) gives the impression that theFile
is actually aString
type and not aFile
type. To me the naming pattern you suggest actually makes it harder to read, since I would look for a separate reference to aFile
somewhere else and would not think that thePathToFastq
actually refers to a file