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.

Getting JSX to work inside Monaco

See original GitHub issue

Hi,

I was wondering the steps necessary to get JSX to compile inside a Monaco editor. I added the React.d.ts file using monaco.languages.typescript.typescriptDefaults.addExtraLib but I still get an compiler error when doing something as simple as this Cannot find name div:

screen shot 2017-02-06 at 5 22 24 pm

I noticed you don’t use monaco.languages.typescript.typescriptDefaults.addExtraLib. How do you get the user’s ever changing TS files into alm in general?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mrjjwrightcommented, Feb 7, 2017

Gotcha, makes sense, thanks!

On Feb 6, 2017, at 5:56 PM, Basarat Ali Syed notifications@github.com wrote:

. I thought the tsc compiler could do that but perhaps I am wrong.

TSC can indeed parse them. You need to set jsx: react flag in the config and make sure the file extension .tsx is captured when adding the file to the compilation context.

Note I am unaware / unskilled in doing language analysis inside monaco. I just uses TypeScript / TypeScript compiler API directly 🌹

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alm-tools/alm/issues/421#issuecomment-277865054, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAQ9wFb7N09F1dVpecYXkiyX7GS2aVqks5rZ8ExgaJpZM4L45Y2.

1reaction
basaratcommented, Feb 7, 2017

. I thought the tsc compiler could do that but perhaps I am wrong.

TSC can indeed parse them. You need to set jsx: react flag in the config and make sure the file extension .tsx is captured when adding the file to the compilation context.

Note I am unaware / unskilled in doing language analysis inside monaco. I just use TypeScript / TypeScript compiler API directly 🌹

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Embed a Monaco Editor in a React App | by Jennifer Fu
The work environment is ready. Embed a Monaco Editor Inside React App. Indeed, it takes one line of code to use the Monaco...
Read more >
@monaco-editor/react - npm
Monaco Editor for React - use the monaco-editor in any React application ... Simple usage; Get value; editor instance; monaco instance ...
Read more >
JSX Support in Microsoft's Monaco editor - Stack Overflow
Hey again, I'm trying to understand your instructions but having trouble on step 3: add JSX definitions as a monaco model. You use...
Read more >
Building a code editor with Monaco - Expo Blog
I work on Snack, an online code editor for React Native apps. In the past, Snack's code ... Monaco provides an API to...
Read more >
How to Build a Code Editor with React that Compiles and ...
This line of code is responsible for actually changing the themes inside a Monaco Editor code window. The defineTheme function gets called with ......
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