@eryx/luau/printer Module

Luau AST printer.

Two modes, selected by PrintOptions.mode:

Summary

Functions

printer.print(astOrResult: any, options: PrintOptions?)string

API Reference

Functions

printer.print

Prints a parsed AST back to Luau source.

mode = "pretty" (default) formats from AST structure and ignores all token text and trivia. mode = "preserve" reproduces the original source from the CST tokens carried on the AST.

printer.print(astOrResult: any, options: PrintOptions?)string

Parameters

astOrResult: any

A ParseResult or AST node.

options: PrintOptions?

Print options.

Returns

string

Printed Luau source.

Types

AstNode

type AstNode = ast.AstAny
Implements: ast.AstAny

PrintOptions

type PrintOptions = { mode: ("pretty" | "preserve")? }
mode: ("pretty" | "preserve")?