Getting autocomplete to show stuff from a completely different module and function

  1. What do you want to achieve? Keep it simple and clear!
  • Get the autocomplete to autocomplete an argument as if it was an object returned by a function from a different module.
  1. What is the issue? Include screenshots / videos if possible!
  • Just a question. Will doing arg : typeof(require(module).new() actuallly require the module, call the function and see the outcome? Will this be inefficient and is there a better way to do this? Perhaps by exporting types but I don’t have the patience to do that.

My code:

local debug = {}

function debug.init(ws:typeof(require(script.Parent).create()))
	-- code
end

return debug
1 Like

No, it will not actually require or call the function

You can try this in the command line as well:

local function t() 
    print('was called') 
    return 1 
end 

local a: typeof(t()) --> nothing
3 Likes

i like to think of type annotations as just a guide for the script editor, and because of that no runtime code is actually affected by it
i’d personally go with exporting the type if possible instead (similar to typescript), see luau documentation for details:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.