-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typescript support (request) #60
Comments
Hi @nicobrinkkemper 👋
interface MarksyCompiler {
tree: ReactNode;
toc: any;
}
interface HeadingProps {
children: any;
id: string;
}
interface NodeProps {
children: any;
}
interface ImgProps {
src: string;
alt: string;
}
interface AnchorProps {
children: any;
href: string;
title?: string;
target?: "_blank" | "_self" | "_parent" | "_top";
}
interface MarksyClientConstructor {
createElement: any;
elements: {
h1(props: HeadingProps): React.ReactNode;
h2(props: HeadingProps): React.ReactNode;
h3(props: HeadingProps): React.ReactNode;
h4(props: HeadingProps): React.ReactNode;
a(props: AnchorProps): React.ReactNode;
img(props: ImgProps): React.ReactNode;
p(props: NodeProps): React.ReactNode;
strong(props: NodeProps): React.ReactNode;
em(props: NodeProps): React.ReactNode;
ol(props: NodeProps): React.ReactNode;
ul(props: NodeProps): React.ReactNode;
br(): React.ReactNode;
hr(): React.ReactNode;
};
components?: Record<string, (props: Record<string, any>) => ReactNode>;
}
declare module "marksy" {
function marksy(
settings: MarksyClientConstructor
): (
markdown: string,
options?: import("@types/marked").MarkedOptions
) => MarksyCompiler;
export default marksy;
} |
I had to write it like this: declare module "marksy" {
import { ReactNode, createElement } from "react";
interface MarksyCompiler {
tree: ReactNode;
toc: any;
}
interface HeadingProps {
children: any;
id: string;
}
interface NodeProps {
children: any;
}
interface ImgProps {
src: string;
alt: string;
}
interface AnchorProps {
children: any;
href: string;
title?: string;
target?: "_blank" | "_self" | "_parent" | "_top";
}
interface CodeProps {
children: any;
language: string;
code: string;
}
interface MarksyClientConstructor {
createElement: typeof createElement;
elements?: Partial<{
h1(props: HeadingProps): React.ReactNode;
h2(props: HeadingProps): React.ReactNode;
h3(props: HeadingProps): React.ReactNode;
h4(props: HeadingProps): React.ReactNode;
a(props: AnchorProps): React.ReactNode;
img(props: ImgProps): React.ReactNode;
p(props: NodeProps): React.ReactNode;
del(props: NodeProps): React.ReactNode;
strong(props: NodeProps): React.ReactNode;
blockquote(props: NodeProps): React.ReactNode;
em(props: NodeProps): React.ReactNode;
ol(props: NodeProps): React.ReactNode;
ul(props: NodeProps): React.ReactNode;
br(): React.ReactNode;
hr(): React.ReactNode;
code(props: CodeProps): React.ReactNode;
codespan(props: NodeProps): React.ReactNode;
}>;
components?: Record<string, (props: Record<string, any>) => ReactNode>;
}
function marksy(
settings: MarksyClientConstructor
): (markdown: string, options?: import("marked").MarkedOptions) => MarksyCompiler;
export default marksy;
}
|
Hello! This is awesome! Could you create a PR for this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As the title suggest. The following is a temporary fix, but not ideal:
The text was updated successfully, but these errors were encountered: