You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({allowNonTsExtensions: true,moduleDetection: 3,// @see https://github.com/microsoft/monaco-editor/issues/2976#issuecomment-2334468503})constmyEditor1=monaco.editor.create(document.getElementById("container1"),{value: `// when this editor has focus, line 2 should be valid and line 3 should show an errorconst a = api.thisShouldWorkInTheTopEditor()const b = api.thisShouldWorkInTheBottomEditor()`,language: "typescript",});myEditor1.onDidFocusEditorWidget(()=>{monaco.languages.typescript.typescriptDefaults.setExtraLibs([{content: ` interface Api { thisShouldWorkInTheTopEditor(): string } declare const api: Api `,filePath: 'globals.d.ts'}])})constmyEditor2=monaco.editor.create(document.getElementById("container2"),{value: `// when this editor has focus, line 2 should show an error and line 3 should be validconst a = api.thisShouldWorkInTheTopEditor()const b = api.thisShouldWorkInTheBottomEditor()`,language: "typescript",});myEditor2.onDidFocusEditorWidget(()=>{monaco.languages.typescript.typescriptDefaults.setExtraLibs([{content: ` interface Api { thisShouldWorkInTheBottomEditor(): string } declare const api: Api `,filePath: 'globals.d.ts'}])})
Reproduction Steps
You see two editors, both show typescript errors
Focus the upper editor, line 2 get valid, line 3 has an error (correct!)
Focus the lower editor, now both lines are correct (error!)
Actual (Problematic) Behavior
setExtraLibs seems to merge the extra libs instead of replacing the existing libs
Expected Behavior
setExtraLibs should correctly replace all the existing libs
Additional Context
the latest version where the behaviour of setExtraLibs is correct is 0.36.1 .
But I can't manage to isolate the modules in 0.36.1 without an export, so downgrading is no option for me
The text was updated successfully, but these errors were encountered:
while there might stil be something wrong with setExtraLibs, I got around this issue by don't using extra libs at all but adding a model that provides the types. The value of the modal can easily be changes. Here is a working playground:
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Link
https://microsoft.github.io/monaco-editor/playground.html?source=v0.51.0#XQAAAAK4BQAAAAAAAABBqQkHQ5NjdQultUhUwcsQIjjaoVayL-wYsMeg24JItvniWevaGyL6ot7GNI6RFj5KIZKnPs8bDABIDSRRqux-oVQT185N0-S9kY8B6TtqQu6-29b1SJjdE3dN-UK1KVtCc43xLj9Jo3QOMz5EH-2xH_NeNavjeq3BMdfl-VDtZ2z4OjBhFRpkU34K6geDzpm9ooZGKEw-1c_GUgYGqEt40F0TiTqOUENu33HWjGIMJoOed9lxM0i_6O2wc5leZUMgfmL5n_viyd8lS-EAz_5V70Qe81d8GDmQ_o6mJXIowRoIlmoe7j9JhyAXd_fvpo5iEjWJ9qMsLL6oLgAiZiEGCydSMzyxrjO_ScgGz1yYlQH-8HiFrosCXcN2p8FUU9tkdYs36UYzHdzIQ0vzvthQaPZg8-qOOJe_RgJyYYYZgyyy2mdncrHPRwWGegmz0o6n2NxsfNI43i7C-Ac3Aqlm_-nQl31MQdrbVTQb9ILdDFiBnIDpQAOu61BDhk8pxnirzVEjBQV4xrOprdpoTaSAq8z_MLAfWXNYZx3NEZq9-ALnVEvh2YanLIN3E3tt89YyIhgPEmh4CjfSs6TPh9LWavKNHV2GKqgIxyxShS2b2tDBcvWRduYVoPob7qD-gAawYRSn9yEd_m9rT69Qz7E2BrKKNva2wbjdb6jbep8W-9fuCdb3EZdGaskKppTIBNZ6l-b9OmTXADGUjrMyocd5kPPKB2RNN1ftYNOD8Hc__-R0qcc
Monaco Editor Playground Code
Reproduction Steps
Actual (Problematic) Behavior
setExtraLibs
seems to merge the extra libs instead of replacing the existing libsExpected Behavior
setExtraLibs
should correctly replace all the existing libsAdditional Context
the latest version where the behaviour of
setExtraLibs
is correct is 0.36.1 .But I can't manage to isolate the modules in 0.36.1 without an
export
, so downgrading is no option for meThe text was updated successfully, but these errors were encountered: