TypeScript + LÖVE 2D
Posted: Fri Nov 09, 2018 3:25 am
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<<
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<<