Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.39k stars 316 forks source link

Typescript support, missing properties on interface RenderingOptions #126

Closed marco-silva0000 closed 4 years ago

marco-silva0000 commented 4 years ago

I'm testing this component in an Angular 4 app, therefore I'm using typescript, even though I'm no typescript master.

While trying some options, specifically:

new EasyMDE({
      renderingConfig: {
        markedOptions: {
          sanitize: true,
        },
    },

But the angular compiler got an error as follows:

renderingConfig: { markedOp...' is not assignable to parameter of type 'Options'.
  Types of property 'renderingConfig' are incompatible.
    Type '{ markedOptions: { sanitize: boolean; }; }' is not assignable to type 'RenderingOptions'.
      Object literal may only specify known properties, and 'markedOptions' does not exist in type 'RenderingOptions'.

and also:

ERROR in /..../node_modules/easymde/types/easymde.d.ts (153,17): Cannot find namespace 'CodeMirror'.
ERROR in /..../node_modules/easymde/types/easymde.d.ts (22,23): Cannot find type definition file for 'codemirror'.

after changing the local files to

    interface RenderingOptions {
        singleLineBreaks?: boolean;
        codeSyntaxHighlighting?: boolean;
        markedOptions?: object;
    }

and also, after removing the codemirror references, there were no more errors and it worked as expected.

Is this something in my compiler, or is the typescript support still not fully fleshed out?

Ionaru commented 4 years ago

I think this is caused by missing typings on this end.