Comments (11)
@jonathanhotono Here is an example: https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-javascript-defaults
You can of course fetch the jquery.d.ts through an xhr and then set the contents, etc.
fyi @jrieken
from monaco-editor.
I think i found my Problem!
i have always used
"monaco.languages.typescript.javascriptDefaults.addExtraLib" instead of
"monaco.languages.typescript.typescriptDefaults.addExtraLib"...
It works now, thanks!
from monaco-editor.
@jrieken Should we improve the sample at https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-javascript-defaults with a better description and/or showing how to bring in something more realistic like jquery.d.ts instead of the Facts
class?
from monaco-editor.
I do understand correctly, that adding code to the language Services on the Monaco object will make 'things' from the referenced file available in all instances of the Editor?
If yes, is it possbile to reference differnent code for different editor instances?
Thanks for any suggestions
Joel
from monaco-editor.
If yes, is it possbile to reference differnent code for different editor instances?
No the languages are not scoped per editor instance
from monaco-editor.
Thanks for the confirmation.
And there is also no other possibility to reference external code per editor instance?
from monaco-editor.
Thanks @alexandrudima & @jrieken
monaco.languages.typescript.javascriptDefaults.addExtraLib
Should do fine. When adding this extra lib, is it also capable to read normal javascript file or only typescript reference file? If so this might answer @jiron12 question.
from monaco-editor.
When adding this extra lib, is it also capable to read normal javascript file or only typescript reference file?
You pass anything the TypeScript compiler given its current options accepts. So, with allowJs
you can also get JS files fed into the compiler, however it doesn't really make sense. The extraLib
feature is meant for providing ambient type declarations. Such that you get suggestions for a library that you have, lets say jQuery.d.ts
from monaco-editor.
I also have troubles with addExtraLib...
For testing i tried to put following in the Playground Editor:
monaco.languages.typescript.javascriptDefaults.addExtraLib([
"declare module foo {",
" export class bar {",
' public getDate():string;',
' }',
'}',
].join('\n'), 'foo.d.ts');
var jsCode = [
"import {bar} from 'foo'",
"",
"var b = new bar();",
"var t = b.getDate();"
].join('\n');
monaco.editor.create(document.getElementById("container"), {
value: jsCode,
language: "typescript"
});
All i'll get is an Error Message wich says that "Cannot find Module foo"...
from monaco-editor.
@windischb You declaration is incorrect - you must enclose the module name in quotes like declare mode "foo" { ... }
to make it usable for import {} from "foo"
from monaco-editor.
I have tried to enclose the module name in quotes, but it doesn't work either...
The only way i didn't get those errors is to set language to "javascript".
Can you give me a simple working example, please?
Many thanks!
from monaco-editor.
Related Issues (20)
- [Bug] DiffEditor with glyphMargin: false, still renders glyphMargin when rendered side by side. HOT 1
- [Bug] Monaco does not render markers of the dedicated model after switching to this model. HOT 1
- [Bug] Tab only accept the empty space HOT 3
- how to convert luau.tmLanguage.json to a something setMonarchLanguageProvider will accept
- [Bug] There is always a focus-border around editor when editor background is transparent HOT 1
- [Bug] Support CSS :has() pseudo-class HOT 1
- _foreignProxy from createWebWorker never resolved
- Zonde does not move to the next line if you add a line break on the line before it
- Reopen "Background color does not seems to be working on monaco.editor.defineTheme rules section." HOT 2
- [Bug] "Developer: Inspect Editor Tokens and Scopes" causes error HOT 1
- [Feature Request] Support for package.json conditional exports map, for extra libs typings acquisition HOT 1
- [Bug] d.classList is undefined
- [Bug] typescript type check HOT 1
- [Bug] Wrong cursor position if editor has `transform: scale(0.4);` HOT 1
- [Bug] Update Inlay Hints Provider Example to use `paddingRight` and `paddingLeft`
- [Feature Request] completionItems with insertText having quotes can have extra quotes in the front
- [Bug] paste by ctrl+v not working inside editor after update to 0.46.0 HOT 1
- [Bug] Glyph margin decorations/widgets for deleted lines not rendering in the inline view
- [Bug] createScopedLocalize is undefined HOT 1
- [Bug] Crash / Slowness when JSON Schema is applied
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monaco-editor.