Akx*_*kxe 9 import typescript visual-studio-code
如果有可用的路径别名,是否有办法强制 TS 使用路径别名进行导入?(我用的是VSCode)
import { ApiError } from '../../../../libs/shared/src'; // This is imported by default
//import { ApiError } from '@rita/shared'; // I want this
const err: ApiError = { /* ... */ };
Run Code Online (Sandbox Code Playgroud)
Ts 配置提取
import { ApiError } from '../../../../libs/shared/src'; // This is imported by default
//import { ApiError } from '@rita/shared'; // I want this
const err: ApiError = { /* ... */ };
Run Code Online (Sandbox Code Playgroud)
小智 11
我遇到了同样的问题,并在这个 github 问题之后修复了它https://github.com/Microsoft/vscode/issues/59815
Settings在 Visual Studio Code 中,通过键入Ctrl + ,(Windows/Linux) 或(Mac)转到CMD + ,,然后使用搜索设置框搜索 importModuleSpecifier,然后从 TypeScript 部分非相对中进行选择。
我在 VSCode 中遇到过这个问题。问题是我importModuleSpecifier在 settings.json 中设置为相对。将其设置为默认值解决了我的问题。
{
// remove this or set to "shortest"
"typescript.preferences.importModuleSpecifier": "relative"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6496 次 |
| 最近记录: |