Code generation strategies #487
Replies: 7 comments 13 replies
-
If done right, (3) would increase the scope and quality of this library while decreasing the maintenance burden. Ideally, dramatically on both counts. The challenge to this scheme was described in #486 (comment):
With this in mind, I make the following proposal for (3). Assume we have a generator that does
Personally, I quite like the ST facades (I made extensive use of a Node.js facade in typelevel/fs2#2453). I think the most annoying thing about them is that Javascript and therefore Typescript does not distinguish numerical types, so everything becomes a |
Beta Was this translation helpful? Give feedback.
-
Thanks for creating this @armanbilge! An important point from my pov, is that I believe we'll need a way to make ad-hoc customisations. So if we're always regenerating, then we need a way to either instruct the code generation to do the following, or have an additional post-processing step to accommodate the following
|
Beta Was this translation helpful? Give feedback.
-
I'll add a bit to this discussion going forward and as time permits, but one thing that I wanted to mention straight away: The generated code will be volatile in two dimensions. one is the evolution of ( |
Beta Was this translation helpful? Give feedback.
-
Note for future: If this takes off, consider using |
Beta Was this translation helpful? Give feedback.
-
@benhutchison wrote some helpful commentary on auto-generated vs hand-maintained facades in #486 (comment). This comment particularly stuck out to me:
|
Beta Was this translation helpful? Give feedback.
-
I'm new to this part of discussion, and I'm not sure what's the current status. Correct me if I'm wrong, but it seems that all the discussion suggest that the generation being based on .d.ts from typescript? I see that Microsoft has a generator that generates their .d.ts from idl of webref; ghcjs generates their definition using webkitgtk's idl file. So should we also start from the IDL file? |
Beta Was this translation helpful? Give feedback.
-
To succesfully map TS union and literal types, scala 3 is required, is it in consideration @sjrd? |
Beta Was this translation helpful? Give feedback.
-
I see this issue as having a couple parts:
I think discussion should focus around (1) while keeping (2) in mind. Perhaps over-optimistically I believe (2) if not already addressed by (1) is surmountable via type aliases, scalafixes, and other sorceries, or just plain breaking changes, assuming we can find a strategy for (1) that we are happy with.
Furthermore, my assumption is the source material for code generation would be
lib.dom.d.ts
. If there are any comparable alternatives that would be great to know as well.As pointed out in #486 (comment), there is a spectrum of approaches to this:
The remaining issue is what should the generator
lib.dom.d.ts => scala-js-dom
do? To answer this question, it would be very helpful if we can get critical commentary on Scalably Typed's latest generated code. Is it good enough to use, and if not, why, and how can it be improved?Beta Was this translation helpful? Give feedback.
All reactions