Skip to content

trivia ​

luau
local trivia = require("@std/syntax/utils/trivia")

WARNING

These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.

Summary ​

EntryDescription
leftmostTriviaReturns the leading trivia of the leftmost token in n, or an empty array if there are no tokens.
rightmostTriviaReturns the trailing trivia of the rightmost token in n, or an empty array if there are no tokens.

Functions and Properties ​

trivia.leftmostTrivia ​

Returns the leading trivia of the leftmost token in n, or an empty array if there are no tokens.

luau
(n: types.CstNode) -> { types.Trivia }

trivia.rightmostTrivia ​

Returns the trailing trivia of the rightmost token in n, or an empty array if there are no tokens.

luau
(n: types.CstNode) -> { types.Trivia }