Skip to content

Simplifying generated variable names and a new uniqueization method #29

@jiwonz

Description

@jiwonz

Similar to roblox-ts, it seems like it would be possible to simplify the generated variable names and make them unique by adding a number to the end if they were used in the input code.

An example from roblox-ts:

import { CollectionService } from "@rbxts/services";

for (const obj of CollectionService.GetTagged("Lava")) {
	if (obj.IsA("BasePart")) {
		let _result = "i take";
		let _result_1 = "uniqueness";
		let _result_2 = "of _result_x from roblox-ts";
		obj.Touched.Connect(part => part.Parent?.FindFirstChildOfClass("Humanoid")?.TakeDamage(100));
	}
}
-- Compiled with roblox-ts v3.0.0
local TS = _G[script]
local CollectionService = TS.import(script, script.Parent, "include", "node_modules", "@rbxts", "services").CollectionService
for _, obj in CollectionService:GetTagged("Lava") do
	if obj:IsA("BasePart") then
		local _result = "i take"
		local _result_1 = "uniqueness"
		local _result_2 = "of _result_x from roblox-ts"
		obj.Touched:Connect(function(part)
			local _result_3 = part.Parent
			if _result_3 ~= nil then
				_result_3 = _result_3:FindFirstChildOfClass("Humanoid")
				if _result_3 ~= nil then
					_result_3 = _result_3:TakeDamage(100)
				end
			end
			return _result_3
		end)
	end
end
return nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions