{"id":13998645,"url":"https://github.com/zackradisic/tyvm","last_synced_at":"2025-04-08T08:17:43.676Z","repository":{"id":191519202,"uuid":"678931653","full_name":"zackradisic/tyvm","owner":"zackradisic","description":"An experimental bytecode interpreter / type-checker for type-level Typescript","archived":false,"fork":false,"pushed_at":"2024-11-25T04:46:18.000Z","size":33308,"stargazers_count":528,"open_issues_count":1,"forks_count":21,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-01T07:45:57.921Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://tyvm.vercel.app","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zackradisic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-15T18:06:33.000Z","updated_at":"2025-03-25T16:36:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"c586e5b8-20de-412e-afd8-630ba4dde909","html_url":"https://github.com/zackradisic/tyvm","commit_stats":{"total_commits":49,"total_committers":2,"mean_commits":24.5,"dds":"0.10204081632653061","last_synced_commit":"fddcbac7bca153ecefb3dfc02947bc90b222ea69"},"previous_names":["zackradisic/tyvm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackradisic%2Ftyvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackradisic%2Ftyvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackradisic%2Ftyvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackradisic%2Ftyvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zackradisic","download_url":"https://codeload.github.com/zackradisic/tyvm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801176,"owners_count":20998339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-09T19:01:52.838Z","updated_at":"2025-04-08T08:17:43.643Z","avatar_url":"https://github.com/zackradisic.png","language":"Zig","funding_links":[],"categories":["Zig","Experimental/Research Projects"],"sub_categories":[],"readme":"# tyvm\n\nAn experimental bytecode interpreter for type-level Typescript.\n\n## About\n\n`tyvm` is another Typescript type-checker project, but this time with a focus on nailing _type-level_ Typescript first.\n\nThe idea is that type-level Typescript is a very simple, purely functional programming language.\n\nTackling type-level Typescript alone is a lot less complex of a task then trying to reach feature parity with tsc in implementing the entirety of Typescript.\n\nThis would, theoretically, allow `tyvm` to be useful much more quickly. It could start being used as a converter for `Typescript types -\u003e X`, where X is GraphQL, Prisma, JSON Schema, etc.\n\nI'm also just fascinated by this kind of stuff, so it's also a fun side project for me.\n\n## Architectural Overview\n\nThis project is comprised of 2 main parts:\n\n1. Compiler: Written in Rust, takes Typescript type-level source code -\u003e tyvm bytecode\n2. VM: Written in Zig, takes tyvm bytecode and executes it.\n\n### Compiler\n\nThe compiler uses the [oxc project's parser](https://github.com/web-infra-dev/oxc/) to parse Typescript source code into an AST, which is then converted to a specialized intermediate representation (IR).\n\nThe IR makes compilation into bytecode much easier. It also doesn't constrain us to any one particular AST, conceptually, any AST from any of the JS/TS compiler projects (e.g. SWC, Babel, etc.) could be converted to the IR, allowing us to support many different compiler frontends.\n\n### VM\n\nThe VM is a stack based machine that runs the generated bytecode from the compiler.\n\nBecause of the simplicity and immutable nature of type-level Typescript, there many cool performance optimizations we can borrow from FP:\n\n- Structurally shared data structures: [hash array mapped tries](https://en.wikipedia.org/wiki/Hash_array_mapped_trie), [RRB trees](https://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=F16EC1235F2CFF0ED612C3C1ADC87EAF?doi=10.1.1.592.5377\u0026rep=rep1\u0026type=pdf)\n- Static reference count optimizations ([Perceus](https://www.microsoft.com/en-us/research/publication/perceus-garbage-free-reference-counting-with-reuse/))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackradisic%2Ftyvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzackradisic%2Ftyvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackradisic%2Ftyvm/lists"}