Using Typescript

From RAGE Multiplayer Wiki
Jump to: navigation, search


Information

Typescript is a really great resource for C# users looking for a similar language for writing client-side resources.

Luckily for us there are a few users out there who have created Typescript definitions for the client-side code.

You may obtain them from:

CocaColaBear's Github


Prerequisites


Setup

Open Visual Studio Code

Pressing ctrl + ` will open a terminal.

You can install typescript by running the following command:

npm install -g typescript

To verify that you have installed typescript correctly type:

tsc --version

Adding Typescript Definitions

Clientside

npm install --save-dev github:CocaColaBear/types-ragemp-c#master

or

npm install --save-dev https://github.com/CocaColaBear/types-ragemp-c/tarball/master

Serverside

npm install --save-dev github:CocaColaBear/types-ragemp-s#master

If neither of these happen to be working properly you can try removing -g. That's just a global install function.


You can verify if it's working properly by creating a new Typescript file. .ts

Then begin programming by typing:

mp.game

If working properly you will have auto-fill available.

Workspace Help

When you're working with Typescript you want your workspace to be setup in clientside_resources.

You can do this by going to: File -> Open Folder -> clientside_resources

After you should initialize your typescript directory by doing Ctrl + ` and typing tsc --init.

If done correctly you will have a tsconfig.json


Compiling your Typescript Files

You mainly want to do this through your command prompt. You can open up a prompt in Visual Studio Code by press Ctrl + `.

This will allow you to easily type tsc

If done properly you will see newly compiled JavaScript files available in the same directory as the files you have created.