Hello,
I've created some TypeScript definitions for LÖVE 2D. They were transpiled from the love-api but I've updated them further to increase type safety and add missing functions.
I created these because I liked the auto-complete, strongly typed checking, error highlighting and document tooltip editor features that the TypeScript plugin for the Sublime text editor provides. Also because the TypeScript you write is self-documenting (using JSDoc) so it'll tell you information about your own code and can find holes in your logic before you even transpile and run your game.
TypescriptToLua is the transpiler which works with these definitions and preserves the logic of TypeScript's code in a Lua form. It also has its methods of transpiling classes and uses interfaces, types and various checking mechanisms that don't show up after transpilation just to make sure your source code is syntactically and functionally correct. It even checks things like if you typed "line" instead of "lines" in the function love.graphics.circle.
You can transpile Typescript to Lua and then run the transpiled code online for LÖVE 2D. So I've made some examples
- LÖVE 2D Hello World, just an example of how to do this in TypeScript
- Classes, Autocomplete, check out Classes and other editor features
- Near Empty Editor for playing around
These only include a few definition examples
You can find the rest of the more in-depth definitions and how to incorporate them in a project here >>love-typescript-definitions<<
TypeScript + LÖVE 2D
-
- Prole
- Posts: 1
- Joined: Sun Oct 28, 2018 7:16 am
TypeScript + LÖVE 2D
Last edited by hazzard993 on Sun Jul 07, 2019 1:34 pm, edited 1 time in total.
Re: Typescript + LÖVE 2D
It's nice. But what I'd actually like to see is a TypeScript transpiler that can actually be bundled within the same Lua container.
Re: Typescript + LÖVE 2D
This is awesome! I think some types really help keeping code organized, and this allows you to use javascript, an awesome (but kind of messed up, yes, I know) language.
EDIT: I played around with it a little and made a simple game. If somebody is interested: https://github.com/yancouto/simple-stuf ... ScriptGame
Pros:
EDIT: I played around with it a little and made a simple game. If somebody is interested: https://github.com/yancouto/simple-stuf ... ScriptGame
Pros:
- Types really help. They enable good autocomplete, which made coding much easier.
- It was easy to configure.
- When you get an error in LOVE, it references your transpiled code, so you have to check it to know where the bug came from. Luckily, the transpiled code is pretty readable.
- typescript-to-lua is kind of incomplete, and has some bugs.
- You have to be aware you're not coding in JS, and I bet some nasty bugs can show up because of tiny differences between typescript and lua.
-
- Prole
- Posts: 22
- Joined: Mon Feb 04, 2019 2:38 pm
- Location: Curitiba, PR, Brazil
Re: TypeScript + LÖVE 2D
I liked it very much!
i was learning about typescript, but i don't found any game engine that pleased me, and so i used it in this game:
https://github.com/Cicolas/BREAKTHELINE
https://cicolas.itch.io/breaktheline
I have a issue about dual arrays, but i think it's because my typescripts knowledgments are poor. Another issue was related with the lovejs, because it doesn't understand the goto (ts-lua transpiler uses goto to replace switch-case).
The typescript-lua works incredible well. Your autocomplete and tooltips are very usefull.
Good Job, i'm really thinking about use it more times.
i was learning about typescript, but i don't found any game engine that pleased me, and so i used it in this game:
https://github.com/Cicolas/BREAKTHELINE
https://cicolas.itch.io/breaktheline
I have a issue about dual arrays, but i think it's because my typescripts knowledgments are poor. Another issue was related with the lovejs, because it doesn't understand the goto (ts-lua transpiler uses goto to replace switch-case).
The typescript-lua works incredible well. Your autocomplete and tooltips are very usefull.
Good Job, i'm really thinking about use it more times.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 1 guest