2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. というエラーの解決方法について

Posted at

はじめに

CI/CDを設定後、GitHubのActionsで

An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled.

というエラーが表示されました。
翻訳すると「allowImportingTsExtensions」が有効になっている場合、インポート パスは「.tsx」拡張子でのみ終わることができます。とのことで、.tsxという記述が原因のようです。

解決方法

allowImportingTsExtensionsについて調べると、tsconfig.jsonに以下の記述をすることで.tsxが使えるようになるようです。

tsconfig.json
"compilerOptions": {
    "allowImportingTsExtensions": true
  }

その他の解決方法として、.tsxを削除することでも解決できました。

main.tsx
import App from './App' // ← .tsxを削除

参考

https://t-yng.jp/post/typescript-tsconfig-options-over-4.5


2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?