I am trying to configure my tsconfig.json for a package inside my react native project to add module resolution and make the code cleaner so instead of
import { LABELS } from "../../../constants";
I can just write
import { LABELS } from "src/constants"; or import { LABELS } from "@app-content/constants";
here is my tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@app-content/*": ["./src/*"]
}
},
"include": ["__tests__/**/*", "src/**/*", "typings/*"]
}
so the folder structure is like this:
root
--src
--packages
---src
----components
----constants
---tsconfig.json
The resolution is working correctly on vs-code if I write “src/” or “@app-content/” it shows the correct folders and there are no errors at that time, also the app is running successfully but when I run the command tsc
it gives error
error TS2307: Cannot find module 'src/constants' or its corresponding type declarations.