Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Test to see why my transformer doesn't work (fixed (downgraded typescript to 4.8.3 (they should use semver)))

License

Notifications You must be signed in to change notification settings

ketrab2004-Roblox/rbxts-transformer-test

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

how to

  • run npm i
  • go into /example
  • also run npm i here
  • run npm run build which will build the transformer, then the example
  • you should see all nodes in the terminal

rbxts-transformer-services

This is a demo transformer that converts @rbxts/services imports into plain GetService calls for increased legibility.

Example

// input.ts
import { Players, ServerScriptService } from "@rbxts/services";

print(Players.LocalPlayer);
print(ServerScriptService.GetChildren().size());
-- output.lua
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
print(Players.LocalPlayer)
print(#ServerScriptService:GetChildren())

Template

This transformer is intended to be used as a template for those who are interested in creating their own transformers in roblox-ts.

A necessary resource for those starting out with transformers is ts-ast-viewer. It shows you the result of AST, relevant properties, symbol information, type information and it automatically generates factory code for nodes. For example, you can see the code this transformer generates here.

I'd also recommend downloading the TypeScript repo locally as it's extremely helpful when you're using undocumented (the majority of the compiler API), internal or uncommon APIs.

Transformers mutate the TypeScript AST by replacing parts of the AST with new nodes. Transformers are also able to utilize symbol and type information giving you access to TypeScript's advanced control flow analysis.

Other Transformers

Here's a list of transformers if you want to see how they handle working with parts of the TypeScript compiler api not shown here (e.g symbols or types).

One other source you may goto for learning about transformers is actually roblox-ts itself. This generates a Luau AST instead of a TS AST but it may still be a useful resource for learning about the compiler api.

About

Test to see why my transformer doesn't work (fixed (downgraded typescript to 4.8.3 (they should use semver)))

Resources

License

Stars

Watchers

Forks

Languages

  • Lua 93.9%
  • TypeScript 6.1%