How to get comfortable with typescript for your game.

This thread is a "plus" to the current thread made by @Dr.Yami here but will go more on the "Game Dev Aspect" on the shot when you are not making plugin for anyone else or truly intend to use other people plugin.


So this thread is for show you how you can get "comfortable" for dev  your game coding with Typescript


So for this you would need to get :

  • a IDE who support the add of Typescript as language (by downloading or downloading the package from Sublime text etc) for myself I use Sublime Text 3 
  • JSLint for detect error in your codes (I honestly don't use much this since it's not working wells with sublime text 3)
  • DocBlockR for write fast documentation or comment for your code if you ever doing comment (will be explain later) https://github.com/spadgos/sublime-jsdocs
  • a TsConfig.json for setup your workspace
  • a coding workspace



SO on that I will assume that people know how to create Projects in their respective IDE so I will not explain much on this but in simple now 


for setup our workspace  we need folders then example for my game I placed a folder named "AloneJS" who's my coding workspace where all my code will get.


THEN on that we need to create a folder who will contain our "Final" products or the JS compiled code. for myself I call it "Final" but you can call it like you want like "Output" or "MarsmhallowPowa!" I just do it for organisation sake.

Spoiler
rmPjy3v.png

THEN now we create a ts Files and let's call it "first" you will able to erase it later it's just for init the tsConfig.JSON


so save the TS files then click the button for your IDE to compile the code (CTRL + B ) for Sublime Text


Then they will appear (on sublime) a lines where you can enter you parameter


enter this line 


-init or -i


it's will call a parameter and create a TsConfig.Json for you.


SO NOW let's configure your TsConfig.Json


THEN it's will give you a default setting and you can edit like you want. Just check how works the configuration in the Compiler Options in the main typescript website.


but on that I will show how I do mine : 


{
"compilerOptions": {
"target": "es5", // Important it's permit the system to compile in ES5 and avoid the famous error with property definition
"removeComments": true, // remove your comments in your JS files
"module": "commonjs", // Use the common JS but you can change for nodes etc
"noImplicitAny": false, // avoid the build to throw you error when you use the any word
"sourceMap": false, // I don't even f*cking know what's the use of it lol
"outDir": "C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\Final" // Will set where the files are compiled for me it's "final"
},
"exclude": [
"node_modules" // exclude the nodes modules
],
"files": [ // Files permit to include wich files are compiled AND you can with that get the reference of other code from other files in your current
// files e.g : if you works on Manager and one of the code you are using is in core it's will not throw a error and even give you reference.
"C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\rpg_core.ts",
"C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\rpg_managers.ts",
"C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\rpg_objects.ts",
"C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\rpg_scenes.ts",
"C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\rpg_sprites.ts",
"C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\rpg_windows.ts",
"C:\\Users\\Nio kasgami\\Documents\\Games\\Alone\\AloneJS\\rpg_enigma.ts"

]
}




so on that if we return on the fact off making comment it's because in Typescript you get a meaningful description of methods...here a examples.

Spoiler
jDVHPUj.png



as you can see it's a really nice tools and DocBlockR permit to make nice comment with only phew touch pressing.


on that you can make really easily your code without having to worry.


Yes Typescript seem a little overwhelming in beginning but it's a nice language who make everything's more faster! 


PS : also it's a good idea to enclosing your codes in a Namespace for avoid that the global var get spread in the global space for nothing !


On that I hope you find this useful I just explain my joy to use this awesome language who are fast for game dev  and offers intelligent debugging! 
It seems good, for I really like Typescript.


One thing I still wonder: Where can I find *.d.ts, the Typescript Defination file? If we have it, we can write our code with more pleasure.


RM MV uses ES5, it's good, although I want ES6.
It seems good, for I really like Typescript.


One thing I still wonder: Where can I find *.d.ts, the Typescript Defination file? If we have it, we can write our code with more pleasure.


RM MV uses ES5, it's good, although I want ES6.

A TypeScript definition file should only be necessary for accessing/using JavaScript code in TypeScript. It looks like @nio kasgami is taking the other route, and has converted the RPG Maker MV base code to TypeScript. 

Off-topic, but:
As for ES6, you should already be able to use a number of ES6 features in RPG Maker MV, so long as you're only building for the nwjs embedded build, and take note of what's actually available to you.
 


chromium: "41.0.2272.76"
node: "1.2.0"
node-webkit: "0.12.3"
v8: "3.32.7"


You always have the option of upgrading or packaging using a new version of nwjs, as the recent releases of nwjs should pretty much support over 90% of ES6.
A TypeScript definition file should only be necessary for accessing/using JavaScript code in TypeScript. It looks like @nio kasgami is taking the other route, and has converted the RPG Maker MV base code to TypeScript. 

Off-topic, but:
As for ES6, you should already be able to use a number of ES6 features in RPG Maker MV, so long as you're only building for the nwjs embedded build, and take note of what's actually available to you.
 



chromium: "41.0.2272.76"
node: "1.2.0"
node-webkit: "0.12.3"
v8: "3.32.7"


You always have the option of upgrading or packaging using a new version of nwjs, as the recent releases of nwjs should pretty much support over 90% of ES6.

yes I took the other route and converted the rpg maker MV base code to typescript lol


ALTHOUGH I thinked to make a definitions file for MV files but typescript is kinda REALLY purist and annoying to add another methods to MV 


Although when you overwrite the actual base code it's pretty nifty and is a solid code base.


it's wonderful used along with gulp.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-get-comfortable-with-typescript-for-your-game.62378/