Closed wangtuyao closed 1 month ago
Hi @wangtuyao which typescript language server backend service do you use? If you use a language server you can use the syntax highlighting in the front-end, but you should not use the standalone worker services for TypeScript that monaco-editor provides. Extra library loading should be handle by the language server in your scenario as far as I can tell.
@kaisalmen Thinks for reply.
If you use a language server you can use the syntax highlighting in the front-end, but you should not use the standalone worker services for TypeScript that monaco-editor provides
Does this mean that once I use typescript-language-server to get syntax highlighting and IntelliSense on brower, I won't be able to use standalone worker services e.g. monaco.languages.typescript.javascriptDefaults.addExtraLib
to add some extra lib in memory?
Does this mean that once I use typescript-language-server to get syntax highlighting and IntelliSense on browser, I won't be able to use standalone worker services
@wangtuyao I don't know. How do they configure that in VSCode? Do they have examples for that?
Btw, have you checked https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/src/ts/wrapperTs.ts This example makes uses of VSCode typescript support and runs it in a worker. Maybe this is can be more helpful for you use case? It does not require to have a backend.
monaco.languages.typescript.javascriptDefaults.addExtraLib
is only used to configure the monaco typescript worker
There are 3 ways to provide typescript intellisense:
monaco.languages.typescript
namespaceYou shouldn't use more than one or you'll have duplicated suggestions
I'm not sure why you may want to call addExtraLib if you use a remote language server, you can install types just as you would do in any project
@CGNonofr @kaisalmen thinks. got it . In our case we should use monaco worker.
Hi,
I am using
monaco-languageclient
to connect to a typescript language server backend service. The workspace path points to a typescript project, and it is successful. IntelliSense is also working properly.However, I am unable to use
monaco.languages.typescript.javascriptDefaults.addExtraLib
to add some extra in-memory created libraries becausemonaco.languages.typescript
is undefined.I noticed in #735 that it requires import
@codingame/monaco-vscode-standalone-typescript-language-features
. After trying that, I found thatmonaco.languages.typescript.javascriptDefaults.addExtraLib
could be successfully called, but another error appeared :My question is:
monaco.languages.typescript.javascriptDefaults.addExtraLib
to add extra libraries in memory, how does Monaco's IntelliSense behave in this case? Does it prioritize the content frommonaco.languages.typescript.javascriptDefaults.addExtraLib
or the language client? If there are conflicting types with the same name, how does IntelliSense handle the suggestions?Thinks.