Skip to content

erfanasbari/resource-boilerplate

 
 

Repository files navigation

TypeScript Resource Boilerplate for MTASA

Write and compile TypeScript code to Lua.

A documentation in your IDE. Types safety. Linting.

Features

  • 🔥 TypeScriptToLua
    Provides compilation.

  • 📓 MTASA Lua Types
    Provides types declarations and the documentation for MTASA Functions and classes.

  • MTASA Lua Utils
    Provides code preparation and MTASA specific linting.

  • ✒️ Prettier
    Code formatter

  • ⌛ In the future: ESLint for linting TypeScript Code

Getting started

NodeJS

This boilerplate requires NodeJS to be installed. If you already have NodeJS installed, skip this step.

Installation for Windows.

Installation for Linux:

Debian or Ubuntu

apt install nodejs

Arch or Manjaro

pacman -S nodejs

How to check NodeJS installation

Open console (What?) and execute the command

npm version

Download boilerplate

The boilerplate should be downloaded into the resources folder.

You can use git:

git clone https://github.com/mtasa-typescript/resource-boilerplate.git
git remote remove origin

Or you can download the boilerplate as a .zip archive:

Download as zip

Initialize the project

Go to the project folder and execute command in the console:

npm install --save-dev

Compile the project

Command:

npm run build

Always running the command to build the resource is annoying. Below there are possible solutions to simplify it.

Code Editor Preparation

VSCode

Using documentation

Ctrl+Mouse Hover is the shortcut to show documentation window.

Ctrl+Shift+Space is the shortcut to show function's parameters.

Tasks

Use Ctrl+Shift+B and select npm: build task to compilte the resource.

Trigger on save

Plugin Trigger Task On Save should be installed.

Configuration provided in .vscode/settings.json and will be enabled by default.

WebStorm

Using documentation

Ctrl+Q is the shortcut to show documentation window.

Ctrl+P is the shortcut to highlight function's parameters.

Configuration

NOTE: In the current version configuration should have been loaded by default.

In the top right corner press Edit Configurations. Press Add New Configuration (Plus icon), select npm and select build in Scripts field.

Configuration

Now you can press Shift+F10 to compile your resource.

File watcher

NOTE: In the current version file watcher should have been loaded by default.

Compile can be executed after file saving.

Open Settings -> Tools -> File watchers. Add new file watcher for TypeScript files in project scope. Put npm into the Script field and run build into the Srguments field.

File Watcher

Thus, saving after editing TypeScript files triggers compilation.

About

MTASA TypeScript Resource Boilerplate

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%