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

RFC: Glob imports #99

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

ffrostfall
Copy link
Contributor

@deviaze
Copy link

deviaze commented Mar 6, 2025

I think a reasonable choice for the return would a struct-like table with keys being the filenames (sans extension) and values being the return types of the files.

But I don't think a glob require scheme is the right way to go about it; I'd rather have the type system be filesystem-aware so that we can write our own type functions for requiring paths, importing dependencies, and verifying that the user inputted a valid path.

In seal, for example, I have a thread.spawn function that expects the user to provide the path of another luau file relative to the file being required from. I think I could probably type hack that in with typeof and require now since it follows Luau's require semantics, but that's not a very general solution. It also breaks apart if I'm dealing with other filetypes (if i need to handle json configs, etc.) or deviate from require semantics. If I could check if the file exists in the type system, I could provide accurate and dedicated errors for that function without having to write a separate vscode plugin for seal.

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

Successfully merging this pull request may close these issues.

2 participants