doc/unreal/en/dev_environment.md
Once puerts has been successfully installed, it's time to set up a working TypeScript development environment.
Puerts is designed to be used with TypeScript however the virtual machine still executes traditional JavaScript. As such, writing code inside of TypeScript and then compiling it all into JavaScript is highly recommended.
# navigate into the project directory (e.g cd path/to/YourProject)
npm install typescript
TypeScript can then be compiled into JavaScript by executing npx tsc from within your project directory.
In order for TypeScript to function correctly, a tsconfig.json file should be present within the project.
Create and place this file directly inside of your U.E project directory.
// YourProject/tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"experimentalDecorators": true, // Set `true` to use of Decorators (i.e. RPC functions)
"jsx": "react",
"sourceMap": true,
"typeRoots": [
"Typing", // Specify the 'Typing' directory as a root (contains the deceleration files)
"./node_modules/@types"
],
"outDir": "Content/JavaScript" // Directory to output compiled .js files (if using `npx tsc` command)
},
"include": [
"TypeScript/**/*" // Location of scripts. (e.g YourProject/TypeScript)
//...
]
}
Note: "include" specifies the directories your puerts TypeScript files are located. If you wish to store your scripts elsewhere, make sure to update this field accordingly
Type safety is the biggest advantage of TypeScript over JavaScript. In order for it to work, deceleration files must be generated. Open up the editor and press the 'Generate' button to produce essential typing files.
Note: Regenerating the deceleration files should be done proceeding any C++ related changes
Now that puerts is installed and your TypeScript development environment has been set up, it's time to get started!