Microsoft/monaco-editor

[Bug] Duplicated function in intellisense after `addExtraLib`

Open

#3,580 opened on Feb 21, 2023

View on GitHub
 (5 comments) (1 reaction) (0 assignees)JavaScript (1,283 forks)batch import
bughelp wantedopen for PRtypescript

Repository metrics

Stars
 (14,836 stars)
PR merge metrics
 (Avg merge 6h 26m) (15 merged PRs in 30d)

Description

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.35.0#XQAAAAI_AgAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw0ujCMH_KmaUY-oS3CKMkOSajRHzMOh275SgQndWdGyFPATHN_jQG5rOFPT-L8kRd7Az7STn-1YydGSUXwZb8WhGo0LTm9LMOTHHaW-VuaVSEvOtnVqiQcdHtSbJ-MXc4sDBPYRWn9llPd7wkQFMjP-1wIbhnirKgcQ6QYJQWrxfa5BkiuTVNdyljIo8gJsjLpnqDCMW2vX2xR9_7xYNQp_SXP3TiWFimDIX7MBNCCrUtv7Nd9PsGeM7tIg-NcKx52fdfiUJveVPjdykEcohN41wWUrSv8oYLJ8Af0x3ExQXC2m0G-b9UaPGF7dlYR039F7NJ9lOEbgZxN7ctjDPUEqzsRJxEzrYKPxox8liDi33QpT9c_SyopAHM4Fb3JbbAibxH5CF4N0IYWmqkV5veef-yegA-hf7_oC_zRsjSABnU_ySaVgA

Monaco Editor Playground Code

// The Monaco Editor can be easily created, given an
// empty container and an options literal.
// Two members of the literal are "value" and "language".
// The editor takes the full size of its container.

monaco.editor.create(document.getElementById("container"), {
	value: "function hello() {\n\talert('Hello world!');\ntrim()}",
	language: "typescript",
});
monaco.languages.typescript.typescriptDefaults.addExtraLib(
            'function trim(s: string):string;',
            'index.d.ts',
          );

Reproduction Steps

hover over trim function in Preview pane. Tooltip will be shown: 'function trim(s: string): string (+1 overload)' image (+1 overload) is not expected (since I only defined a single trim function).

Similar thing happens if I type trim( to see autocompletion. It shows like there are 2 overloads of trim function, while actually there's only one. image

Actual (Problematic) Behavior

editor behaves like addExtraLib is called twice and shows 2 identical overloads of a function defined in addExtraLib

Expected Behavior

I'd expect a single overload of trim function to exist in autocomplete.

Additional Context

No response

Contributor guide