I do not believe that this is supported for simple JavaScript projects, but supported for Typescript projects (and I will talk about a workaround that you can use to enable it for JS projects). I recommend that you open a feature request if you need more efficient support for these kinds of functions.
To enable this in a Typescript project, create a file tsconfig.jsonin the root of your project:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": [
"assets/js/*"
]
}
}
}
paths - , . .
:
import Foo from '~/utils/Foo'
import Foo from 'assets/js/utils/Foo'
Typescript , JS , "allowJs": true tsconfig.json :
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": [
"assets/js/*"
]
},
"allowJs": true
}
}
intellisense JavaScript .
JavaScript , paths . , , '~/utils/Foo'.
, VSCode, , - , .