Merge pull request #34620 from adriankremer/master

[rehype-react] Add initial type definitions
This commit is contained in:
Benjamin Lichtman
2019-04-11 14:28:09 -07:00
committed by GitHub
4 changed files with 67 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for rehype-react 3.1
// Project: https://github.com/rhysd/rehype-react
// Definitions by: Adrian Kremer <https://github.com/adriankremer>
// 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<any>;
};
prefix?: string;
}
declare class RehypeReact {
constructor(options: Options)
Compiler: (node: any) => any;
}
export = RehypeReact;
+18
View File
@@ -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 <button />;
}
}
});
compile(htmlAst);
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"esModuleInterop": true
},
"files": ["index.d.ts", "rehype-react-tests.tsx"]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}