Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript typings? #103

Open
JacobEvelyn opened this issue Jun 17, 2018 · 0 comments
Open

Add TypeScript typings? #103

JacobEvelyn opened this issue Jun 17, 2018 · 0 comments

Comments

@JacobEvelyn
Copy link

This seems to work for me, but I'm a TypeScript beginner and am probably doing a lot of things wrong:

// Modified from https://github.com/patrick-steele-idem/morphdom/pull/113/commits/0b6b2e87b5f1b193c40c4c64f25938846ccd4039
declare module "nanomorph" {
  interface NanomorphOptions {
    getNodeKey?: (node: Node) => any;
    onBeforeNodeAdded?: (node: Node) => Node;
    onNodeAdded?: (node: Node) => Node;
    onBeforeElUpdated?: (fromEl: HTMLElement, toEl: HTMLElement) => boolean;
    onElUpdated?: (el: HTMLElement) => void;
    onBeforeNodeDiscarded?: (node: Node) => boolean;
    onNodeDiscarded?: (node: Node) => void;
    onBeforeElChildrenUpdated?: (
      fromEl: HTMLElement,
      toEl: HTMLElement
    ) => boolean;
    childrenOnly?: boolean;
  }

  namespace nanomorph {

  }

  function nanomorph(
    fromNode: Node,
    toNode: Node | string,
    options?: NanomorphOptions
  ): void;

  export default nanomorph; // Added "default" here.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant