Skip to content

Commit c3c4cc9

Browse files
refactor(types): let transform callbacks return null
1 parent edcf5c8 commit c3c4cc9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎lib/javascript/syntax-printer.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,8 +1883,8 @@ const NODE_CHILD = /^(\?)?([*~+^])?([A-Za-z_]+(?:\.body)?)$/;
18831883
*/
18841884
/** @typedef {CompressorShape} Walker terser's `TreeWalker` or `TreeTransformer`, a plain object `createWalker` makes */
18851885
/** @typedef {(this: Walker, node: Node, descend: () => void) => boolean | void} WalkVisit what a walk hands each node to, a truthy result skipping its children */
1886-
/** @typedef {(this: Walker, node: Node, descend: (node: Node, walker: Walker) => void, inList: boolean | undefined) => Node | Splice | SkipMarker | void} TransformBefore what a transform hands each node to on entering it, what it returns replacing it */
1887-
/** @typedef {(this: Walker, node: Node, inList: boolean | undefined) => Node | Splice | SkipMarker | void} TransformAfter what a transform hands each node to on leaving it, what it returns replacing it */
1886+
/** @typedef {(this: Walker, node: Node, descend: (node: Node, walker: Walker) => void, inList: boolean | undefined) => Node | Splice | SkipMarker | null | void} TransformBefore what a transform hands each node to on entering it, what it returns replacing it */
1887+
/** @typedef {(this: Walker, node: Node, inList: boolean | undefined) => Node | Splice | SkipMarker | null | void} TransformAfter what a transform hands each node to on leaving it, what it returns replacing it */
18881888
/** @typedef {Record<string, never>} SkipMarker `MAP.skip`, which a transform returns to drop a node from its list */
18891889

18901890
/**

‎types.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,12 @@ declare interface Ast {
707707
node: NodeShape,
708708
descend: (node: NodeShape, walker: CompressorShape) => void,
709709
inList?: boolean
710-
) => void | NodeShape | Splice | SkipMarker,
710+
) => null | void | NodeShape | Splice | SkipMarker,
711711
after?: (
712712
this: CompressorShape,
713713
node: NodeShape,
714714
inList?: boolean
715-
) => void | NodeShape | Splice | SkipMarker
715+
) => null | void | NodeShape | Splice | SkipMarker
716716
): CompressorShape;
717717
namesOf(node: NodeShape): (null | NodeShape)[];
718718
wrapOptimizer(

0 commit comments

Comments
 (0)