Solar2D + TypeScript

Hello everyone.

I’m fairly new to Solar2D and Lua. And I’ve been loving both so far :blue_heart: Coming from a TypeScript background I’m missing type checking which Lua lacks. I did some research to see if I can leverage TypeScript in writing Solar2D games and looks it can be possible.

Found these examples for other Lua frameworks. Let me share with you and then ask my question.

https://github.com/TypeScriptToLua/TypeScriptToLua - TypeScript to Lua transpiler. This converts your TS code to Lua, which is awesome!

https://github.com/hazzard993/love-typescript-definitions - Löve2D TypeScript definitions
https://github.com/hazzard993/love-typescript-template - Löve2D TypeScript Project Template

https://github.com/ts-defold/types - Defold TypeScript definitions
https://github.com/ts-defold/tsd-template - Defold Typescript Project Template

Both Defold and Löve2D has type definitions which make it possible to jump start writing code in those frameworks easily using TypeScript, with good type safety and lets you use some great libraries and tools from JS/TS ecosystem.

So why should not Solar2D benefit from this as well?

If anyone interested and/or has any idea how to generate type definitions from Solar2D source code or from documents or from any other source which can feed the generator (which does not exist right now, but will be developed according to the options), please let me know and please reply this thread.

Btw, I tried Löve2D TypeScript project template, and it works really nice. So, I’m hopeful we can bring TS to Solar2D and we open up new possibilities.

Note: Here is my humble investigation results so far:

  1. Explored https://github.com/coronalabs/corona Solar2D source code, which seems too hard to generate types from. Couldn’t find my way here :sweat_smile:
  2. Explored https://github.com/coronalabs/corona-docs/tree/master/markdown/api API documentation for Solar2D in markdown format, which seems to be easier than the 1st option.
  3. Official API docs - not so different than the 2nd option, in fact more fragile compared to parsing markdown, imho.
1 Like

Does Solar2D companion extension for VS Code have with a dictionary?

some great libraries and tools from JS/TS ecosystem.

I am playing with nanostores that is ported from typescript to lua by Chris Griffing. It is good.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.