[Seeking Help] Adding Typescript Support
See original GitHub issueHey All! I’m not a TS expert, yet many people in the community are asking for TS support. That said, I’d love the help from someone who knows TS and common TS toolchains to help us get native TS support in Elder.js.
Hurdles Blocking TS Support
At a high level the main hurdle to implementing TS for Elder.js really comes down to:
The fact that there are several files that read the system expects .js
files in specific places. These files include:
routes.ts
externalHelpers.ts
plugins.ts
rollupPlugin.ts
(look for./server.js
)- I’m sure there are more… (I’ll update this list with edits)
When Should Elder.js Compile TS?
Accepting TS files in the above listed code isn’t a hard problem to solve, there was a partial attempt to get these playing nicely which you can see on this PR (https://github.com/Elderjs/elderjs/pull/170)… the main problem comes down to when we compile TS and run that code.
The way I understand it there are two options:
-
Update the Elder.js
srcDir
to match theoutDir
found in thetsconfig
and update all of the files Elder.js reads looking for.js
and allow it to accept.ts
as well. This would be done ingetConfig
and let the user handle the compilation in their own tool chain. I planned on using this approach in alpha versions of Elder.js. -
Another suggestion from @orta that is on the TS team mentioned that we could just use an esbuild background process to transpile TS on the fly and just run the output as if it was a JS file.
The main reason neither of these have been implemented is that I just don’t understand TS tooling well enough to make a decision because I don’t know the pros/cons of each.
If anyone has strong opinions or would like to offer support, I’m all ears. 👂 👂 👂
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
Top GitHub Comments
@orta should this code say
routes.ts
?Thank you for your hard working! I’m very sorry for spamming, but is there any progress on this? It would be great if we can use Typescript for Elder.js.