简体   繁体   中英

Can I configure something in VSCode to get javascript intellisense for a js file that imports from an importmap?

I have this ken.html

<script type="importmap">
        {
            "imports": {
                "three": "../../../node_modules/three/build/three.module.js",
                "manimjs": "../../build/manimjs.js"
            }
        }
    </script>

I have this ken.js file:

import * as MANIMJS from 'manimjs';  // intellisense does not work
//import * as MANIMJS from "../../build/manimjs.js"; // intellisense works good

I have tried various settings in jsconfig.json but none work. I get no intellisense for objects in MANIMJS unless I toggle the commented lines. Is there some way to let VSCode understand that 'manimjs' (from html importmap) is the same file as "../../build/manimjs.js"?

You can create a jsconfig.json file and define the following settings

{
    "compilerOptions": {
        "baseUrl": "./",
        "paths": {
            "*": ["../../build/*.js"]
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM