added typings for morphdom (#26059)

* added typings for morphdom

* removed the empty namespace
This commit is contained in:
Alexandro Libertino
2018-05-29 15:47:06 -07:00
committed by Mohamed Hegazy
parent 09bf36d49d
commit 1ed824d9df
4 changed files with 71 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for morphdom 2.3
// Project: https://github.com/patrick-steele-idem/morphdom
// Definitions by: arvitaly <https://github.com/arvitaly>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface MorphDomOptions {
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;
}
declare function morphdom(
fromNode: Node,
toNode: Node | string,
options?: MorphDomOptions,
): void;
export = morphdom;
+20
View File
@@ -0,0 +1,20 @@
import morphdom = require("morphdom");
declare var node1: Node;
declare var node2: Node;
declare var el1: HTMLElement;
declare var el2: HTMLElement;
morphdom(node1, node2);
morphdom(node1, node2, {});
morphdom(node1, node2, {
childrenOnly: true,
getNodeKey: (node) => null,
onBeforeElChildrenUpdated: (el1, el2) => true,
onBeforeElUpdated: (el1, el2) => true,
onBeforeNodeAdded: (node) => node1,
onBeforeNodeDiscarded: (node) => false,
onElUpdated: (el) => null,
onNodeAdded: (node) => node2,
onNodeDiscarded: (node) => null,
});
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"morphdom-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}