こんな感じのフォルダ構成でmoduleAやmoduleBをimportしたい時
src/ components/ moduleA/index.ts moduleB/index.tsx
これじゃできない
import moduleA from "./components/moduleA"
こうじゃないとimportできない
import moduleB from "./components/moduleA/index"
./components/moduleAでimportしたい場合は、tsconfig.jsonを編集する
{ "compilerOptions": { ... "moduleResolution": "Node" //これを追加 } }
これで解決します
参考
https://qiita.com/murank/items/5f11466474d49498bbd5
https://blog.siromath.com/posts/typescript-import-index-module-resolution/
フロントエンド開発でお困りのことはありませんか?
フロントエンドの開発支援を行っています。
・Reactの開発をお願いしたい
・コーディング作業を依頼したい
・javascriptライブラリを作って欲しい。
上記以外にも何かありましたらお気軽にお問い合わせください。