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
luau-analyze should support loading in type definition files through a command line switch #1140
Comments
…tion files Add the ability to load a type definition file before type checking. This is useful in projects that'd like to declare their own types (such as types declared by their game engine's Luau integration code) and linting their scripts using 'luau-analyze'. This is modeled to behave similar to the luau-lsp.types.definitionFiles in the Luau LSP project (https://github.com/JohnnyMorganz/luau-lsp). Usage example: luau-analyze --definitions=engine_types.d.luau some_script.luau Note: doesn't introduce new clang-format delta, but the edited file already deviates from what clang-format produces. for luau-lang#1140
PR for the above: #1139 |
FYI in case you weren't aware, luau-lsp releases a binary that you can use like But still +1 for first class support in the Luau CLI tool. Although I think definitions file syntax is currently not formalised so that may prevent this from being supported until then |
Yeah, I kind of gathered that from various github issues but thought to file a PR anyway as it a) makes forward progress on exposing extremely useful functionality, and b) it doesn't touch the Luau core so it doesn't feel like the risk of breaking anything is high. Thanks for @JohnnyMorganz for |
If we were to add this, it should work through a .luaurc file so that any tool can be aware of the dependency: #418 |
@vegorov-rbx Looks like .luaurc PR got dropped in #418. Would you be willing to accept a PR for that updates my PR to input definitions from .luaurc instead of command line arguments? |
Currently
luau-analyze
does not support loading in a type definition file.Type definitions are supported and work well with f.ex. the luau-lsp VSCode extension. Alas, should a user want to perform the same static type checking at the command line (f.ex to easily integrate this into build scripts), the same seems to be impossible with
luau-analyze
.I propose that
luau-analyze
is extended with a--definitions=<typedef_file>
CLI flag, that will load type definitions into the global scope before type checking.Why are type definition files useful? For example, in a sitation where a game engine integrates Luau, the engine may expose its own functions, types and classes into the Lua global namespace that the game scripts then. Any Luau scripts written against this engine could then be static type checked on the command line with
luau-analyze
to ensure that the engine's types are correctly used in scripts.(Note: I happened to also author a PR that implements the
--definitions
flag but noticed in the contributor guidelines that I should file an issue first. So here's the issue!)The text was updated successfully, but these errors were encountered: