-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot import modules in src aliased in tsconfig paths compilerOptions #11834
Comments
Also got this issue on my machine. VSCode read |
TS doesn't do any path remapping itself, neither does |
Yep..figure it out already. But is there any way to fix it without eject CRA or switching to Craco? |
I'm actually surprised CRA doesn't let you merge additional Webpack config... FWIW, the first thing I do when making a CRA project is ejecting :P |
@Josh-Cena. thanks for checking out the issue. In the context of CRA it doesn't work as its suppose to. please check out.
|
Looking a few lines up, you see the actual aliases that CRA generates. create-react-app/packages/react-scripts/config/modules.js Lines 65 to 79 in bb64e31
The only alias is |
thanks,I added these changes on tsconfig.json,it worked |
I have added this type of path in tsconfig file and use this relative path to my routes file
it's causing this type of error
|
Describe the bug
Cannot import files aliased in the tsconfig paths. imports sometimes work for some files but often don't. I can't say i know why, but when the break the errors are cascading causing imports with aliased paths to break too and forcing the whole project to revert back to relative path imports
(Write your answer here.)
Did you try recovering your dependencies?
Yes
Which terms did you search for in User Guide?
https://create-react-app.dev/docs/adding-typescript/#troubleshooting
Environment
Environment Info:
current version of create-react-app: 5.0.0
running from /home/craft/.config/yarn/global/node_modules/create-react-app
System:
OS: Linux 5.14 Arch Linux
CPU: (8) x64 Intel(R) Xeon(R) CPU W3530 @ 2.80GHz
Binaries:
Node: 17.3.0 - /tmp/yarn--1640220951632-0.6230549606809872/node
Yarn: 1.22.17 - /tmp/yarn--1640220951632-0.6230549606809872/yarn
npm: 8.3.0 - /usr/bin/npm
Browsers:
Chrome: Not Found
Firefox: 95.0.2
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
"baseUrl" : "."
and"paths" : { "@app/*": ["src/*"] }
options to thecompilerOptions
in tsconfig.jsonimport sub from '@app/sub';
to your App.tsx imports in the src/ directoryExpected behavior
No errors
Actual behavior
Reproducible demo
could not recreate the problem in https://codesandbox.io/s/trusting-morse-bs8tc?file=/src/App.tsx because it seams to work just fine there.
The text was updated successfully, but these errors were encountered: