Example of using monaco editor in typescript code
See original GitHub issueMonaco provides typescript definitions, so it should be able to be used in typescript. Unfortunately, all the examples of using monaco are just in embedded HTML, so it’s tough to get get started, even with a minimal example.
Right now, I’m working off of the following. It doesn’t get any simpler than this, folks:
// src/index.ts
import {
editor
} from 'monaco-editor';
let div = document.createElement('div');
editor.create(div);
I get the following errors in the browser (chrome):
Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/Microsoft/monaco-editor#faq
You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker
To address the first error, I checked out the faq and yes, I am loading the webpage via http://
. No clue about the second, though.
Importing a library should not be this difficult. Has anyone figured out how to do this in Typescript?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Monaco Editor
The Monaco Editor is the code editor that powers VS Code. A good page describing the code editor's features is here. It is...
Read more >How to use the monaco-editor.languages.typescript ...
To help you get started, we've selected a few monaco-editor examples, based on popular ways it is used in public projects. Secure your...
Read more >Create a Custom Web Editor Using TypeScript, React, ...
The Monaco Editor is the code editor that powers VS Code. It's a JavaScript library that offers an API for syntax highlighting, auto-completion,...
Read more >Create a web editor using Monaco editor, React and Node + ...
First let's get the node app setup to integrate the Monaco editor. Folder structure of the app i'm gonna create as below. You...
Read more >Playground Example - TypeScript Versions
With the new Playground, we have a lot more control over the environment in which ... The new Playground is now loosely coupled...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I looked through the javascript examples, but they aren’t very helpful for typescript. Specifically, the type checking totally falls apart when I try to add the loader.
There is a sample in the meantime – https://github.com/microsoft/monaco-editor-samples/tree/master/browser-esm-webpack-typescript