quantizor / markdown-to-jsx

🏭 The most lightweight, customizable React markdown component.
https://markdown-to-jsx.quantizor.dev/
MIT License
1.96k stars 169 forks source link

type "[key: string]: any" makes extension difficult #592

Open jamesarosen opened 2 months ago

jamesarosen commented 2 months ago

The library declares

declare const Markdown: React.FC<{
    [key: string]: any;
    children: string;
    options?: MarkdownToJSX.Options;
}>;

This makes it hard to wrap the Markdown component because every type becomes an any. For example:

import MarkdownToJsx from 'markdown-to-jsx';

type MyMarkdownProps =
  HTMLProps<HTMLDivElement> &
  Pick<ComponentPropsWithoutRef<typeof MarkdownToJsx>, 'children' | 'options'>

type Children = MyMarkdownProps['children'] // any, not string
type Children = MyMarkdownProps['options'] // any, not Partial<...>