diff --git a/lib/traverse.js b/lib/traverse.js index b6b7d60..74904c4 100644 --- a/lib/traverse.js +++ b/lib/traverse.js @@ -1,9 +1,14 @@ +/** + * @typedef { import('./types.js').EnterFn } EnterFn + * @typedef { import('./types.js').LeaveFn } LeaveFn + */ + /** * Traverse a moddle tree, depth first from top to bottom * and call the passed visitor fn. * * @param {ModdleElement} element - * @param {{ enter?: Function; leave?: Function }} options + * @param {{ enter?: EnterFn; leave?: LeaveFn }} options */ module.exports = function traverse(element, options) { diff --git a/lib/types.d.ts b/lib/types.d.ts new file mode 100644 index 0000000..b39fbf5 --- /dev/null +++ b/lib/types.d.ts @@ -0,0 +1,5 @@ +export type ModdleElement = any; + +export type EnterFn = (element: ModdleElement) => boolean | null; + +export type LeaveFn = (element: ModdleElement) => void; \ No newline at end of file