Search code examples
typescriptmonaco-editor

monaco-editor typescript not providing suggestions


In monaco-editor if you try to use a union type as a parameter of a function it does not provide you any suggestions. Doing the same in vscode provides you with the suggestions. Is there something I need to enable in monaco to get the same functionality?

It does provide the correct checking and errors, however the suggestions seem to be missing.

Does anyone have any suggestions? Or is this not supported in monaco-editor?

Examples below:

type Test = {
    choice1: "A" | "B" | "C";
    choice2: "X" | "Y" | "Z";
}

function test<T extends keyof Test>(t: T, s: Test[T]) {

}

test("choice1", "")

vscode:

In VSCode

monaco-editor:

In Monaco

I've also tried with a simple union type and the same Simple in Monaco

type Test2 = "something" | "somethingelse"

function test2(t: Test2) {

}

test2("")

Solution

  • This must be a simple mistake. It works pretty well in my application and in the monaco-editor playground:

    enter image description here