Tried to use Teal on real project, my findings

Hello,

I spent an evening attempting to migrate my current project to use Teal. Currently it uses LuaCheck combined with EmmyLua annotations for type safety. I used an LLM to help convert existing scripts and tried to configure a fully functional development environment for writing, debugging, and deploying. Here are my findings.

  • If you use an external editor, be aware that Teal has a narrow set of tooling options. I was forced to switch from IntelliJ IDEA to Visual Studio Code.

  • I couldn’t attach .tl files as Defold components directly. Instead, for each script, you must create a Proxy script that requires the compiled Teal script and returns its methods. A straightforward implementation (a simple require and return of all methods) is insufficient because adding new methods in the .tl file doesn’t automatically add them to the proxy. A more robust, automated solution is required.

  • Debugging did not work for me. The editor would not stop on breakpoints placed in .tl files.

  • Hot reloading was also broken. Upon editing and triggering a hot reload, a “successfully replaced .luac” message appeared, but no changes were reflected in the running application.

  • Configuring the environment is not straightforward. The documentation lacks many crucial details, which could be a significant barrier for many developers.

  • Visual Studio Code uses the Defold Buddy extension, which has some bugs. It corrupted my tlconfig.lua, downloaded incorrect versions, and the LSP (Language Server Protocol) did not function correctly.

  • The only existing Teal type definitions for Defold are generated by mikatuo/defold-lsp-annotations, and the latest versions (1.10.*) are broken. While Lua ignores these errors, Teal rightfully refuses to compile, forcing you to fix the definition files yourself, which can be problematic for many of us.

  • There is a noticeable compilation delay. Of course, every Teal script and its dependencies must be recompiled before the game can run.

  • I encountered several Editor crashes. I did not save the error messages from the first occurrences, and they did not reappear. Logs likely contain these errors.

After fixing all these issues and achieving a working environment, I realized the workflow was too cumbersome. I gave Teal a second chance with a different approach:

  • I disabled the Teal plugin for the project.

  • Configured manual compilation:

    • Set up incremental recompilation for the entire project using Cyan.

    • Added *.lua to .gitignore.

  • In this setup, .tl files are only the source for generating .lua files, which are then required by the Proxy scripts.

The results of this hybrid approach were:

  • Debugging and hot reloading worked again. Breakpoints in the generated .lua files functioned without issue.

  • Before every run or hot reload, manually recompiling the project with Cyan was mandatory.

  • Teal strips “unnecessary” elements like comments from the source, which is confusing during debugging. The resulting Lua files contain large gaps where this content was removed, which looks strange. This is a minor issue, but not a deal-breaker.

Finally, I ultimately decided to roll back all changes. For me, Teal introduced significant overhead and degraded my development, debugging, and deployment experience.

12 Likes

Thank you for your feedback!

Just checking, did you use the latest extension-teal release? It includes the LSP server that vscode uses, so you can also write Teal in the Defold editor.

Yeah, this is not implemented since it would require a much deeper integration into the pipeline that we currently lack the resources to do.

I created an issue to add support for debugging: Investigate (and implement) debugging support · Issue #10 · defold/extension-teal · GitHub

I think it might be “broken“ in the exact same way for regular lua files. Hot reload does not replace the module when it is required in other places.

Anything in particular you found missing?

We want to generate annotations for LSP servers, both Lua and Teal. So far, it hasn’t been prioritised against other issues that we work on. I created an issue in the teal repo: Add annotations · Issue #11 · defold/extension-teal · GitHub

Yeah, teal has incremental mode, but unfortunately, it’s disabled because there are some issues with how it interacts with our undo system. We have an issue for that: Support incremental code transpilation · Issue #8928 · defold/defold · GitHub

Please share them! (Help → Show Logs)

Huh, hot reload worked then? Can you explain what you mean by working/not working?

Oh, this is promising, actually! It likely means it will be relatively easy to add breakpoint debugging if Teal preserves line number matching.

:saluting_face: Thanks for trying it for real! Our main scripting language remains Lua, and we added Teal for those who reeeeallllly want typed languages. We will continue to improve it, though, as usual, when — is a question of prioritization.

8 Likes

Just checking, did you use the latest extension-teal release? It includes the LSP server that vscode uses, so you can also write Teal in the Defold editor.

Yep, I used latest version, 1.4. Can confirm, Teal at Defold Editor works correctly. Intelij Idea is my personal preference over editor, because editor lacks some refactoring features Idea have and i’m more familiar with Idea behaviour. Not blaming editor here, thats completely fine. Also, Editor absolutely correctly see any changes done by external apps on all object types, so both Idea and Defold Editor perfectly works together.

We want to generate annotations for LSP servers, both Lua and Teal. So far, it hasn’t been prioritised against other issues that we work on. I created an issue in the teal repo: Add annotations · Issue #11 · defold/extension-teal · GitHub

It will be great. At this moment there are no official annotations and several projects exists we can choose from. Thats a bit confusing. Official annotations will help a lot for many of us.

Anything in particular you found missing?

Nothing special. I’m newbie at Defold, so some things may be obvious for more experienced developers, but unclear for someone like me.

  • How to add extension, where this can be configured? Finally found solution at official documentation.
  • Once realised that tl cannot be attached as component, question appears - what is recommended usage pattern? I understand that where are no recommendations at this moment, but that forces us to develop one from scratch - uneasy task for newbies.
  • How to configure external tools for teal? - I understand that this is out of scope, but for anyone who are using external editors this is must have to resolve.

Please share them! (Help → Show Logs)

Pastebin

Huh, hot reload worked then? Can you explain what you mean by working/not working?

I believe hot reload also started to work, but don’t remember exactly. BTW, this happened during my second attempt, with disabled extension-teal and manual compilation to lua files.

3 Likes

Well, in my mind the .tl files should be used exactly like you would use .lua files. You start with a .script component (or .gui_script) and then require your Teal or Lua code and use the functions from the required module in your script file.

It would obviously be great if the script component files could also use Teal, but that is a much larger task.

2 Likes

IMHO, having typings in your .script and .gui_script is mostly a requirement for a project of any decent size. A significant amount of source code lives in those files, and you still want type safety when interacting with your lua modules.

I tried to adopt TL at one point and this was a major blocker for me. The other was LSP integration in the editor but that’s been added recently, which made me interested again. But this remaining issue is kind of a showstopper for me personally.

ts-defold has a fairly decent solution for dealing with this. It just strips the .lua extension if the file extension is .script or .gui_script.

So you have a file named player.script.tl and you end up with a file player.script

1 Like

Added Support Teal in script files · Issue #11251 · defold/defold · GitHub

1 Like

Thank you so much for your writeup @ViktorAseev ! I wanted to try it for my next project but the current limitations are a bit too rough for me at the moment. I mean I can live with most of it but the impossibility of attaching teal in .script/.guiscript files is going to be really cumbersome.

So I subscribed to the related github issues and will postpone my test, thanks again, you saved me several days of tinkering too early :slight_smile:

3 Likes