Typescript: Property 'inAutolink' does not exist on type 'MarkdownSerializerState'

I am getting this error with typescript when trying to use prosemirror-markdown:

error TS2339: Property 'inAutolink' does not exist on type 'MarkdownSerializerState'.
new MarkdownSerializer({
    text(state, node) {
        state.text(node.text!, true)
        state.text(node.text!, !state.inAutolink) // <--- Here :/

I am using the latest version of prosemirror-markdown.

Thanks in advance for the help!

inAutoLink is private. Why do you need a custom serializer for text nodes?

Thanks for your answer. I don’t need a custom serializer for text nodes indeed, but if I create a new MarkdownSerializer() without adding serializers for text and paragraph, I get the error Token type ``text (or paragraph)`` not supported by Markdown renderer.

What I don’t understand is that the code in my previous message is exactly the same as in the defaultMarkdownSerialize’ (from here), but on my side it is not working.

Should I instead do something like below ?

const mdSerializer = new MarkdownSerializer({
}, {
    bold: {open: "**", close: "**", mixable: true, expelEnclosingWhitespace: true},
    italic: {open: "*", close: "*", mixable: true, expelEnclosingWhitespace: true}

Ah, I see what you mean. You can borrow them from defaultMarkdownSerializer.nodes. You’ll probably want to base your serializer on the functions in there anyway—defining one from scratch seems impractical.

1 Like

Yes that’s right, I’ll do that then. Thanks!