As benefits we have TypeScript and VSCode with incredible TS support. TS is very popular in web development now and TS support in Defold make it best web game engine for many people who already known TS.
It’s early version with very basic functionally (currenly have only functions for example projects) but it works. A lot to do. Use an example project for basic tests. Do not hesitate to contribute!
Do not need support Lua in full. It use basic Lua functions and construction to trinspile TypeScript. Generated Lua code is very clean and human readable.
Here is TS code.
import { Unit } from "./modules/unit";
let unit: Unit
function init(self: any) {
print("The amazing world of Defold TypeScript")
unit.create();
}
function update(self: any, dt: number) {
unit.update(dt);
}
And here is output:
require("typescript_lualib")
local unit0 = require("modules.unit")
local Unit = unit0.Unit
local unit = nil
function init(self)
print("The amazing world of Defold TypeScript")
unit:create()
end
function update(self,dt)
unit:update(dt)
end
Using TS you get strong type check, typed arguments, classes, inheritance and so on. All reflects to lua basic constructions. TS to Lua work the same way as TS to JS. Very usefulfor big projects support.
Don’t see reasons why this shouldn’t work. I think there was a similar project for Defold but with Haxe - https://github.com/hxdefold/hxdefold. A nice feature would be to provide TS bindings to Defold API (generate it?) so you would get some code assistance while typing.
Additionally I have create simple script that working in watch mode and prepare lua files automatically just when you save any TypeScript file from project. Process is fully automated now. Just 3 steps to repeat until game do not finished.
Very interesting. Does it mean, if you have JS coding expirience, you are very close to JS because of TypeScript, or is it a whole different story? Just in Terms of “feeling home / feeling familiar” with the language. I am very new to LUA, this is why i am asking …
I’m interested in checking out TypeScript in Defold to take advantage of some of its features in a game I’m working on - Are we able to mix Lua and Typescript? (And do you consider it a good move?) For example, if I would like to move some logic from Lua to Typescript and use OOP when designing some more complex objects for which many times I’m struggling with some problems I’m pretty sure I would neutralize (or at least detect more conveniently and faster) with type checking, compile time detections and so on.