From d01dbee93352addf79467fbef0b462eb18331c32 Mon Sep 17 00:00:00 2001 From: Johan Fagerberg Date: Tue, 21 Jan 2020 22:14:03 +0100 Subject: [PATCH] [rehype-react] Add Fragment option, update which options are optional (#41600) * [rehype-react] Add Fragment option Usually this will be `React.Fragment`, but it accepts any component. * [rehype-react] Update which options are optional Most options have healthy defaults. Only `createElement` is required. * [rehype-react] Update version number * [rehype-react] Update tests to include Fragment option --- types/rehype-react/index.d.ts | 5 +++-- types/rehype-react/rehype-react-tests.tsx | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/rehype-react/index.d.ts b/types/rehype-react/index.d.ts index c9d7220054..da69043894 100644 --- a/types/rehype-react/index.d.ts +++ b/types/rehype-react/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for rehype-react 3.1 +// Type definitions for rehype-react 4.0 // Project: https://github.com/rhysd/rehype-react // Definitions by: Adrian Kremer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,7 +8,8 @@ import * as React from "react"; interface Options { createElement: typeof React.createElement; - components: { + Fragment?: React.ComponentType<{ children?: React.ReactNode }>; + components?: { [tagName: string]: React.ComponentType; }; prefix?: string; diff --git a/types/rehype-react/rehype-react-tests.tsx b/types/rehype-react/rehype-react-tests.tsx index efbf298e72..7e5f39bdea 100644 --- a/types/rehype-react/rehype-react-tests.tsx +++ b/types/rehype-react/rehype-react-tests.tsx @@ -8,6 +8,7 @@ const htmlAst = { const { Compiler: compile } = new RehypeReact({ createElement: React.createElement, + Fragment: React.Fragment, components: { button: () => { return