Remember to 🌟 this Github if you 💖 it.
Types definitions for RAGE:MP
# With npm
npm i --save-dev github:leonardssh/ragemp-types#types-server
# With yarn
yarn add -D github:leonardssh/ragemp-types#types-server
# With pnpm
pnpm add -D github:leonardssh/ragemp-types#types-server# With npm
npm i --save-dev github:leonardssh/ragemp-types#types-client
# With yarn
yarn add -D github:leonardssh/ragemp-types#types-client
# With pnpm
pnpm add -D github:leonardssh/ragemp-types#types-client# With npm
npm i --save-dev github:leonardssh/ragemp-types#types-cef
# With yarn
yarn add -D github:leonardssh/ragemp-types#types-cef
# With pnpm
pnpm add -D github:leonardssh/ragemp-types#types-cefTo make these types detectable, you need to add the
typesproperty below totsconfig.jsonon each side of your project.
// e.g server-side
{
"compilerOptions": {
"types": ["{RELATIVE_PATH_TO_NODE_MODULES}/@ragemp/types-server"]
}
}To avoid conflicts between server and client types, they must be installed and set as follows:
Step #1: install the types in package.json from the project root
npm i --save-dev github:leonardssh/ragemp-types#types-server
npm i --save-dev github:leonardssh/ragemp-types#types-clientStep #2: for this step, your project should be structured as follows:
├───my-awesome-ragemp-server
│ └───src
│ # Server - Contains code relating to the database, player spawning, etc.
│ # Client - Contains code to display things to the user and do things to them.
│ ├───client
│ │ ├───src
│ │ └───tsconfig.json
│ │
│ ├───server
│ │ ├───src
│ │ └───tsconfig.json
│ └───
├───package.json
└───tsconfig.base.jsonNow that we know what our server structure should look like, let's start setting the types properly.
tsconfig.base.json- this is our base tsconfig, from which we extend the client/server part (to avoid making redundant code)
{ // NOTE: This is my config that I use everywhere, it is optimized for the cleanest and best code.
"exclude": ["node_modules", "dist"],
"compileOnSave": true,
"compilerOptions": {
"skipLibCheck": false,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": ["es6", "esnext", "DOM"],
"rootDir": ".",
"outDir": "dist",
"strict": true,
"removeComments": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowJs": true,
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"alwaysStrict": true,
"importsNotUsedAsValues": "remove",
"incremental": true,
"newLine": "lf",
"noEmitHelpers": true,
"preserveConstEnums": true,
"pretty": true,
"useDefineForClassFields": true,
"baseUrl": "./"
}
}
client/tsconfig.json- this is our tsconfig for the client side, extended from the basic tsconfig and containing the types for the client
{ // NOTE: This tsconfig will work assuming your project is structured as described above.
"extends": "../../tsconfig.base.json",
"compilerOptions": {
// [RELATIVE_PATH_TO_NODE_MODULES]/@ragemp/types-client
"types": ["../../node_modules/@ragemp/types-client"],
},
"include": ["./**/*.ts"],
}server/tsconfig.json- this is our tsconfig for the server side, extended from the basic tsconfig and containing the types for the server
{ // NOTE: This tsconfig will work assuming your project is structured as described above.
"extends": "../../tsconfig.base.json",
"compilerOptions": {
// [RELATIVE_PATH_TO_NODE_MODULES]/@ragemp/types-server
"types": ["../../node_modules/@ragemp/types-server"],
},
"include": ["./**/*.ts"],
}For those who didn't understand, I made a gamemode from which you can better orient yourself: ragemp-typescript
To contribute to this repository, feel free to create a new fork of the repository and submit a pull request.
- Fork / Clone and select the
mainbranch. - Create a new branch in your fork.
- Make your changes.
- Commit your changes, and push them.
- Submit a Pull Request here!
- CocaColaBear - Creator of types-ragemp-s & types-ragemp-c
This project is licensed under the MIT License - see the LICENSE file for details.