choojs / choojs/nanomorph

Add TypeScript typings?

Open
#103 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
751
Forks
57
PR merge metrics
No merged PRs in 30d

Description

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

```typescript
// 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.
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.