LLS-Addons icon indicating copy to clipboard operation
LLS-Addons copied to clipboard

Add relative import addon.

Open qeffects opened this issue 11 months ago • 4 comments

What this fixes: Relative requires in lua suffer from losing all emmylua/autogenerated annotations because Lua Language server can't follow through dynamic paths. Example:

local path = (...):gsub(".file", "")
local anotherFile = require(path..".anotherFile")

This allows for your library to work independent of what the external file system looks like, for example your library could be copy pasted in /libraries/* /libs/* /whatever/* and you could import adjacent files regardless. But, anotherFile is now a completely unknown variable and you have to manually annotate it.

This together with https://github.com/Keyslam/LuaImport adds an import("./anotherFile") function that preserves type information from the required file.

qeffects avatar Mar 20 '24 10:03 qeffects