Unfortunately, it is not achievable due to the following reasons:
When using Chrome DevTools console, it executes code in the context of the page as you type. For example, when you run Object.keys(formEl.elements)
, it will display that formEl.elements
contains properties like post and userName.
In contrast, Visual Studio Code only displays what it can statically analyze. In this scenario, it identifies formEl as an Element
rather than an HTMLFormElement
because it does not recognize that document.querySelector('.form')
returns a form element. Consequently, the autocomplete suggestions are limited to symbols used elsewhere in your code.
To enable autocomplete functionality, one solution is to utilize TypeScript and explicitly define the type of formEl.