syntax-tree/mdast-util-heading-range

Add types

chmac opened this issue · 1 comments

chmac commented

I tried using this in a typescript project and so I spent a little time creating a module definition. In the end I won't use the package, and I'm not sure if my types are accurate or not, but I'll post them here anyway on the off chance they might help somebody else write up types for this package. As always, thanks for all this awesome code, makes markdown much easier to play with!

declare module "mdast-util-heading-range" {
  import { Node, Parent } from "unist";
  interface Heading extends Parent {
    depth: number;
  }

  type TestFunction = (value: string, node: Heading) => boolean;

  export default function (
    tree: Parent,
    options:
      | {
          test: string | RegExp | TestFunction;
          ignoreFinalDefinitions?: boolean;
        }
      | TestFunction,
    onrun: (
      start: Heading,
      nodes: Node[],
      end: Node | null,
      scope: { parent: Parent; start: number; end: number | null }
    ) => Node | Node[]
  ): Node;
}

Going to close this, as I don’t think there’s a need for an issue in every repo, or in some repos: every unified repo w/o types accepts a PR to add them!