An import path can only end with a ‘.ts’ extension when ‘allowImportingTsExtensions’ is enabled.ts-plugin(5097)
这个错误消息表明在 TypeScript 项目中,当 allowImportingTsExtensions 未启用时,导入路径不能以 .ts 扩展名结尾。

解决方案

启用 allowImportingTsExtensions

在TypeScript 配置文件(通常是 tsconfig.json)中,可以找到 "compilerOptions" 部分,并添加或确保以下选项存在:

{
  "compilerOptions": {
    "allowImportingTsExtensions": true
  }
}

保存配置后,允许在导入时使用 .ts 扩展名。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐