Monaco editor: intellisense for properties in square brackets not working (Typescript, works in VSCode)

Viewed 39

I want to have intellisense for the following code:

const a = {
    asd: '123'
};
a[''] // I want the editor to suggest that there's `asd` property here

It works in VS Code:

enter image description here

But it doesn't work in Monaco:

enter image description here

I tried importing TextMate grammar from VSCode to Monaco using monaco-tm, but it seems to have no influence on intellisense.

P.S. intellisense works for dot-properties, i.e. if I type a., Monaco suggests me to type asd.

1 Answers

To trigger it automatically (without pressing 'Ctrl+Space') when you type quotes, you can use code below:

editor.onKeyUp((e) => {
        if (e.keyCode === monaco.KeyCode.Quote) {
          editor.trigger('', 'editor.action.triggerSuggest', '');
        }
      });

Thanks to the answer here.

Related