Skip to content

Commit

Permalink
Simplify iterators types
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Dec 29, 2020
1 parent ff00f7e commit bc28c89
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions lib/container.d.ts
Expand Up @@ -91,8 +91,9 @@ export default abstract class Container extends Node {
* @param callback Iterator receives each node and index.
* @return Returns `false` if iteration was broke.
*/
each (callback: (node: ChildNode, index: number) => void): void
each (callback: (node: ChildNode, index: number) => false): false
each (
callback: (node: ChildNode, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
Expand All @@ -113,8 +114,9 @@ export default abstract class Container extends Node {
* @param callback Iterator receives each node and index.
* @return Returns `false` if iteration was broke.
*/
walk (callback: (node: ChildNode, index: number) => void): void
walk (callback: (node: ChildNode, index: number) => false): false
walk (
callback: (node: ChildNode, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
Expand Down Expand Up @@ -147,14 +149,11 @@ export default abstract class Container extends Node {
*/
walkDecls (
propFilter: string | RegExp,
callback: (decl: Declaration, index: number) => void
): void
walkDecls (callback: (decl: Declaration, index: number) => void): void
callback: (decl: Declaration, index: number) => false | void
): false | undefined
walkDecls (
propFilter: string | RegExp,
callback: (decl: Declaration, index: number) => false
): false
walkDecls (callback: (decl: Declaration, index: number) => false): false
callback: (decl: Declaration, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
Expand All @@ -180,14 +179,11 @@ export default abstract class Container extends Node {
*/
walkRules (
selectorFilter: string | RegExp,
callback: (atRule: Rule, index: number) => void
): void
walkRules (callback: (atRule: Rule, index: number) => void): void
callback: (atRule: Rule, index: number) => false | void
): false | undefined
walkRules (
selectorFilter: string | RegExp,
callback: (atRule: Rule, index: number) => false
): false
walkRules (callback: (atRule: Rule, index: number) => false): false
callback: (atRule: Rule, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
Expand Down Expand Up @@ -220,14 +216,11 @@ export default abstract class Container extends Node {
*/
walkAtRules (
nameFilter: string | RegExp,
callback: (atRule: AtRule, index: number) => void
): void
walkAtRules (callback: (atRule: AtRule, index: number) => void): void
callback: (atRule: AtRule, index: number) => false | void
): false | undefined
walkAtRules (
nameFilter: string | RegExp,
callback: (atRule: AtRule, index: number) => false
): false
walkAtRules (callback: (atRule: AtRule, index: number) => false): false
callback: (atRule: AtRule, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
Expand All @@ -246,10 +239,12 @@ export default abstract class Container extends Node {
* @return Returns `false` if iteration was broke.
*/

walkComments (callback: (comment: Comment, indexed: number) => void): void
walkComments (
callback: (comment: Comment, indexed: number) => boolean
): boolean
callback: (comment: Comment, indexed: number) => false | void
): false | undefined
walkComments (
callback: (comment: Comment, indexed: number) => false | void
): false | undefined

/**
* Inserts new nodes to the end of the container.
Expand Down

0 comments on commit bc28c89

Please sign in to comment.