diff --git a/lib/react-markdown.js b/lib/react-markdown.js index 9291e7f3..f01aa068 100644 --- a/lib/react-markdown.js +++ b/lib/react-markdown.js @@ -141,14 +141,38 @@ ReactMarkdown.propTypes = { PropTypes.oneOfType([ PropTypes.object, PropTypes.func, - PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.object, PropTypes.func])) + PropTypes.arrayOf( + PropTypes.oneOfType([ + PropTypes.bool, + PropTypes.string, + PropTypes.object, + PropTypes.func, + PropTypes.arrayOf( + // prettier-ignore + // type-coverage:ignore-next-line + PropTypes.any + ) + ]) + ) ]) ), rehypePlugins: PropTypes.arrayOf( PropTypes.oneOfType([ PropTypes.object, PropTypes.func, - PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.object, PropTypes.func])) + PropTypes.arrayOf( + PropTypes.oneOfType([ + PropTypes.bool, + PropTypes.string, + PropTypes.object, + PropTypes.func, + PropTypes.arrayOf( + // prettier-ignore + // type-coverage:ignore-next-line + PropTypes.any + ) + ]) + ) ]) ), // Transform options: diff --git a/test/test.jsx b/test/test.jsx index e904b8d1..ac8af80c 100644 --- a/test/test.jsx +++ b/test/test.jsx @@ -1424,4 +1424,50 @@ test('should crash on a plugin replacing `root`', () => { }, /Expected a `root` node/) }) +test('should support remark plugins with array parameter', async () => { + const error = console.error + /** @type {string} */ + let message = '' + + console.error = (/** @type {string} */ d) => { + message = d + } + + const input = 'a' + /** @type {import('unified').Plugin>, Root>} */ + const plugin = () => () => {} + + const actual = asHtml( + + ) + const expected = '

a

' + assert.equal(actual, expected) + + assert.not.match(message, /Warning: Failed/, 'Prop types should be valid') + console.error = error +}) + +test('should support rehype plugins with array parameter', async () => { + const error = console.error + /** @type {string} */ + let message = '' + + console.error = (/** @type {string} */ d) => { + message = d + } + + const input = 'a' + /** @type {import('unified').Plugin>, Root>} */ + const plugin = () => () => {} + + const actual = asHtml( + + ) + const expected = '

a

' + assert.equal(actual, expected) + + assert.not.match(message, /Warning: Failed/, 'Prop types should be valid') + console.error = error +}) + test.run()