question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example of using monaco editor in typescript code

See original GitHub issue

Monaco 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
brentshermanacommented, Jan 29, 2019

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.

0reactions
alexdimacommented, Dec 12, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found