diff --git a/types/rehype-react/index.d.ts b/types/rehype-react/index.d.ts new file mode 100644 index 0000000000..c9d7220054 --- /dev/null +++ b/types/rehype-react/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for rehype-react 3.1 +// Project: https://github.com/rhysd/rehype-react +// Definitions by: Adrian Kremer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from "react"; + +interface Options { + createElement: typeof React.createElement; + components: { + [tagName: string]: React.ComponentType; + }; + prefix?: string; +} + +declare class RehypeReact { + constructor(options: Options) + Compiler: (node: any) => any; +} + +export = RehypeReact; diff --git a/types/rehype-react/rehype-react-tests.tsx b/types/rehype-react/rehype-react-tests.tsx new file mode 100644 index 0000000000..efbf298e72 --- /dev/null +++ b/types/rehype-react/rehype-react-tests.tsx @@ -0,0 +1,18 @@ +import React from "react"; +import RehypeReact from "rehype-react"; + +const htmlAst = { + type: "element", + tagName: "button" +}; + +const { Compiler: compile } = new RehypeReact({ + createElement: React.createElement, + components: { + button: () => { + return