Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with local functions #6

Open
KlutzyBubbles opened this issue Jan 13, 2024 · 3 comments
Open

Issues with local functions #6

KlutzyBubbles opened this issue Jan 13, 2024 · 3 comments

Comments

@KlutzyBubbles
Copy link
Contributor

Tried from the readme and it produces

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]

local ____modules = {}
local ____moduleCache = {}
local ____originalRequire = require
local function require(file, ...)
    if ____moduleCache[file] then
        return ____moduleCache[file].value
    end
    if ____modules[file] then
        local module = ____modules[file]
        ____moduleCache[file] = { value = (select("#", ...) > 0) and module(...) or module(file) }
        return ____moduleCache[file].value
    else
        if ____originalRequire then
            return ____originalRequire(file)
        else
            error("module '" .. file .. "' not found")
        end
    end
end
____modules = {
["src.index"] = function(...) 
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local function onLoad(saveData)
    print("test")
end
return ____exports
 end,
}
return require("src.index", ...)

When run in game it does nothing unless the local in front of the onLoad function is removed.

Curious to whether you ran into this issue or if there are any solutions, currently i have just modified TypeScriptToLua to output all functions without local however i dont think this would be a viable option long term.

@stevenlafl
Copy link
Owner

When run in game it does nothing unless the local in front of the onLoad function is removed.

Ahh, that in particular seems like a bug. These type definitions were painstakingly manually written, so it is likely that is just a mistake.

I'll take a look at your PR in a few.

@Venusta
Copy link

Venusta commented Jul 3, 2024

Any update on this? I have the same issue.

@KlutzyBubbles
Copy link
Contributor Author

Any update on this? I have the same issue.

The local is a side effect from typescript-to-lua see https://github.com/KlutzyBubbles/tts-typescript-template?tab=readme-ov-file#global-functions for a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants