VS Code Intellisense not working with es6 imports inside HTML

67 views Asked by At

I can't get VS Code Intellisense to recognize code in an imported module (es6) in .html files.

//module1.js
class A{
  B(){
    console.log("Hello, World")
  }
}
export default A;
<html><body><script type="module">
  import A from "./module1.js"
  let a = new A();
  a.B() 
  //I would expect Intellisense to suggest B() after typing a., but it does not.
</script></body></html>

I'm using VS Code 1.76.1 on MacOS with all extension disabled. I have the same problem if I change module1 to export {A}. I have tried using a jsconfig.json file, but nothing changes.

Notably, VS Code correctly provides suggestions when I import module1.js from another js file:

//test.js
import A from "./module.js"
let a = new A();
a.B()

...which differentiates my question from VSCode Intellisense not fully working with ES6 imports?.

I also am not using ts, which differentiates this from How to get intellisense for external javascript libraries with es5 and Visual Studio Code

I have followed the thread here: https://github.com/microsoft/vscode/issues/26338, but the suggested extension did not work: https://marketplace.visualstudio.com/items?itemName=shuaihu.html-embedded-javascript

0

There are 0 answers