Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: remarkjs/react-markdown
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9a25ef80daeb72b0740e756cb126527fe85f932f
Choose a base ref
...
head repository: remarkjs/react-markdown
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 58806be34af01a90fa538b8ffb16d7a487530486
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Jan 2, 2022

  1. Fix ref in types

    Closes GH-668.
    
    Reviewed-by: Remco Haszing <remcohaszing@gmail.com>
    Reviewed-by: Titus Wormer <tituswormer@gmail.com>
    ChristianMurphy authored Jan 2, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    tberreis Thomas Berreis
    Copy the full SHA
    656a4fa View commit details
  2. 7.1.2

    wooorm committed Jan 2, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    58806be View commit details
Showing with 15 additions and 11 deletions.
  1. +12 −7 lib/ast-to-react.js
  2. +2 −2 lib/complex-types.ts
  3. +1 −1 package.json
  4. +0 −1 test/test.jsx
19 changes: 12 additions & 7 deletions lib/ast-to-react.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,11 @@
* @typedef {import('react').ComponentType<T>} ComponentType<T>
*/

/**
* @template T
* @typedef {import('react').ComponentPropsWithoutRef<T>} ComponentPropsWithoutRef<T>
*/

/**
* @typedef {import('react').ReactNode} ReactNode
* @typedef {import('unist').Position} Position
@@ -49,13 +54,13 @@
*
* To do: is `data-sourcepos` typeable?
*
* @typedef {JSX.IntrinsicElements['code'] & ReactMarkdownProps & {inline?: boolean}} CodeProps
* @typedef {JSX.IntrinsicElements['h1'] & ReactMarkdownProps & {level: number}} HeadingProps
* @typedef {JSX.IntrinsicElements['li'] & ReactMarkdownProps & {checked: boolean|null, index: number, ordered: boolean}} LiProps
* @typedef {JSX.IntrinsicElements['ol'] & ReactMarkdownProps & {depth: number, ordered: true}} OrderedListProps
* @typedef {JSX.IntrinsicElements['table'] & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: boolean}} TableCellProps
* @typedef {JSX.IntrinsicElements['tr'] & ReactMarkdownProps & {isHeader: boolean}} TableRowProps
* @typedef {JSX.IntrinsicElements['ul'] & ReactMarkdownProps & {depth: number, ordered: false}} UnorderedListProps
* @typedef {ComponentPropsWithoutRef<'code'> & ReactMarkdownProps & {inline?: boolean}} CodeProps
* @typedef {ComponentPropsWithoutRef<'h1'> & ReactMarkdownProps & {level: number}} HeadingProps
* @typedef {ComponentPropsWithoutRef<'li'> & ReactMarkdownProps & {checked: boolean|null, index: number, ordered: boolean}} LiProps
* @typedef {ComponentPropsWithoutRef<'ol'> & ReactMarkdownProps & {depth: number, ordered: true}} OrderedListProps
* @typedef {ComponentPropsWithoutRef<'table'> & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: boolean}} TableCellProps
* @typedef {ComponentPropsWithoutRef<'tr'> & ReactMarkdownProps & {isHeader: boolean}} TableRowProps
* @typedef {ComponentPropsWithoutRef<'ul'> & ReactMarkdownProps & {depth: number, ordered: false}} UnorderedListProps
*
* @typedef {ComponentType<CodeProps>} CodeComponent
* @typedef {ComponentType<HeadingProps>} HeadingComponent
4 changes: 2 additions & 2 deletions lib/complex-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {ReactNode, ComponentType} from 'react'
import type {ReactNode, ComponentType, ComponentPropsWithoutRef} from 'react'
import type {Position} from 'unist'
import type {Element} from 'hast'

@@ -24,5 +24,5 @@ export interface ReactMarkdownProps {
export type NormalComponents = {
[TagName in keyof JSX.IntrinsicElements]:
| keyof JSX.IntrinsicElements
| ComponentType<JSX.IntrinsicElements[TagName] & ReactMarkdownProps>
| ComponentType<ComponentPropsWithoutRef<TagName> & ReactMarkdownProps>
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-markdown",
"version": "7.1.1",
"version": "7.1.2",
"description": "React component to render markdown",
"license": "MIT",
"keywords": [
1 change: 0 additions & 1 deletion test/test.jsx
Original file line number Diff line number Diff line change
@@ -1161,7 +1161,6 @@ test('should be able to render components with forwardRef in HOC', () => {
const wrapped = (props) => <a {...props} />

const actual = asHtml(
// @ts-expect-error: something up with types for refs.
<Markdown components={{a: wrapper(wrapped)}}>
[Link](https://example.com/)
</Markdown>