Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/r-unic/crystallizer
TypeScript to Crystal compiler. All the beauty and power of TypeScript, with all the speed and portability of Crystal.
https://github.com/r-unic/crystallizer
code-generation codegen compiler crystal transpiler ts typescript
Last synced: 3 months ago
JSON representation
TypeScript to Crystal compiler. All the beauty and power of TypeScript, with all the speed and portability of Crystal.
- Host: GitHub
- URL: https://github.com/r-unic/crystallizer
- Owner: R-unic
- License: mit
- Created: 2023-08-31T09:16:02.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-03-28T23:56:14.000Z (10 months ago)
- Last Synced: 2024-10-04T21:31:58.107Z (4 months ago)
- Topics: code-generation, codegen, compiler, crystal, transpiler, ts, typescript
- Language: TypeScript
- Homepage:
- Size: 41.6 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![build](https://github.com/R-unic/crystallizer/actions/workflows/test.yml/badge.svg)
# Crystallizer
A TypeScript to Crystal compiler. All the beauty and power of TypeScript, with the speed and portability of Crystal.# Example
```ts
// examples/async-await/src/test.tsasync function myAsyncFunction(): Promise {
return "Hello!";
}async function main(): Promise {
myAsyncFunction() // you can also use await here of course
.then(res => console.log(res));
}main();
```
```cr
# examples/async-await/dist/test.crprivate def myAsyncFunction : MiniFuture(String)
async! do
return "Hello!"
end
end
private def main : MiniFuture(Nil)
async! do
myAsyncFunction.then do |res|
puts(res)
end
return
end
end
await main
```# Usage
* All of the below instructions are temporary.
* You must have Crystal and TypeScript installed to be able to actually use it.1. Clone the repository
2. Run `npm i && tsc`
3. Run `npm start ` to compile all TypeScript files inside of `` **OR** `npm start` to compile all TypeScript files inside your current working directory# Todo
- cli:
- watch mode
- codegen:
- ignore advanced type generics (T extends, ternary operator, initializers) because Crystal doesn't support them
- destructuring (this is so much harder than it needs to be, thanks TypeScript devs)
- for..in (is this even necessary?)
- macro the rest of the `console` library (warn, error, info, clear, etc.)
- macro the `??` operator (`a != nil ? a : b`)
- emit comments
- disallow:
- call expressions on arrow functions directly
- type parameters in function types
- polyfills:
- `String` (ðŸ˜)
- `Object`
- `Promise`
- test:
- `StringBuilder` class
- commonly used utility functions
- if statements with `else`/`elsif` branches