From dc5c3fecc170c9c07d84b9cdfcb223afcc5a372c Mon Sep 17 00:00:00 2001 From: sbelzile Date: Thu, 19 Aug 2021 06:54:18 -0400 Subject: [PATCH] feat: adds typescript type definition --- @types/index.d.ts | 21 +++++++++++++++++++++ package.json | 1 + 2 files changed, 22 insertions(+) create mode 100644 @types/index.d.ts diff --git a/@types/index.d.ts b/@types/index.d.ts new file mode 100644 index 0000000..1c217fb --- /dev/null +++ b/@types/index.d.ts @@ -0,0 +1,21 @@ +import type { CSSProperties, FC } from 'react'; +import type { Edge, Node, NetworkEvents, Options, Network } from "vis-network/peer" + +type PartialRecord = Partial> + +export interface VisNetworkReactProps { + data: { + nodes: Node[] + edges: Edge[] + } + style?: CSSProperties + options?: Options + events?: PartialRecord void> + getNetwork?: (network: Network) => void, + getNodes?: (nodes: Node[]) => void, + getEdges?: (nodes: Edge[]) => void, +} + +declare const VisNetworkReact: FC + +export default VisNetworkReact; \ No newline at end of file diff --git a/package.json b/package.json index bb8f0f9..da6d518 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.3.6", "description": "", "main": "./lib/index.js", + "types": "@types/index.d.ts", "scripts": { "link": "cd ./lib && npm link && cd ../example && npm link \"vis-network-react\"", "build": "./node_modules/.bin/babel src --out-file ./lib/index.js",