FiveM is a modification for Grand Theft Auto V enabling you to play multiplayer on customized dedicated servers, powered by Cfx.re.
When you develop a FiveM server, you can create resource . Theses resources can be write in multiple langage Lua , C# and JavaScript . In this article we are going to see how to build a resource using TypeScript
Type :
For typing our code, we will use two packages provided by CFX.re the company behind FiveM
@citizenfx/client
@citizenfx/server
These packages provided types for each native method usable inside client-side or server-side code.
tsconfig.json
{ "compilerOptions" : { "target" : "ES2020" , "module" : "ESNext" , "moduleResolution" : "Bundler" , // Location "outDir" : "./dist" , // Other "types" : [ "@citizenfx/client" , "@types/node" ], "lib" : [ "ES2020" ], "strict" : true , "esModuleInterop" : true , "allowSyntheticDefaultImports" : true , "skipLibCheck" : true }, "include" : [ "src/**/*.ts" ], "exclude" : [ "**/node_modules" , "**/.test.ts" ] }
Enter…