FASTTypeScript is a recently created project that integrates with Moose and leverages the Tree-Sitter parser to analyze TypeScript source code in Pharo.
FASTTypeScript relies on:
- FAST, to ensure compatibility with Moose.
- Pharo-Tree-Sitter, implemented in Pharo via the FFI protocol to efficiently parse TypeScript source code. It is also used to do incremental parsing.
FASTTypeScript metamodel is defined in a way where nodes align with those generated by Tree-Sitter.
To load FASTTypeScript in Pharo, execute the following in a Moose image:
Metacello new
baseline: 'FASTTypescript';
repository: 'github://moosetechnology/FASTTypescript:main';
load.
In order to use it, please make sure that you have installed on your machine the correposndat library from tree sitter typescript, in order to make sure the parsing succeeds. For more details you can have a look at this blog-post.
To use it in Pharo, you can check below example:
res := FASTTypescriptGenerator new getASTFromString: 'class SimpleClass {
integerProperty = 1;
doubleProperty = 1.2;
booleanProperty= true;
stringProperty = "hello";
}'.
The project is still at the very begining. But at least now it can parse and generate a basic model of FASTTypescript. Still need to:
- Reorder classes
- Add new properties
- Check traits
- Add tests
Your contribution is more than welcome. Happy coding with Typescript :)