题意:“IntelliJ - 如何在自动导入时去掉扩展名?”
问题背景:
When I type something like
“当我输入类似这样的内容时”
const func = myFuncti..;
It will suggest myFunction()
, and I accept that.
“它会建议 myFunction(),我接受了该建议。”
Afterward the import will be like
“随后,导入将会像这样”
import {myFunction} from '../myFunction.ts`;
I want to get rid of the ts, so it becomes
“我想去掉 `.ts`,所以它变成了”
import {myFunction} from '../myFunction`;
How to do it? “该如何做到这一点?”
问题解决:
Turns out it's a problem of tsconfig.json
“结果这是一个 tsconfig.json 的问题。”
After changing allowImportingTsExtensions
to false
, problem solved.
“将 allowImportingTsExtensions 更改为 false 后,问题解决了。”