I have the following file structure
|__ app1/
| |__ tsconfig.json
|__ utilities/
| |__ files.ts
|__ base-tsconfig.json
In base-tsconfig.json
I have set the paths
property as following
"compilerOptions": {
"baseUrl": ".",
"paths": {
"utils/*": ["utilities/*"]
}
}
and in tsconfig.json
it looks as follow
{
"extends": "../base-tsconfig",
}
That should be enough right? I am still getting below message though.
Cannot find module 'utils'
You could use multiple tsconfig files to solve some of those problems, but new ones would appear: There's no built-in up-to-date checking, so you end up always running tsc twice.
The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.
allowJs is the option newly available in 1.8. The TypeScript compiler will run a quick sanity check on . js files for syntax errors but otherwise passes them straight through to the output directory.
The "paths"
option can be used to inform the compiler of mappings but it does not perform these path transformations by itself. You can read more about this in the docs and in this issue. Most likely you are using a loader which does not
allow remapping, such as Node.js's require().
There are packages available to help resolve this problem such as module-alias and tsconfig-paths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With