Skip to content

Typing continuation: convert imports to use require()#9887

Closed
vaisest wants to merge 26 commits into
PathOfBuildingCommunity:devfrom
vaisest:typing-require
Closed

Typing continuation: convert imports to use require()#9887
vaisest wants to merge 26 commits into
PathOfBuildingCommunity:devfrom
vaisest:typing-require

Conversation

@vaisest

@vaisest vaisest commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Description of the problem being solved:

This solves the remaining problems of #9861, which is that PoB uses LoadModule(), which allows for importing modules in ways that require() doesn't. For example, some modules are imported by passing them varargs containing the destination table and helper functions. require() does not take in other inputs, and does not allow returning multiple values.

This solves that by:

  1. Converting modules to only require a single value, and to use a function return value if necessary
  2. Changes export scripts accordingly
  3. Changes everything to use `require()´

I haven't been able to get a clear answer to what else LoadModule() does differently, but the last part is technically extra. I assume there's reason to prefer require(), because it's a standard Lua function, but just converting LoadModule() to work exactly like it allows for treating it like it is require() in the language server. Either way typing info is retained. If necessary, the last change can be reverted.

Note that due to running all export scripts, the amount of changed files is inflated somewhat.

Steps taken to verify a working solution:

  • Tests pass and nothing crashes

Link to a build that showcases this PR:

Before screenshot:

After screenshot:

vaisest added 26 commits May 19, 2026 21:18
- adding a type hint for new() and newClass()
- adding simple ---@Class x: y type hints for base class variables
Fix minion exports

Fix ModCache generation

Convert LoadModule calls which return multiple values to use require()

Convert LoadModule calls which use ..

Remove useless file extensions

Rest of the owl
@vaisest vaisest marked this pull request as draft June 14, 2026 14:19
@vaisest vaisest closed this Jun 14, 2026
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

Successfully merging this pull request may close these issues.

1 participant