Open Hookyns opened 1 year ago
Can I also join in? Thank you!
@Hookyns, count me in pleaseπ
Looking forward to checking out the new version π₯
Can I use this to generate Teal types from TS ones? (Writing my own generator) I so, please add me to the repo. Otherwise, if you know of any tool I can use for this task please tell me. Thanks!
Can I use this to generate Teal types from TS ones? (Writing my own generator) I so, please add me to the repo. Otherwise, if you know of any tool I can use for this task please tell me. Thanks!
Hello @Papipo, Yes, you can. It generates some kind of database of types. You can select them and do whatever you want with them. You'll have access to modules, types contained in those modules, classes, functions, interfaces, type aliases, methods of classes/objects, properties etc.
I created a demo of such generator for you.
In that demo, there are two folders (two projects), some-ts-project
and tl-generator
; ignore other stuff in the root directory.
In the tl-generator
there is the index.ts
file which is super simple cmd tool. It requires path to typelib
(metadata generated from some TS project; generated by the rttist
- new tool from Alpha version) and path to output directory for generated LUA files (generating files to FS is not implemented in the demo). I use ts-node
to run that script. It's in the root package.json file.
Amazing! Can I get access to the repo? Thanks!
BTW, how does this lib compare to ts-morph? I have been using it but I think the DX is not as pleasant as it could be.
Amazing! Can I get access to the repo? Thanks!
BTW, how does this lib compare to ts-morph? I have been using it but I think the DX is not as pleasant as it could be.
ts-morph is wrapper for TS compiler API. It helps you manipulate the TS source code. With RTTIST you do nothing with the source code, I do that for you; I traverse the TS code, handle different TS versions, find all types, all their properties, methods, decorators etc. and I create one file with metadata about all the types. Then I provide you runtime API you can use to read that metadata file. So you will use RTTIST cli that will generate metadata from a TS project and you can work with it at runtime. It's typical reflection as you may know from eg. C#, Java, Go etc.
With this, you can access metadata about all the types in the project:
const allTypesInWholeProject: Type[] = Metadata.getTypes();
So you can write a node.js script that will read your TS project, you'll receive all the TS metadata and you can just generate LUA files using the node:fs API.
Bit more info in the docs. Still WIP.
I see there is in progress support for vite. In fact my use case is with Vue SFCs: I am writing the UI of a game using them and I want to grab its Props interface to aid in the development of the backend game rules, which will be written in Teal. So right now I am using @vue/compiler-sfc
to extract the scriptSetup
.
I see there is in progress support for vite. In fact my use case is with Vue SFCs: I am writing the UI of a game using them and I want to grab its Props interface to aid in the development of the backend game rules, which will be written in Teal. So right now I am using
@vue/compiler-sfc
to extract thescriptSetup
.
@Papipo Does it have to be "real-time"? I mean, does it have to be generated with the HMR/fast-reload while you develop your Vue app? Or can it be CLI tool that you'll run here and there?
Can you prepare some demo project on StackBlitz? How does your components look like, how the props are defined and what the output should be?
For now I am going with a CLI but honestly I thought about using a watcher at some point. Not sure if I will be coding both the FE at the same time, but it might happen.
For now the approach is to code the FE in Vue, as I can use storybook or in general fake payloads, and only then, transform the entry point Props interface into Teal types to start coding the backend, but we'll see (the project is a year old but only now I've decided to go this route). After all, it's the FE who dictates what props it needs.
I'll try to give you a sample repo but that'll have to wait at least a week because I am on vacation for the rest of the week.
BTW, if you are curious, I plan to use Elixir for the host app, Luerl (an implementation of lua to be run in the BEAM) to run the game engine/rules (lua via teal compiler) and LiveVue to update the Vue props via a websocket (hence the requirement to transform types, for pure sanity). We'll see if it works as intended π
Sign here who wants to participate in the alpha of the new major version. I will invite you to the private project when it is ready. π