在Visual Studio代码中,IDE如何使用app-module-path识别types

我正在使用app-module-path的节点环境中,以便始终可以从基本path写入require。

所以所有的path可以是: const something = require('/api/something')而不必像下面这样退出文件夹结构: const something = require('../../api/something)

没有确切的path,VSCode说,所有types都是任何types的。 这意味着像“去定义”这样的function是行不通的。

有没有办法configurationVSCode来解决这个问题?

经过一些更多的search,我发现这可以通过使用jsconfig.son文件使用以下设置来完成。

 { "compilerOptions": { "target": "ES6", "allowSyntheticDefaultImports": true, "jsx": "react", "module": "commonjs", "baseUrl": ".", "paths": { "*": [ "*", "app/*" ] } }, "include": [ "app/**/*.js" ] }