What is the 'export' global?

I’ve found that if you type export in a script it prompts an auto-complete. And when you have it typed it is even in syntax.
image

I found out about this when I saw this person’s code snippet.

image

Additionally, when you’ve got it typed out, the Script Analysis tab reads it as an ‘unrecognized global’.

image

Furthermore it does not come up anywhere in the Lua Globals API documentation or the Roblox Globals API documentation.

What is it? What does it do? Why is it there?
Thanks!

3 Likes

It’s a type checking keyword that can be used to export types from a module to another script.

local module = {}
export type coolModuleType = { cool: boolean? }

return module
local module = require(path.to.module)
local t: module.coolModuleType = { cool = true } -- ok

For backwards compatibility reasons (like the continue keyword), variables can be named “export” and can be assigned “export” (but by default it’s nil)

local export = true -- ok

local var = export -- ok
3 Likes

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