How return type from module ignoring table

Hi everyone, I have a very specific situation. I need to somehow return from module script the type so I don’t have to use the table access method. I think this is technically impossible.

for example what i need:

-- basic "table" type

export type someType = {
   --some type data
}

return nil

and using is

local module = require("path.to.module")

local function some_function(): module.someType end-- <- sometimers looks very dirty in buisness logic. This is what I want to fix

and I need something like (this code doesn’t work if anything)

-- like, idk
return type {
    -- type data
}

and required using is:

local module = require("path.to.module")

 local function some_function():  someType end

I know about the base local type like

type someType = module.someType

but I need to do it somehow WITHOUT this

This is impossible :sob:

This isn’t possible, you need to use module.someType or by using type someType = module.someType. I don’t see why you can’t use this solution.

I don’t want to do this, because the API of my new library, which I’m about to release, uses such types, and creating new ones for those who (probably) will use my library will be inconvenient,

Imo I prefer module.someType, because it’s the usual way to get the types of a specific module/library, it makes it clear that the type is from that module, and provides autocomplete when writing said types

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