- Rust 100%
| .idea | chore: stuff before I try to do another rewrite | |
| .vscode | draft: add some transformers | |
| src | draft: add some transformers | |
| .gitignore | ignore: input.luau | |
| Cargo.toml | deps: update | |
| LICENSE.md | chore: add license | |
| ReadME.md | chore(ReadME.md): fix spelling | |
| REWRITE.md | chore: stuff before I try to do another rewrite | |
| rustfmt.toml | chore: add rustfmt.toml | |
rbxts-decompiler
Important
Things like types or etc. can't be supported, as Roblox TS doesn't emit anything that will let us know what the TypeScript type for something is. This probably won't be implemented in Roblox TS anyway, so just remember, you won't get 1:1 results. Also, decompiler (with optimizations enabled) support isn't very good. The reason why is that things like
doloops get inlined by the compiler (even without optimizations),repeat until trueloops get inlined by the compiler (on optimization 1+), etc. We might make a script for fixing problems caused by optimizations later, but for now, if you're using a decompiler (decompiling scripts compiled with optimizations), don't expect it to transform all the supported syntax.
A decompiler for Luau files that are compiled from TypeScript using Roblox TS.
Progress / TODOs
See https://github.com/roblox-ts/roblox-ts/tree/master/src/TSTransformer for all transformers: [Statements]: https://github.com/roblox-ts/roblox-ts/tree/master/src/TSTransformer/nodes/statements [Expressions]: https://github.com/roblox-ts/roblox-ts/tree/master/src/TSTransformer/nodes/expressions
- Enums
- Classes
- Functions
- For Loops
- Numeric For Loops
- partially, code like:
for (let i = 0; i >= 5; i++) { - or
for (let i = 0; i === 5; i++) {won't be transformed
- partially, code like:
- For-Of Loops (should be easy)
- Numeric For Loops
Usage
# cargo 1.82.0 (8f40fc59f 2024年08月21日) or earlier
cargo run -- <file_path>
# or:
cargo run <file_path>
Example
cargo run input.luau
Input:
-- Compiled with roblox-ts v3.0.0
local exampleEnum
do
local _inverse = {}
exampleEnum = setmetatable({}, {
__index = _inverse,
})
exampleEnum.A = 0
_inverse[0] = "A"
exampleEnum.B = 1
_inverse[1] = "B"
exampleEnum.C = 2
_inverse[2] = "C"
exampleEnum.D = 3
_inverse[3] = "D"
exampleEnum.magic = 420
_inverse[420] = "magic"
end
return nil
Output:
enum exampleEnum {
A = 0,
B = 1,
C = 2,
D = 3,
magic = 420
}