Luau type checker, type inference, autocomplete, and config resolution.
Wraps the native Luau analysis engine to provide full type checking,
per-position type inference, module-level type-pack queries,
autocompletion, .luaurc config discovery, and require() path
resolution.
Runs the Luau type checker on a source string.
Returns a CheckResult containing any type errors found. When
options.annotate is true, also returns the source code rewritten
with inferred type annotations attached to every binding and
expression. The result also includes built-in Luau lints under
result.lints.
local result = analysis.check(source, { mode = "strict", annotate = true })
for _, err in result.errors do
print(err.message, err.location.beginline)
end
if result.annotated then
print(result.annotated)
end
Parameters
The Luau source code to type-check.
Returns
Infers the type at a specific position in Luau source code.
Runs the type checker in strict mode (by default) and queries the
inferred type at the given 1-based line and column. Useful for
building LSP hover information or type inspection tools.
Returns nil if no type can be determined at that position (e.g.
whitespace, comments, or if the position is out of range).
local source = "local x = 42\nprint(x)"
local ty = analysis.typeAt(source, 1, 7)
print(ty)
Parameters
Returns
The inferred type as a string, or nil.
Returns the inferred return type pack for a Luau module.
This runs the type checker for the provided source and then returns the
module's exported return pack, i.e. the type-level shape produced by the
module's top-level return statement(s).
By default this returns a human-readable string. Pass
{ detailed = true } to receive a structured type-pack payload.
local source = "return { answer = 42 }"
local moduleType = analysis.typeofModule(source)
print(moduleType)
Parameters
The Luau module source code.
Module type inference options.
Returns
The inferred module return pack as a string, or nil.
Computes autocompletion entries at a cursor position.
Runs type checking and returns contextual completions, including
property names, local bindings, keywords, and types - along with
their inferred types where available. This is the same engine
used by Luau language servers.
local source = 'local t = {foo = 1, bar = "hi"}\nt.'
local result = analysis.autocomplete(source, 2, 3)
for name, entry in result.entries do
print(name, entry.kind, entry.type)
end
Parameters
1-based line number of the cursor.
1-based column number of the cursor.
Returns
Resolve a require() path relative to a source file.
Given the absolute path of a Luau source file and a require string
(relative path like "./foo", "../bar", or alias path like
"@alias/mod"), returns the absolute path to the resolved module
file, or nil if no matching file was found.
Uses the same resolution rules as the type checker:
- Extension search order:
.luau -> .lua -> dir/init.luau -> dir/init.lua
- Alias resolution via
.luaurc files walking up the directory tree.
init.luau files resolve relative requires from the parent directory.
local target = analysis.resolve("C:/project/src/main.luau", "./utils")
print(target)
Parameters
Absolute path of the source file containing the require.
The require string to resolve.
Returns
Absolute path to the resolved file, or nil if not found.
Error message string if resolution failed, otherwise nil.
Returns the active merged Luau config for the current require context.
Lookup follows the same caller-sensitive rules used by require,
luau.resolve, and type-checker file resolution, including VFS/module
context handling and parent-directory config merging.
When folderPath is provided, lookup starts from that folder path
instead of the current caller context.
The returned table includes language mode, lint/type flags, globals,
and resolved alias metadata.
local cfg = analysis.getconfig()
if cfg.found then
print(cfg.languageMode, cfg.configDir)
end
for alias, info in cfg.aliases do
print(alias, info.qualified)
end
Parameters
Optional folder path to start config discovery from.
Returns
Current merged config state.
mode: ("strict" | "nonstrict" | "nocheck")?
Type-checking strictness. "strict" enables full checking, "nonstrict" (default) is lenient, "nocheck" disables checking.
If true, the result includes an annotated field with the source rewritten to include inferred type annotations.
Additional .d.luau-style definition sources to load before type checking.
Absolute path of the source file. Enables require() resolution and .luaurc discovery.
Human-readable error message.
Source location of the error.
category: "TypeError" | "SyntaxError"
Error category: "TypeError" for type errors, "SyntaxError" for parse errors.
Human-readable module path that produced the error, when available.
severity: "error" | "warning"
Lint severity level.
Stable lint code name (e.g. "LocalUnused").
Human-readable lint message.
Source location for the diagnostic.
Lint diagnostics with "error" severity.
Lint diagnostics with "warning" severity.
All lint diagnostics in source order, regardless of severity.
Type errors found during checking. Empty when there are none.
Luau lint diagnostics grouped by severity.
The source rewritten with inferred type annotations. Only present when options.annotate is true.
Human-readable display string for the type.
Internal kind tag (e.g. "primitive", "table", "function").
Internal kind tag for the type pack.
Human-readable type string.
source: "Expression" | "Binding" | "ScopeBinding"
Where the type was found: an expression, a local binding, or a scope binding.
Structured type detail object.
Human-readable type pack string.
source: "Module"
Always "Module" for module type results.
Structured type pack detail object.
Human-readable module path, when available.
mode: ("strict" | "nonstrict" | "nocheck")?
Type-checking strictness. Defaults to "strict" for best inference.
Additional type definition sources to load before inference.
Absolute path of the source file. Enables require() resolution.
If true, return a structured TypeAtResult instead of just a string.
mode: ("strict" | "nonstrict" | "nocheck")?
Type-checking strictness. Defaults to "strict" for best inference.
Additional type definition sources to load before inference.
Absolute path of the source file. Enables require() resolution.
If true, return a structured ModuleTypeResult instead of just a string.
mode: ("strict" | "nonstrict")?
Type-checking strictness. Defaults to "strict" for best results.
Additional type definition sources to load before completion.
Absolute path of the source file. Enables require() resolution.
If true, include a typeDetail field for each typed completion entry.
type AutocompleteEntry = {
kind: "Property"
| "Binding"
| "Keyword"
| "String"
| "Type"
| "Module"
| "GeneratedFunction"
| "RequirePath"
| "Unknown",
type: string?,
typeDetail: AnalysisTypeDetail?,
deprecated: boolean?,
typeCorrect: ("Correct" | "CorrectFunctionResult")?,
insertText: string?,
parens: ("CursorAfter" | "CursorInside")?
}
kind: "Property" | "Binding" | "Keyword" | "String" | "Type" | "Module" | "GeneratedFunction" | "RequirePath" | "Unknown"
What kind of completion this is.
Inferred type of this entry. Absent for keywords and untyped entries.
Structured type metadata. Only present when options.detailed is true.
Whether this entry is marked deprecated.
typeCorrect: ("Correct" | "CorrectFunctionResult")?
Whether the entry's type matches what is expected at the cursor position.
Suggested text to insert. Falls back to the completion name when absent.
parens: ("CursorAfter" | "CursorInside")?
Parentheses hint: "CursorAfter" adds () with cursor after, "CursorInside" adds () with cursor between.
context: "Expression" | "Statement" | "Property" | "Type" | "Keyword" | "String" | "Unknown"
The completion context at the cursor position.
Map of completion name to its entry details.
Absolute filesystem path resolved from the alias target.
Directory of the config file that defined this alias.
Raw alias target string as written in the config file.
Whether any config file was discovered during lookup.
Directory of the innermost config file that applies to the caller.
languageMode: "strict" | "nonstrict" | "nocheck"
Active language mode from the merged config chain.
Bitmask of enabled lint rule codes.
Bitmask of lint rule codes treated as fatal.
Whether lint diagnostics are promoted to errors.
Whether type diagnostics are promoted to errors.
Additional global names declared in the config.
Resolved alias map from alias key to alias metadata.