Skip to content

[WIP] ts2clar #1864

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

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft

[WIP] ts2clar #1864

wants to merge 25 commits into from

Conversation

hugoclrd
Copy link
Collaborator

@hugoclrd hugoclrd commented Jun 16, 2025

fix: #1783

Disclaimers

At this stage, I'm primarily looking for architectural feedback. The current process is to:

  • Convert the TS code into an intermediate representation (IR), mostly to get the top-level definitions
  • Transpile this IR in Clarity PSEs
    • There's a sub-step here that handles function bodies
  • Format the PSEs to Clarity code with the Clarity formatters

  • There are still thousands of syntax decisions to take and nitpicking to do; this is not the focus of this particular PR and will be addressed 1 by 1 on separate GitHub issues or discussions
  • This is only one half of the project; the other half is the Clarity standard TS lib definition (available in this repo - private)
    • In TS tooling, the approach is often to let the tooling (such as eslint) handle the type safety, because there are no other TS type implementations than the official JS one (and the recent port in Go). That's the approach of SWC and OXC. They will happily transpile invalid TS code into JS
    • There is currently a similar approach. ts2clar will have some support for basic type-inference at some point, and the error handling for invalid code will need to be greatly improved for v1.

Copy link

codecov bot commented Jun 16, 2025

Codecov Report

Attention: Patch coverage is 93.67254% with 97 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/ts-to-clar/src/parser.rs 94.13% 36 Missing ⚠️
components/ts-to-clar/src/expression_converter.rs 95.39% 26 Missing ⚠️
components/ts-to-clar/src/converter.rs 93.44% 20 Missing ⚠️
components/ts-to-clar/src/bin.rs 0.00% 15 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hugoclrd hugoclrd force-pushed the feat/ts-to-clar branch 3 times, most recently from 7c5257a to 8a6778d Compare June 24, 2025 12:31
@hugoclrd hugoclrd force-pushed the feat/ts-to-clar branch 3 times, most recently from e0c2b73 to 3e8d7ba Compare June 30, 2025 07:48
@hugoclrd hugoclrd mentioned this pull request Jul 1, 2025
@hugoclrd hugoclrd force-pushed the feat/ts-to-clar branch 3 times, most recently from 37df04b to c2c467d Compare July 28, 2025 10:07
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.

Transpiler PoC (v0)
1 participant