overextended/ox_core

Imports, JS/TS support, Lua definitions

thelindat opened this issue · 4 comments

Lua types: https://github.com/overextended/ox_types
TS types: https://www.npmjs.com/package/@overextended/ox_core


Since player and vehicle classes are built around metatables and an export to handle method access, more glue code is required to build for ox_core than you would use for ESX or QB (no closures for easy function refs).

JS and TS support comes secondary to Lua and won't be worked on much until ox_core is closer to a stable state - rewriting to support multiple languages is a bit of a hassle.

C# support is not even a consideration at this point.


I wrote some incomplete JS imports to match the CPlayer behaviour in Lua, but we will ideally publish a node_module instead.

For Lua, some work will need to be done to the settings shared for sumneko-lua and cfxlua support. A separate library with stub functions should be written, rather than relying on in-line LuaDocs that require the entire resource to be loaded into the workspace.

... A separate library with stub functions should be written, rather than relying on in-line LuaDocs that require the entire
resource to be loaded into the workspace.

What do you mean by this exactly? I was going to at some point recommend/do documentation using EmmyLua doc. It seems to work well with the vscode sumneko-lua plugin and is the go-to plugin for Jetbrains users (like myself)

--- [gottfriedleibniz/lua-rapidjson](https://github.com/gottfriedleibniz/lua-rapidjson)
json = {}

-- TODO: annotations

---@return table
--- Returns a metatable with the `array` __jsontype.
function json.array() end

---@param string string
--- Refer to [documentation](https://github.com/gottfriedleibniz/lua-rapidjson#decoding) for additional options.
function json.decode(string, ...) end

---@param string string
---@param options? table {indent=true}
--- Refer to [documentation](https://github.com/gottfriedleibniz/lua-rapidjson#encoding) for additional options.
function json.encode(string, options) end

function json.getoption(...) end

---@param value table
---@return boolean
--- Return true if the provided table has the 'array' __jsontype.
function json.isarray(value) end

---@param value table
---@return boolean
--- Return true if the provided table has the 'object' __jsontype.
function json.isobject(value) end

function json.null() end

---@return table
--- Returns a metatable with the `object` __jsontype.
function json.object() end

function json.setoption(...) end

---@param bool boolean
function json.use_lpeg(bool) end
"Lua.workspace.library": [
  "dir\\library\\json.lua"
]

And then probably support for fivem-lua-lint-action.

TypeScript library and types are implemented at https://www.npmjs.com/package/@overextended/ox_core