Skip to content

Add support for Teal #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Add support for Teal #22

wants to merge 4 commits into from

Conversation

Saturn745
Copy link
Member

Adds support for Teal a typed dialect of Lua. Similar to Typescript but for Lua

Simply make a main.tl or require a Teal based module and LuaLink will automatically compile Teal -> Lua before running it

Example

-- Test Teal features: enums, records, interfaces, type checking

-- Example: Teal interface and enum usage

global enum Color
   "Red"
   "Green"
   "Blue"
end

local interface ColoredShape
   color: Color
   get_color_name: function(self): string
end

local record Box is ColoredShape
   width: number
   height: number
end

function Box:get_color_name(): string
   if self.color == Color.Red then
      return "Red"
   elseif self.color == Color.Green then
      return "Green"
   elseif self.color == Color.Blue then
      return "Blue"
   else
      return "Unknown"
   end
end

local mybox: Box = { color = Color.Green, width = 10, height = 5 }
setmetatable(mybox, { __index = Box })
print("Box color enum:", mybox.color)
print("Box color name:", mybox:get_color_name())
print("Box size:", mybox.width, mybox.height)

local function add(a: number, b: number): number
   return a + b
end

local s = add(1, 2)
print(s)

script:onLoad(function()
   print("Script loaded")
end)

Likely needs more testing, stub files (LuaStubGen and make sure that all of it is checked properly at compile time of script. Likely means the stubs are gonna need to be included or perhaps downloaded if Teal is used?), and documentation written (just basic mention that you can use Teal by making your main file a teal file or require one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant