Compiler

Compiler<Tree, Result>: (tree, file) => Result

A compiler handles the compiling of a syntax tree to something else (in most cases, text) (TypeScript type).

It is used in the stringify phase and called with a Node and VFile representation of the document to compile. It should return the textual representation of the given tree (typically string).

Note: unified typically compiles by serializing: most compilers return string (or Uint8Array). Some compilers, such as the one configured with rehype-react, return other values (in this case, a React tree). If you’re using a compiler that doesn’t serialize, expect different result values.

To register custom results in TypeScript, add them to CompileResultMap.

Type Parameters

Type ParameterDefault type
Tree extends ../../node_modules/@types/unist../../node_modules/@types/unist
Result extends CompileResultsCompileResults

Parameters

ParameterType
treeTree
fileVFile

Returns

Result

Defined in

node_modules/unified/lib/index.d.ts:912