Skip to content

Commit a8fddeb

Browse files
authored
Improve type declarations (#67)
* Indicate that a CustomStringCallback can return undefined to indicate that no custom behavior should be applied for that node. * Allow WalkCallback to return false. Otherwise, a callback that may or may not prevent further traversal can't be expressed in TypeScript, since it doesn't allow a function to only return a value some of the time.
1 parent caeda65 commit a8fddeb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ declare namespace postcssValueParser {
8585
* @param node The node to stringify
8686
* @returns The serialized CSS representation of the node
8787
*/
88-
(nodes: Node): string;
88+
(nodes: Node): string | undefined;
8989
}
9090

9191
interface WalkCallback {
@@ -95,7 +95,7 @@ declare namespace postcssValueParser {
9595
* @param nodes The series of parsed nodes
9696
* @returns Returning `false` will prevent traversal of descendant nodes (only applies if `bubble` was set to `true` in the `walk()` call)
9797
*/
98-
(node: Node, index: number, nodes: Node[]): void | false;
98+
(node: Node, index: number, nodes: Node[]): void | boolean;
9999
}
100100

101101
/**

0 commit comments

Comments
 (0)