-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Models with "@" in their name do not resolve as dependencies #2295
Comments
try to add them whithout the /lib/ subdir, so your index.d.ts whill work here: |
also, I think, it should be
|
Hi @zerdos, thanks for your response and suggestions! Unfortunately, they did not work in the playground for me, I still get the same issue. As I've mentioned before, I suspect the issue lies somewhere around the fact that monaco changes the @-character to |
I once had a similar issue. I can't find the original issue but the way to make scope packages to work is to remove
And the full file path should be: |
@ErkoKnoll i believe this might work using |
The problem here is that if you don't add it to your models, you will not be able to peek the definition. So for that, you need to add it to both the extra lib and the model. So after debugging this issue for half a day and trying to come up with a solution, which I didn't, I found out that the problem can basically be tracked down to this method. So it tries to remove the So I basically gave up on this and instead I do not add the |
I am also having this issue. editor.createModel(
source,
'typescript',
this.monaco.Uri.parse(`file:///node_modules/@reduxjs/toolkit/index.d.ts`)
) // this works
import { createSlice } from '%40reduxjs/toolkit';
// this gives an error
import { createSlice } from '@reduxjs/toolkit'; It's a big deal for me because code written in my editor won't be the same as code written in native VSCode. |
A full example that can be pasted in https://microsoft.github.io/monaco-editor/playground.html monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.Latest,
allowNonTsExtensions: true,
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
module: monaco.languages.typescript.ModuleKind.ESNext,
noEmit: true,
esModuleInterop: true,
strict: true,
jsx: monaco.languages.typescript.JsxEmit.React,
reactNamespace: 'React',
allowJs: true,
isolatedModules: true,
})
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
const instance = monaco.editor.create(document.getElementById("container"), {
language: 'typescript',
model: null,
});
monaco.editor.createModel(
'export const foo = {bar: 123};',
'typescript',
this.monaco.Uri.parse(`file:///node_modules/@reduxjs/toolkit/index.d.ts`)
)
const model = monaco.editor.createModel(
`import {foo} from "@reduxjs/toolkit"
console.log(foo.bar);
`,
'typescript',
this.monaco.Uri.parse(`file:///index.ts`)
)
instance.setModel(model) Changing cc @orta |
Any update on this? I also have the same issue |
component: TypeScriptWorker (tsWorker.ts) - Enable 'skipEncoding' flag on Uri.toString invokation on getScriptFileNames() method - Compare 'fileName' argument provided to _getModel() method both with Uri encoded and not
Hi I've worked trying to understand the problem and finally I found out. I've submitted PR #3057 |
Fix issue #2295 - Models with "@" in their name do not resolve as dependencies
The following code examples can be copied into https://microsoft.github.io/monaco-editor/playground.html for verification.
I'm trying to specify dependencies manually via
monaco.editor.createModel()
, which works fine for dependency outside of organizations, but if a package is defined within a organization, i.e. has a name like@org/packagename
and thus contains a @-character, it breaks. To me it looks like this is due to Monaco changing the @-character to%40
.The following code (which does not contain @) works fine:
However, on this code (containing a @) it breaks;
monaco-editor version: 0.21.2
Browser: Chrome
OS: Windows 10
Is this an issue with Monaco or with my approach? Is there a workaround for this problem? Let me know if you need more details.
The text was updated successfully, but these errors were encountered: