[Bug] Suggestions of declared modules (via addExtraLib) are not showing up in suggestion window #3810
Replies: 3 comments
-
Any news on this one? Or did I miss to provide some more information? Or how could I help? ;) |
Beta Was this translation helpful? Give feedback.
-
I've looked a bit deeper into this. Imagine the following setup within vscode:
with class Chuck {
greet() {
const x: MyInte
return "";
}
} and declare module 'Module' {
export interface MyInterface { }
export const fooBar: () => void
} While typing the import suggestion of
So this will work perfectly fine in vscode. Then I tried to replicate the same behavior in the monaco editor: // validation settings
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false,
});
monaco.languages.typescript.typescriptDefaults.setModeConfiguration({
definitions: true,
completionItems: true,
documentSymbols: true,
codeActions: true,
diagnostics: true,
onTypeFormattingEdits: true,
});
// compiler options
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
...monaco.languages.typescript.typescriptDefaults.getCompilerOptions(),
target: monaco.languages.typescript.ScriptTarget.ES2016,
module: monaco.languages.typescript.ModuleKind.CommonJS,
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
typeRoots: ["types"],
rootDir: "./src"
});
// extra libraries
var libSource = [
"declare module 'Module' {",
' export interface MyInterface {}',
' export const fooBar:() => void',
'}'
].join('\n');
// won't work either!
// var libSource = [
// 'export interface MyInterface {}',
// 'export const fooBar:() => void',
// ].join('\n');
var libUri = 'file:///types/facts.d.ts';
monaco.languages.typescript.typescriptDefaults.addExtraLib(libSource, libUri);
var tsCode = [
'class Chuck {',
' greet() {',
' const x: MyInter',
' return "";',
' }',
'}'
].join('\n');
var indexUri = 'file:///src/index.ts';
const model = monaco.editor.createModel(tsCode, 'typescript', monaco.Uri.parse(indexUri));
const editor = monaco.editor.create(document.getElementById('container'), {
language: 'typescript',
model,
}); This however won't work. I took some time debugging this and found out that, while Interestingly enough, auto-importing works if I fully type out the name in the monaco editor, but not if I only partially type it :( |
Beta Was this translation helpful? Give feedback.
-
It should be because of this #2582 |
Beta Was this translation helpful? Give feedback.
-
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Code
Actual Behavior
I am declaring a module
addExtraLib()
If I have fully typed the interface name, monaco-editor provides me a "Quick fix" to import the interface from "Module" (same for the
fooBar
const)But if I only type
const x:My
, the interface will not show up in the suggestion windowIf I change the extraLib, by removing the module declaration and declaring the interface/const directly (commented in the example) it will show up.
Expected Behavior
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions