react-monaco-editor icon indicating copy to clipboard operation
react-monaco-editor copied to clipboard

Export full monaco-editor types for typescript

Open miriamso opened this issue 6 years ago • 2 comments

I'm using react-monaco-editor in a React + typescript project

For some implementations I want to give appropriate types of monaco-editor as described in the docs https://microsoft.github.io/monaco-editor/api/index.html But didn't found these types in react-monaco-editor exports

For ex: here in editorDidMount I don't want the any type

const editorDidMount = (editor: any, monaco: any): void => {
   //do something
};
   
//...
 <MonacoEditor
    language={language}
    value={code}
    editorDidMount={editorDidMount}                    
/>

So in order to give the editor its right type I had to add monaco-editor to the package-json and then import from it

//...
import MonacoEditor from 'react-monaco-editor';
import { editor } from 'monaco-editor';
//...
const editorDidMount = (editor: editor.IStandaloneCodeEditor, monaco: any): void => {
   //do something
};

Suggested solution

Enable to import all the types directly from react-monaco-editor without having to import monaco-ediitor and import the types from there

miriamso avatar Oct 22 '20 14:10 miriamso

Happy to review a pull request with the changes and docs.

domoritz avatar Oct 22 '20 15:10 domoritz

@domoritz This is the PR: #315, I'd happy for review thanks!

miriamso avatar Oct 25 '20 16:10 miriamso