Skip to content

StaticOptimizer

StaticOptimizer contains a sequence of AST optimizers which are applied in order.

Expression ids and macro metadata are normalized between passes, and type-checking runs after every pass so the final output is valid and consistent with a parsed and checked expression.

Source position information is best-effort and incomplete, but optimized expressions are suitable for calls to astToString.

new StaticOptimizer(options?): StaticOptimizer

constructor configures the optimizer from a plain option object.

StaticOptimizerOptions = {}

StaticOptimizer

optimize(env, input?): AST

optimize applies the configured optimization passes to a checked AST.

Optimization and recheck failures are reported as thrown errors, matching the other high-level TypeScript environment methods.

Env

AST

AST