Last active
March 11, 2019 08:47
-
-
Save ydhao/5785affd741c9695dcb6ec3d48bb65d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
一、为Create-react-app项目配置支持绝对路径引入模块 | |
Messing around I just found one setting that works without craco for the absolute paths: | |
1 - Update .env file to NODE_PATH=./; | |
2 - Create one tsconfig.paths.json: | |
{ | |
"compilerOptions": { | |
"baseUrl": ".", | |
"paths": { | |
"src/*": ["src/*"] | |
} | |
} | |
} | |
3 - Add this as your first entry in tsconfig.json: | |
"extends": "./tsconfig.paths.json", | |
Now everything should work fine, just reference the src/ folder in your imports instead of @. | |
YES, CRA will complain about the tsconfig.json absolute paths and stuff, but... VSCode seems to work pretty well with it and I think other IDEs will just as well. | |
EDIT: CRA complains but don't really remove the lines because it extends from the paths.json file so it can't modify it! | |
二、"Cannot compile namespaces" error with --isolatedModules and no namespaces | |
A global file cannot be compiled using '--isolatedModules'. | |
Ensure your file contains imports, exports, or an 'export {}' statement. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment