You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ如何移除自动导入时的.ts文件扩展名

在IntelliJ中移除自动导入语句的.ts扩展名

TypeScript项目操作步骤

  • 打开IntelliJ设置面板:使用快捷键Ctrl+Alt+S(Windows/Linux)或Cmd+,(Mac)
  • 导航至 Languages & Frameworks > TypeScript
  • 在右侧Imports区域,勾选Use paths relative to tsconfig.json
  • 确保项目根目录的tsconfig.json配置了正确的模块解析规则,示例配置如下:
{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "node",
    "target": "ESNext",
    "resolveJsonModule": true
  }
}

完成设置后,IDE会遵循tsconfig的模块解析逻辑,自动导入时不再添加.ts扩展名。

JavaScript项目操作步骤

  • 打开IntelliJ设置面板:使用快捷键Ctrl+Alt+S(Windows/Linux)或Cmd+,(Mac)
  • 导航至 Languages & Frameworks > JavaScript > Imports
  • 在Generated imports区域,选择Do not add extensions(部分版本选项名称可能为取消勾选「Add file extensions」)

设置生效后,重新触发自动导入操作,生成的语句就会去掉文件扩展名。

内容的提问来源于stack exchange,提问作者CCCC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 16:47:32