Skip to content

Conversation

elmerbulthuis
Copy link
Contributor

@elmerbulthuis elmerbulthuis commented Jul 8, 2025

I have been translating a small portion of the code to TypeScript to get a feel of the impact this would have.

First I renamed all .js files I wanted to transform to .ts, then I let some agent (codex) fill in all the missing types for the functions. so far everything was easy and straightforward. Then the work became a bit more difficult and interesting, I walked trought every file to manually transform the rest. The code is transformed with the least amount of effort. Some of the patterns used could (should) be optimized for TypeScript but nothing too difficult.

I feel that this little exercise may already expose some bugs or at least weak spots. There are things like using null when undefined is expected that might cause problems in rare cases, there are are also strings being used when UInt8Arrays are expected that would likely cause more problems. I think TypeScript can provide some real benefit by being more strict about this.

I might introduced some new bugs! Sorry for that, this was just to get a feel of the thing.

Another thing that I notice is that the current setup makes for 4 files (yes, 4!) per module. So we have one .ts file, this is where we should be working in. Then we have a compiles .js and .d.ts file, and then we have a map file, .js.map. We want all of these files, but should they really be in the src folder? Should they really be in the repo? I'd propose a slightly more sophisticated build system to make this more ergonomic. This would then be a task that we do before moving to TypeScript.

So like I mentioned before in #717, I am in favor of moving the codebase to TypeScript, and after my little experiment I am even more into doing that! It will not be without any effort, but the sooner we move, the less code we need to move and the earlier we can reap the benefits of this move.

\o/

@vados-cosmonic
Copy link
Collaborator

Hey Elmer thanks for starting to explore and working on this!

I'm going to discuss it at the bext SIG Guest Languages meeting for Javascript (that's happening soon) -- if you'd like to join in feel free to attend or just catch the recording later!

@elmerbulthuis
Copy link
Contributor Author

O great! I'd love to join!

If I am correct the thing is not scheduled yet right? I'll keep an eye on that link then.

Cu then! :-)

@vados-cosmonic
Copy link
Collaborator

Ah hopefully I'm not too late here but to be clear the next meeting will happen -- in roughly ~2 hours!

@elmerbulthuis
Copy link
Contributor Author

Oo dear! I am at the gym with my son in 2 hours! I guess I'll check out the recording and maybe next time I can join.

Cu soon!

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

Successfully merging this pull request may close these issues.

2 participants